|
29 | 29 | import org.opentcs.access.to.order.OrderSequenceCreationTO; |
30 | 30 | import org.opentcs.access.to.order.TransportOrderCreationTO; |
31 | 31 | import org.opentcs.data.model.Vehicle; |
| 32 | +import org.opentcs.data.order.OrderConstants; |
32 | 33 | import org.opentcs.data.order.OrderSequence; |
33 | 34 | import org.opentcs.data.order.TransportOrder; |
34 | 35 | import org.opentcs.util.event.SimpleEventBus; |
@@ -258,6 +259,76 @@ void assignProcessingVehicleToOrderSequenceIfDifferentToPreviousOne() { |
258 | 259 | assertThat(seqAfterThirdAssignment, is(sameInstance(seqAfterSecondAssignment))); |
259 | 260 | } |
260 | 261 |
|
| 262 | + @Test |
| 263 | + void allowAssigningTransportOrderToOrderSequenceWithAnyType() { |
| 264 | + OrderSequence sequence = orderPoolManager.createOrderSequence( |
| 265 | + new OrderSequenceCreationTO("some-sequence") |
| 266 | + .withOrderTypes(Set.of(OrderConstants.TYPE_ANY)) |
| 267 | + ); |
| 268 | + |
| 269 | + orderPoolManager.createTransportOrder( |
| 270 | + new TransportOrderCreationTO( |
| 271 | + "some-order", |
| 272 | + List.of(new DestinationCreationTO("some-location", "NOP")) |
| 273 | + ) |
| 274 | + .withType("some-type") |
| 275 | + .withWrappingSequence(sequence.getName()) |
| 276 | + ); |
| 277 | + |
| 278 | + assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty()))); |
| 279 | + assertThat(objectRepo.getObjects(TransportOrder.class), is(not(empty()))); |
| 280 | + } |
| 281 | + |
| 282 | + @Test |
| 283 | + void allowAssigningTransportOrdersToOrderSequenceWithMatchingType() { |
| 284 | + OrderSequence sequence = orderPoolManager.createOrderSequence( |
| 285 | + new OrderSequenceCreationTO("some-sequence") |
| 286 | + .withOrderTypes(Set.of("some-type", "some-other-type")) |
| 287 | + ); |
| 288 | + |
| 289 | + orderPoolManager.createTransportOrder( |
| 290 | + new TransportOrderCreationTO( |
| 291 | + "some-order", |
| 292 | + List.of(new DestinationCreationTO("some-location", "NOP")) |
| 293 | + ) |
| 294 | + .withType("some-type") |
| 295 | + .withWrappingSequence(sequence.getName()) |
| 296 | + ); |
| 297 | + orderPoolManager.createTransportOrder( |
| 298 | + new TransportOrderCreationTO( |
| 299 | + "some-other-order", |
| 300 | + List.of(new DestinationCreationTO("some-location", "NOP")) |
| 301 | + ) |
| 302 | + .withType("some-other-type") |
| 303 | + .withWrappingSequence(sequence.getName()) |
| 304 | + ); |
| 305 | + |
| 306 | + assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty()))); |
| 307 | + assertThat(objectRepo.getObjects(TransportOrder.class), hasSize(2)); |
| 308 | + } |
| 309 | + |
| 310 | + |
| 311 | + @Test |
| 312 | + void disallowAssigningTransportOrderToOrderSequenceWithNonMatchingType() { |
| 313 | + OrderSequence sequence = orderPoolManager.createOrderSequence( |
| 314 | + new OrderSequenceCreationTO("some-sequence") |
| 315 | + .withOrderTypes(Set.of("some-type")) |
| 316 | + ); |
| 317 | + |
| 318 | + TransportOrderCreationTO creationTO = new TransportOrderCreationTO( |
| 319 | + "some-order", |
| 320 | + List.of(new DestinationCreationTO("some-location", "NOP")) |
| 321 | + ) |
| 322 | + .withType("some-other-type") |
| 323 | + .withWrappingSequence(sequence.getName()); |
| 324 | + |
| 325 | + assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty()))); |
| 326 | + Assertions.assertThrows( |
| 327 | + IllegalArgumentException.class, |
| 328 | + () -> orderPoolManager.createTransportOrder(creationTO) |
| 329 | + ); |
| 330 | + } |
| 331 | + |
261 | 332 | @Test |
262 | 333 | void removeSingleOrderSequence() { |
263 | 334 | OrderSequence sequence = orderPoolManager.createOrderSequence( |
|
0 commit comments