diff --git a/stgroup.mdsd.transportation_network.test/scripts/test.eunit b/stgroup.mdsd.transportation_network.test/scripts/test.eunit index 99401b04894145d04fa55f5924f41d2ba2920d9c..64900a9a1dbb52554795923f8ccbd27d8c03bff1 100644 --- a/stgroup.mdsd.transportation_network.test/scripts/test.eunit +++ b/stgroup.mdsd.transportation_network.test/scripts/test.eunit @@ -17,4 +17,12 @@ operation RoadNetworksShouldOnlyHaveOneRoad() { var numRoads:Integer = rn.roads.size(); assertEquals(rn.identifier + " should have 1 road, but it has " + numRoads, numRoads, 1); } +} + +@Test +operation TestWithValidation() { + var evlTask := antProject.createTask("epsilon.evl"); + evlTask.setSrc(new Native('java.io.File')(antProject.getBaseDir(), './scripts/validation.evl')); + evlTask.createModel().setRef("transformed"); + evlTask.execute(); } \ No newline at end of file diff --git a/stgroup.mdsd.transportation_network.test/scripts/validation.evl b/stgroup.mdsd.transportation_network.test/scripts/validation.evl new file mode 100644 index 0000000000000000000000000000000000000000..dc9aaa896f1f40d8a549a16036610c03ce1168a3 --- /dev/null +++ b/stgroup.mdsd.transportation_network.test/scripts/validation.evl @@ -0,0 +1,9 @@ +context transformed!TransportationNetwork{ + + constraint LocationCount{ + + check: self.locations.size() == 6 + + message: "The transformed Model should have 6 Locations. It has " + self.locations.size() + } +} \ No newline at end of file diff --git a/stgroup.mdsd.transportation_network.validation/validation.evl b/stgroup.mdsd.transportation_network.validation/validation.evl index db955f9666461805aeb3bc5ee7aeb0f3d62acc8b..58a484597b95dee0dd1115526f0121626349b3dc 100644 --- a/stgroup.mdsd.transportation_network.validation/validation.evl +++ b/stgroup.mdsd.transportation_network.validation/validation.evl @@ -43,8 +43,44 @@ context source!IdentifiableElement{ } + +context source!TransportationNetwork{ + + critique RoadNetworkWithoutLength{ + + check: source!CompanyWarehouse.all().size() <> 0 + + message: "No Company Warehouse was found in the Network" + + } + +} + context source!RoadNetwork{ + critique RoadNetworkWithoutLength{ + + check: self.length <> -1 + + message { + var length:Real = 0.0d; + for (road in self.roads) { + length += road.length; + } + self.length = length; + return "Road network did not define a length. Setting it to " + length +". Element: " + self; + } + + } + + critique RoadNetworkWithoutRoads{ + + check: self.roads.size <> 0 + + message: "Road network did not have a road. Element: " + self + + } + constraint RoadNetworkWithoutSourceOrTarget{ check{ @@ -68,3 +104,109 @@ context source!RoadNetwork{ } +context source!Location{ + + critique LocationIsIsolated{ + + check: (self.eContainer().roadnetworks.select(rn| (rn.source == self) or (rn.target == self)).size() <> 0) + + message: "Location is isolated from the Network. Element: " + self + + fix { + title: "Delete Location" + do { + delete self; + } + } + } + +} + +context source!Route{ + + constraint RouteHasNoRoadNetworks{ + + check: self.networkList.size() <> 0 + + message: "Route did not have refernces to road networks . Element: " + self + + } + + constraint RouteStartsNotOnCompanyWareHouse{ + + check: self.start.pois.exists(poi| poi.isKindOf(source!CompanyWarehouse)) + + message: "Route did not start at a company warehouse. Element: " + self + + } + + constraint RouteEndsNotOnCustomerWareHouse{ + + check: self.end.pois.exists(poi| poi.isKindOf(source!CustomerWarehouse)) + + message: "Route did not end at a customer warehouse. Element: " + self + + } + + constraint RouteHasNoVehicle{ + + check: self.vehicle <> null + + message: "Route has not reserved a Vehicle. Element: " + self + + fix { + title: "Reserve first Available" + do { + self.vehicle = source!TransportationNetwork.all().first().carpark.first(); + } + } + + } + + constraint RouteIsToLongForVehicle{ + + check { + var length:Real = 0.0d; + for (rn in self.networkList) { + length += rn.length; + } + return self.vehicle <> null and (self.vehicle.fuelCapacity > length); + } + + message: "Route length ( "+ length + " ) is longer as the vehicles fuel capacity ( " + self.vehicle.fuelCapacity + " ). Element: " + self + + fix { + title: "Reserve fitting" + do { + source!TransportationNetwork.all().first().carpark.add(self.vehicle); + self.vehicle = source!TransportationNetwork.all().first().carpark.selectOne(v| v.fuelCapacity > length); + } + } + + } + +} + +context source!Vehicle{ + + critique VehicleCapacityisNonNormal{ + + check: self.fuelCapacity > 0.0 + + message: "Fuel capacity of a Vehicle is not in the normal range. Element: " + self + + } + +} + +context source!Road{ + + critique RoadLengthisNonNormal{ + + check: self.length > 0.0 + + message: "Length of a Road is not in the normal range. Element: " + self + + } + +} \ No newline at end of file