From e04f4edd7a22f1268972d860c44e23db392300d3 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Sun, 22 Oct 2023 04:26:16 +0000 Subject: [PATCH] Google Java Format --- .../application/BookingService.java | 16 +++---- .../application/HandlingEventService.java | 4 +- .../domain/model/location/Location.java | 13 ++---- .../messaging/JMSResourcesSetup.java | 19 +++----- .../client/GraphTraversalResourceClient.java | 3 +- .../application/ApplicationEventsTest.java | 23 ++++------ .../application/BookingServiceTest.java | 15 +++--- .../CargoInspectionServiceTest.java | 3 +- .../application/HandlingEventServiceTest.java | 30 +++++------- .../domain/model/cargo/CargoTest.java | 1 - .../domain/model/cargo/ItineraryTest.java | 29 ++++++------ .../model/handling/HandlingEventTest.java | 1 - .../model/handling/HandlingHistoryTest.java | 3 +- .../domain/shared/DomainObjectUtilsTest.java | 1 - .../persistence/jpa/CargoRepositoryTest.java | 24 ++++------ .../jpa/CarrierMovementRepositoryTest.java | 9 ++-- .../jpa/HandlingEventRepositoryTest.java | 18 +++----- .../jpa/LocationRepositoryTest.java | 6 +-- .../routing/ExternalRoutingServiceTest.java | 3 +- .../rest/CargoMonitoringServiceTest.java | 7 ++- .../RealtimeCargoTrackingServiceTest.java | 3 +- .../rest/HandlingReportServiceTest.java | 8 ++-- .../scenario/CargoLifecycleScenarioTest.java | 46 ++++++++----------- 23 files changed, 112 insertions(+), 173 deletions(-) diff --git a/src/main/java/org/eclipse/cargotracker/application/BookingService.java b/src/main/java/org/eclipse/cargotracker/application/BookingService.java index df60c699..8984169c 100644 --- a/src/main/java/org/eclipse/cargotracker/application/BookingService.java +++ b/src/main/java/org/eclipse/cargotracker/application/BookingService.java @@ -10,20 +10,16 @@ import java.time.LocalDate; import java.util.List; -/** - * Cargo booking service. - */ +/** Cargo booking service. */ public interface BookingService { - /** - * Registers a new cargo in the tracking system, not yet routed. - */ + /** Registers a new cargo in the tracking system, not yet routed. */ TrackingId bookNewCargo( @NotNull(message = "Origin is required") @Valid UnLocode origin, @NotNull(message = "Destination is required") @Valid UnLocode destination, @NotNull(message = "Deadline is required") - @Future(message = "Deadline must be in the future") - LocalDate arrivalDeadline); + @Future(message = "Deadline must be in the future") + LocalDate arrivalDeadline); /** * Requests a list of itineraries describing possible routes for this cargo. @@ -45,6 +41,6 @@ void changeDestination( void changeDeadline( @NotNull(message = "Tracking ID is required") @Valid TrackingId trackingId, @NotNull(message = "Deadline is required") - @Future(message = "Deadline must be in the future") - LocalDate deadline); + @Future(message = "Deadline must be in the future") + LocalDate deadline); } diff --git a/src/main/java/org/eclipse/cargotracker/application/HandlingEventService.java b/src/main/java/org/eclipse/cargotracker/application/HandlingEventService.java index 3ba6c5bc..ff8050ea 100644 --- a/src/main/java/org/eclipse/cargotracker/application/HandlingEventService.java +++ b/src/main/java/org/eclipse/cargotracker/application/HandlingEventService.java @@ -21,6 +21,6 @@ void registerHandlingEvent( @NotNull(message = "Tracking ID is required.") @Valid TrackingId trackingId, @Valid VoyageNumber voyageNumber, @NotNull(message = "Location is required.") @Valid UnLocode unLocode, - @NotNull(message = "Type is required.") HandlingEvent.Type type - ) throws CannotCreateHandlingEventException; + @NotNull(message = "Type is required.") HandlingEvent.Type type) + throws CannotCreateHandlingEventException; } diff --git a/src/main/java/org/eclipse/cargotracker/domain/model/location/Location.java b/src/main/java/org/eclipse/cargotracker/domain/model/location/Location.java index c3625c49..49643507 100644 --- a/src/main/java/org/eclipse/cargotracker/domain/model/location/Location.java +++ b/src/main/java/org/eclipse/cargotracker/domain/model/location/Location.java @@ -25,14 +25,9 @@ public class Location implements Serializable { public static final Location UNKNOWN = new Location(new UnLocode("XXXXX"), "Unknown location"); private static final long serialVersionUID = 1L; - @Id - @GeneratedValue - private Long id; - @Embedded - @NotNull - private UnLocode unLocode; - @NotEmpty - private String name; + @Id @GeneratedValue private Long id; + @Embedded @NotNull private UnLocode unLocode; + @NotEmpty private String name; public Location() { // Nothing to do. @@ -40,7 +35,7 @@ public Location() { /** * @param unLocode UN Locode - * @param name Location name + * @param name Location name * @throws IllegalArgumentException if the UN Locode or name is null */ public Location(UnLocode unLocode, String name) { diff --git a/src/main/java/org/eclipse/cargotracker/infrastructure/messaging/JMSResourcesSetup.java b/src/main/java/org/eclipse/cargotracker/infrastructure/messaging/JMSResourcesSetup.java index 024c8140..9d6dd66d 100644 --- a/src/main/java/org/eclipse/cargotracker/infrastructure/messaging/JMSResourcesSetup.java +++ b/src/main/java/org/eclipse/cargotracker/infrastructure/messaging/JMSResourcesSetup.java @@ -16,33 +16,27 @@ name = "java:app/jms/CargoHandledQueue", // resourceAdapter = "jmsra", interfaceName = "jakarta.jms.Queue", - destinationName = "CargoHandledQueue" -) + destinationName = "CargoHandledQueue") @JMSDestinationDefinition( name = "java:app/jms/MisdirectedCargoQueue", // resourceAdapter = "jmsra", interfaceName = "jakarta.jms.Queue", - destinationName = "MisdirectedCargoQueue" -) + destinationName = "MisdirectedCargoQueue") @JMSDestinationDefinition( name = "java:app/jms/DeliveredCargoQueue", // resourceAdapter = "jmsra", interfaceName = "jakarta.jms.Queue", - destinationName = "DeliveredCargoQueue" -) + destinationName = "DeliveredCargoQueue") @JMSDestinationDefinition( name = "java:app/jms/RejectedRegistrationAttemptsQueue", // resourceAdapter = "jmsra", interfaceName = "jakarta.jms.Queue", - destinationName = "RejectedRegistrationAttemptsQueue" -) + destinationName = "RejectedRegistrationAttemptsQueue") @JMSDestinationDefinition( name = "java:app/jms/HandlingEventRegistrationAttemptQueue", // resourceAdapter = "jmsra", interfaceName = "jakarta.jms.Queue", - destinationName = "HandlingEventRegistrationAttemptQueue" -) - + destinationName = "HandlingEventRegistrationAttemptQueue") @Startup @Singleton public class JMSResourcesSetup { @@ -53,6 +47,7 @@ public class JMSResourcesSetup { @PostConstruct public void init() { - LOGGER.log(Level.INFO, "JMS connectionFactory is available : {0} ", connectionFactory != null); + LOGGER.log( + Level.INFO, "JMS connectionFactory is available : {0} ", connectionFactory != null); } } diff --git a/src/main/java/org/eclipse/cargotracker/infrastructure/routing/client/GraphTraversalResourceClient.java b/src/main/java/org/eclipse/cargotracker/infrastructure/routing/client/GraphTraversalResourceClient.java index 6af4fd1c..51225519 100644 --- a/src/main/java/org/eclipse/cargotracker/infrastructure/routing/client/GraphTraversalResourceClient.java +++ b/src/main/java/org/eclipse/cargotracker/infrastructure/routing/client/GraphTraversalResourceClient.java @@ -17,7 +17,8 @@ @ApplicationScoped public class GraphTraversalResourceClient { - private static final Logger LOGGER = Logger.getLogger(GraphTraversalResourceClient.class.getName()); + private static final Logger LOGGER = + Logger.getLogger(GraphTraversalResourceClient.class.getName()); @Resource(lookup = "java:app/configuration/GraphTraversalUrl") private String graphTraversalUrl; diff --git a/src/test/java/org/eclipse/cargotracker/application/ApplicationEventsTest.java b/src/test/java/org/eclipse/cargotracker/application/ApplicationEventsTest.java index 22220c66..4fdb3d66 100644 --- a/src/test/java/org/eclipse/cargotracker/application/ApplicationEventsTest.java +++ b/src/test/java/org/eclipse/cargotracker/application/ApplicationEventsTest.java @@ -54,14 +54,10 @@ public class ApplicationEventsTest { // private DeliveredCargoConsumer deliveredCargoConsumer; private static LocalDate deadline; private static Itinerary assigned; - @Inject - UserTransaction utx; - @Inject - CargoInspectionServiceStub cargoInspectionService; - @Inject - HandlingEventServiceStub handlingEventService; - @Inject - JMSContext jmsContext; + @Inject UserTransaction utx; + @Inject CargoInspectionServiceStub cargoInspectionService; + @Inject HandlingEventServiceStub handlingEventService; + @Inject JMSContext jmsContext; // MSB can not be injected as normal CDI beans. // https://rmannibucau.metawerx.net/post/cdi-proxy-interceptor-support-with-interceptionfactory // @@ -84,8 +80,7 @@ public class ApplicationEventsTest { // // assertThat(argumentCaptor.getValue().toString()).contains("AAA"); // } - @Inject - private ApplicationEvents applicationEvents; + @Inject private ApplicationEvents applicationEvents; @Resource(lookup = "java:app/jms/MisdirectedCargoQueue") private Destination misdirectedCargoQueue; @@ -244,8 +239,7 @@ public void testCargoWasMisdirected() throws InterruptedException, JMSException @ApplicationScoped public static class CargoInspectionServiceStub implements CargoInspectionService { public static CountDownLatch latch; - @Inject - Logger logger; + @Inject Logger logger; private TrackingId trackingId; @@ -264,8 +258,7 @@ public TrackingId getTrackingId() { @ApplicationScoped public static class HandlingEventServiceStub implements HandlingEventService { public static CountDownLatch latch; - @Inject - Logger logger; + @Inject Logger logger; private LocalDateTime completionTime; private TrackingId trackingId; private VoyageNumber voyageNumber; @@ -288,7 +281,7 @@ public void registerHandlingEvent( + "voyageNumber: {2}\n" + "unLocode: {3}\n" + "type: {4}", - new Object[]{completionTime, trackingId, voyageNumber, unLocode, type}); + new Object[] {completionTime, trackingId, voyageNumber, unLocode, type}); this.completionTime = completionTime; this.trackingId = trackingId; this.voyageNumber = voyageNumber; diff --git a/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java b/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java index 4e30b3f1..2cc3da0c 100644 --- a/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/application/BookingServiceTest.java @@ -54,12 +54,9 @@ public class BookingServiceTest { private static List candidates; private static LocalDate deadline; private static Itinerary assigned; - @Inject - UserTransaction utx; - @Inject - private BookingService bookingService; - @PersistenceContext - private EntityManager entityManager; + @Inject UserTransaction utx; + @Inject private BookingService bookingService; + @PersistenceContext private EntityManager entityManager; @Deployment public static WebArchive createDeployment() { @@ -192,9 +189,9 @@ public void testAssignRoute() { assertEquals(Voyage.NONE, cargo.getDelivery().getCurrentVoyage()); assertThat(cargo.getDelivery().isMisdirected()).isFalse(); assertThat( - cargo.getDelivery() - .getEstimatedTimeOfArrival() - .isBefore(deadline.atStartOfDay())) + cargo.getDelivery() + .getEstimatedTimeOfArrival() + .isBefore(deadline.atStartOfDay())) .isTrue(); assertEquals( HandlingEvent.Type.RECEIVE, diff --git a/src/test/java/org/eclipse/cargotracker/application/CargoInspectionServiceTest.java b/src/test/java/org/eclipse/cargotracker/application/CargoInspectionServiceTest.java index 2df6744b..e07ee988 100644 --- a/src/test/java/org/eclipse/cargotracker/application/CargoInspectionServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/application/CargoInspectionServiceTest.java @@ -31,7 +31,8 @@ public class CargoInspectionServiceTest { mock(HandlingEventRepository.class); @SuppressWarnings("unchecked") - private final Event cargoEvent = (Event)mock(Event.class); + private final Event cargoEvent = (Event) mock(Event.class); + // private CargoInspectionService service; diff --git a/src/test/java/org/eclipse/cargotracker/application/HandlingEventServiceTest.java b/src/test/java/org/eclipse/cargotracker/application/HandlingEventServiceTest.java index bbd15fb5..ef48e01c 100644 --- a/src/test/java/org/eclipse/cargotracker/application/HandlingEventServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/application/HandlingEventServiceTest.java @@ -43,25 +43,21 @@ public void setUp() { @Test public void testRegisterEvent() throws Exception { // assume - when(handlingEventFactory - .createHandlingEvent( + when(handlingEventFactory.createHandlingEvent( any(LocalDateTime.class), any(LocalDateTime.class), any(TrackingId.class), any(VoyageNumber.class), any(UnLocode.class), - any(HandlingEvent.Type.class) - ) - ).thenReturn( - new HandlingEvent( - cargo, - LocalDateTime.now(), - LocalDateTime.now(), - HandlingEvent.Type.LOAD, - SampleLocations.STOCKHOLM, - SampleVoyages.CM001 - ) - ); + any(HandlingEvent.Type.class))) + .thenReturn( + new HandlingEvent( + cargo, + LocalDateTime.now(), + LocalDateTime.now(), + HandlingEvent.Type.LOAD, + SampleLocations.STOCKHOLM, + SampleVoyages.CM001)); doNothing().when(handlingEventRepository).store(any(HandlingEvent.class)); doNothing().when(applicationEvents).cargoWasHandled(any(HandlingEvent.class)); @@ -71,8 +67,7 @@ public void testRegisterEvent() throws Exception { cargo.getTrackingId(), SampleVoyages.CM001.getVoyageNumber(), SampleLocations.STOCKHOLM.getUnLocode(), - HandlingEvent.Type.LOAD - ); + HandlingEvent.Type.LOAD); // verify verify(handlingEventFactory, times(1)) @@ -82,8 +77,7 @@ public void testRegisterEvent() throws Exception { any(TrackingId.class), any(VoyageNumber.class), any(UnLocode.class), - any(HandlingEvent.Type.class) - ); + any(HandlingEvent.Type.class)); verify(handlingEventRepository, times(1)).store(any(HandlingEvent.class)); verify(applicationEvents, times(1)).cargoWasHandled(any(HandlingEvent.class)); diff --git a/src/test/java/org/eclipse/cargotracker/domain/model/cargo/CargoTest.java b/src/test/java/org/eclipse/cargotracker/domain/model/cargo/CargoTest.java index a09ae286..b55b2e48 100644 --- a/src/test/java/org/eclipse/cargotracker/domain/model/cargo/CargoTest.java +++ b/src/test/java/org/eclipse/cargotracker/domain/model/cargo/CargoTest.java @@ -18,7 +18,6 @@ import static org.junit.jupiter.api.Assertions.*; - public class CargoTest { private final List events = new ArrayList<>(); diff --git a/src/test/java/org/eclipse/cargotracker/domain/model/cargo/ItineraryTest.java b/src/test/java/org/eclipse/cargotracker/domain/model/cargo/ItineraryTest.java index b6808d3d..78b4a495 100644 --- a/src/test/java/org/eclipse/cargotracker/domain/model/cargo/ItineraryTest.java +++ b/src/test/java/org/eclipse/cargotracker/domain/model/cargo/ItineraryTest.java @@ -14,7 +14,6 @@ import static org.junit.jupiter.api.Assertions.*; - public class ItineraryTest { private Voyage voyage = @@ -146,21 +145,23 @@ public void testCargoOnTrack() { assertFalse(itinerary.isExpected(event)); // Unloaded from the wrong ship in the wrong location - event = new HandlingEvent( - cargo, - LocalDateTime.now(), - LocalDateTime.now(), - HandlingEvent.Type.UNLOAD, - SampleLocations.HELSINKI, - wrongVoyage); + event = + new HandlingEvent( + cargo, + LocalDateTime.now(), + LocalDateTime.now(), + HandlingEvent.Type.UNLOAD, + SampleLocations.HELSINKI, + wrongVoyage); assertFalse(itinerary.isExpected(event)); - event = new HandlingEvent( - cargo, - LocalDateTime.now(), - LocalDateTime.now(), - HandlingEvent.Type.CLAIM, - SampleLocations.ROTTERDAM); + event = + new HandlingEvent( + cargo, + LocalDateTime.now(), + LocalDateTime.now(), + HandlingEvent.Type.CLAIM, + SampleLocations.ROTTERDAM); assertFalse(itinerary.isExpected(event)); } diff --git a/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingEventTest.java b/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingEventTest.java index 4cc7c5cf..8d36eb2e 100644 --- a/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingEventTest.java +++ b/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingEventTest.java @@ -14,7 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; - public class HandlingEventTest { private final TrackingId trackingId = new TrackingId("XYZ"); diff --git a/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingHistoryTest.java b/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingHistoryTest.java index 1b8cec2e..8fb0ac93 100644 --- a/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingHistoryTest.java +++ b/src/test/java/org/eclipse/cargotracker/domain/model/handling/HandlingHistoryTest.java @@ -71,7 +71,8 @@ public class HandlingHistoryTest { @Test public void testDistinctEventsByCompletionTime() { - assertEquals(Arrays.asList(event1, event2), handlingHistory.getDistinctEventsByCompletionTime()); + assertEquals( + Arrays.asList(event1, event2), handlingHistory.getDistinctEventsByCompletionTime()); } @Test diff --git a/src/test/java/org/eclipse/cargotracker/domain/shared/DomainObjectUtilsTest.java b/src/test/java/org/eclipse/cargotracker/domain/shared/DomainObjectUtilsTest.java index e5f19844..a410e0a0 100644 --- a/src/test/java/org/eclipse/cargotracker/domain/shared/DomainObjectUtilsTest.java +++ b/src/test/java/org/eclipse/cargotracker/domain/shared/DomainObjectUtilsTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; - public class DomainObjectUtilsTest { @Test diff --git a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CargoRepositoryTest.java b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CargoRepositoryTest.java index 63617f7f..92bf41f2 100644 --- a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CargoRepositoryTest.java +++ b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CargoRepositoryTest.java @@ -5,7 +5,6 @@ import jakarta.persistence.PersistenceContext; import jakarta.transaction.Status; import jakarta.transaction.UserTransaction; -import org.eclipse.cargotracker.IntegrationTests; import org.eclipse.cargotracker.application.util.SampleDataGenerator; import org.eclipse.cargotracker.domain.model.cargo.*; import org.eclipse.cargotracker.domain.model.handling.HandlingEvent; @@ -44,22 +43,16 @@ @Tag("arqtest") public class CargoRepositoryTest { private static final Logger LOGGER = Logger.getLogger(CargoRepositoryTest.class.getName()); - @Inject - UserTransaction utx; - @Inject - private LocationRepository locationRepository; + @Inject UserTransaction utx; + @Inject private LocationRepository locationRepository; - @Inject - private HandlingEventRepository handlingEventRepository; + @Inject private HandlingEventRepository handlingEventRepository; - @Inject - private CargoRepository cargoRepository; + @Inject private CargoRepository cargoRepository; - @Inject - private VoyageRepository voyageRepository; + @Inject private VoyageRepository voyageRepository; - @PersistenceContext - private EntityManager entityManager; + @PersistenceContext private EntityManager entityManager; @Deployment public static WebArchive createDeployment() { @@ -92,8 +85,7 @@ public static WebArchive createDeployment() { } @BeforeEach - public void setup() { - } + public void setup() {} public void startTransaction() throws Exception { utx.begin(); @@ -296,7 +288,7 @@ public void testSpecifyNewRoute() throws Exception { LOGGER.log( Level.INFO, "query cargo by tracking id: {0}, \n result: {1}", - new Object[]{trackingId, result.toString(true)}); + new Object[] {trackingId, result.toString(true)}); assertThat(result.getTrackingId()).isEqualTo(trackingId); assertThat(result.getRouteSpecification().getOrigin()).isEqualTo(origin); assertThat(result.getRouteSpecification().getDestination()).isEqualTo(destination); diff --git a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CarrierMovementRepositoryTest.java b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CarrierMovementRepositoryTest.java index 1f8924df..77700b85 100644 --- a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CarrierMovementRepositoryTest.java +++ b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/CarrierMovementRepositoryTest.java @@ -31,12 +31,9 @@ public class CarrierMovementRepositoryTest { private static final Logger LOGGER = Logger.getLogger(CarrierMovementRepositoryTest.class.getName()); - @Inject - VoyageRepository voyageRepository; - @PersistenceContext - EntityManager entityManager; - @Inject - UserTransaction utx; + @Inject VoyageRepository voyageRepository; + @PersistenceContext EntityManager entityManager; + @Inject UserTransaction utx; String voyageNumberIdString = "007"; Voyage voyage; Location from = SampleLocations.HONGKONG; diff --git a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/HandlingEventRepositoryTest.java b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/HandlingEventRepositoryTest.java index f332a608..26976cf2 100644 --- a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/HandlingEventRepositoryTest.java +++ b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/HandlingEventRepositoryTest.java @@ -40,19 +40,14 @@ public class HandlingEventRepositoryTest { private static final Logger LOGGER = Logger.getLogger(HandlingEventRepositoryTest.class.getName()); - @Inject - UserTransaction utx; - @Inject - private LocationRepository locationRepository; + @Inject UserTransaction utx; + @Inject private LocationRepository locationRepository; - @Inject - private HandlingEventRepository handlingEventRepository; + @Inject private HandlingEventRepository handlingEventRepository; - @Inject - private CargoRepository cargoRepository; + @Inject private CargoRepository cargoRepository; - @PersistenceContext - private EntityManager entityManager; + @PersistenceContext private EntityManager entityManager; @Deployment public static WebArchive createDeployment() { @@ -86,8 +81,7 @@ public static WebArchive createDeployment() { } @BeforeEach - public void setup() { - } + public void setup() {} public void startTransaction() throws Exception { utx.begin(); diff --git a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/LocationRepositoryTest.java b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/LocationRepositoryTest.java index 7f6a090a..c45b52b3 100644 --- a/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/LocationRepositoryTest.java +++ b/src/test/java/org/eclipse/cargotracker/infrastructure/persistence/jpa/LocationRepositoryTest.java @@ -27,8 +27,7 @@ @Tag("arqtest") public class LocationRepositoryTest { private static final Logger LOGGER = Logger.getLogger(LocationRepositoryTest.class.getName()); - @Inject - private LocationRepository locationRepository; + @Inject private LocationRepository locationRepository; @Deployment public static WebArchive createDeployment() { @@ -61,8 +60,7 @@ public static WebArchive createDeployment() { } @BeforeEach - public void setup() { - } + public void setup() {} @Test public void testFind() { diff --git a/src/test/java/org/eclipse/cargotracker/infrastructure/routing/ExternalRoutingServiceTest.java b/src/test/java/org/eclipse/cargotracker/infrastructure/routing/ExternalRoutingServiceTest.java index 67965e48..81da1e1e 100644 --- a/src/test/java/org/eclipse/cargotracker/infrastructure/routing/ExternalRoutingServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/infrastructure/routing/ExternalRoutingServiceTest.java @@ -106,6 +106,7 @@ public void testCalculatePossibleRoutes() { verify(voyageRepository, atLeastOnce()).find(any(VoyageNumber.class)); verify(locationRepository, atLeastOnce()).find(any(UnLocode.class)); - verifyNoMoreInteractions(voyageRepository, locationRepository, graphTraversalResourceClient); + verifyNoMoreInteractions( + voyageRepository, locationRepository, graphTraversalResourceClient); } } diff --git a/src/test/java/org/eclipse/cargotracker/interfaces/booking/rest/CargoMonitoringServiceTest.java b/src/test/java/org/eclipse/cargotracker/interfaces/booking/rest/CargoMonitoringServiceTest.java index 0d40101a..e39b99c9 100644 --- a/src/test/java/org/eclipse/cargotracker/interfaces/booking/rest/CargoMonitoringServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/interfaces/booking/rest/CargoMonitoringServiceTest.java @@ -33,8 +33,7 @@ public class CargoMonitoringServiceTest { private static final Logger LOGGER = Logger.getLogger(CargoMonitoringServiceTest.class.getName()); - @ArquillianResource - private URL base; + @ArquillianResource private URL base; private Client client; @Deployment(testable = false) @@ -83,11 +82,11 @@ public void teardown() { public void testCargoStatus() throws Exception { LOGGER.log(Level.INFO, " Running test:: CargoMonitoringServiceTest#testCargoStatus ... "); final WebTarget getCargoStatus = - client.target(URI.create(base+ "rest/cargo").toURL().toExternalForm()); + client.target(URI.create(base + "rest/cargo").toURL().toExternalForm()); // Response is an autocloseable resource. try (final Response getAllPostsResponse = - getCargoStatus.request().accept(MediaType.APPLICATION_JSON).get()) { + getCargoStatus.request().accept(MediaType.APPLICATION_JSON).get()) { assertThat(getAllPostsResponse.getStatus()).isEqualTo(200); // TODO: use POJO to assert the response body. } diff --git a/src/test/java/org/eclipse/cargotracker/interfaces/booking/socket/RealtimeCargoTrackingServiceTest.java b/src/test/java/org/eclipse/cargotracker/interfaces/booking/socket/RealtimeCargoTrackingServiceTest.java index becba784..4b441333 100644 --- a/src/test/java/org/eclipse/cargotracker/interfaces/booking/socket/RealtimeCargoTrackingServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/interfaces/booking/socket/RealtimeCargoTrackingServiceTest.java @@ -33,8 +33,7 @@ public class RealtimeCargoTrackingServiceTest { private static final Logger LOGGER = Logger.getLogger(RealtimeCargoTrackingServiceTest.class.getName()); - @ArquillianResource - URL base; + @ArquillianResource URL base; @Deployment(testable = false) public static WebArchive createDeployment() { diff --git a/src/test/java/org/eclipse/cargotracker/interfaces/handling/rest/HandlingReportServiceTest.java b/src/test/java/org/eclipse/cargotracker/interfaces/handling/rest/HandlingReportServiceTest.java index 934cb359..beb70158 100644 --- a/src/test/java/org/eclipse/cargotracker/interfaces/handling/rest/HandlingReportServiceTest.java +++ b/src/test/java/org/eclipse/cargotracker/interfaces/handling/rest/HandlingReportServiceTest.java @@ -73,11 +73,9 @@ public static WebArchive createDeployment() { return war; } - @ArquillianResource - URL base; + @ArquillianResource URL base; - @Inject - ApplicationEventsStub applicationEventsStub; + @Inject ApplicationEventsStub applicationEventsStub; private Client client; @@ -107,7 +105,7 @@ public void submitReport() throws MalformedURLException { // Response is an autocloseable resource. try (final Response postReportResponse = - postReportTarget.request().post(Entity.json(report))) { + postReportTarget.request().post(Entity.json(report))) { assertThat(postReportResponse.getStatus()).isEqualTo(202); LOGGER.log( Level.INFO, diff --git a/src/test/java/org/eclipse/cargotracker/scenario/CargoLifecycleScenarioTest.java b/src/test/java/org/eclipse/cargotracker/scenario/CargoLifecycleScenarioTest.java index 3faa5879..f031fc03 100644 --- a/src/test/java/org/eclipse/cargotracker/scenario/CargoLifecycleScenarioTest.java +++ b/src/test/java/org/eclipse/cargotracker/scenario/CargoLifecycleScenarioTest.java @@ -64,8 +64,7 @@ public class CargoLifecycleScenarioTest { private static LocalDate arrivalDeadline = LocalDate.now().minusYears(1).plusMonths(3).plusDays(18); private static TrackingId trackingId; - @Inject - UserTransaction utx; + @Inject UserTransaction utx; /** * Repository implementations are part of the infrastructure layer, which in this test is @@ -73,10 +72,8 @@ public class CargoLifecycleScenarioTest { */ HandlingEventRepository handlingEventRepository; - @Inject - CargoRepository cargoRepository; - @Inject - LocationRepository locationRepository; + @Inject CargoRepository cargoRepository; + @Inject LocationRepository locationRepository; VoyageRepository voyageRepository; /** @@ -92,11 +89,9 @@ public class CargoLifecycleScenarioTest { * application. The "real" implementations are used in this lifecycle test, but wired with * stubbed infrastructure. */ - @Inject - BookingService bookingService; + @Inject BookingService bookingService; - @Inject - HandlingEventService handlingEventService; + @Inject HandlingEventService handlingEventService; CargoInspectionService cargoInspectionService; /** @@ -114,8 +109,7 @@ public class CargoLifecycleScenarioTest { */ RoutingService routingService; - @PersistenceContext - private EntityManager entityManager; + @PersistenceContext private EntityManager entityManager; @Deployment public static WebArchive createDeployment() { @@ -361,14 +355,14 @@ public void testCannotCreateHandlingEventException() throws Exception { UnLocode noSuchUnLocode = new UnLocode("ZZZZZ"); assertThatThrownBy( - () -> - handlingEventService.registerHandlingEvent( - LocalDateTime.now().minusYears(1).plusMonths(3).plusDays(5), - trackingId, - noSuchVoyageNumber, - noSuchUnLocode, - HandlingEvent.Type.LOAD), - "Should not be able to register a handling event with invalid location and voyage") + () -> + handlingEventService.registerHandlingEvent( + LocalDateTime.now().minusYears(1).plusMonths(3).plusDays(5), + trackingId, + noSuchVoyageNumber, + noSuchUnLocode, + HandlingEvent.Type.LOAD), + "Should not be able to register a handling event with invalid location and voyage") .isInstanceOf(CannotCreateHandlingEventException.class); } @@ -732,11 +726,9 @@ public static class RoutingServiceStub implements RoutingService { private static final Logger LOGGER = Logger.getLogger(RoutingServiceStub.class.getName()); - @Inject - private LocationRepository locationRepository; + @Inject private LocationRepository locationRepository; - @Inject - private VoyageRepository voyageRepository; + @Inject private VoyageRepository voyageRepository; @Override public List fetchRoutesForSpecification(RouteSpecification routeSpecification) { @@ -834,12 +826,10 @@ public List fetchRoutesForSpecification(RouteSpecification routeSpeci @ApplicationScoped public static class SynchronousApplicationEventsStub implements ApplicationEvents { - @Inject - Instance cargoInspectionServiceInstance; + @Inject Instance cargoInspectionServiceInstance; // no-args constructor required by CDI - public SynchronousApplicationEventsStub() { - } + public SynchronousApplicationEventsStub() {} @Override public void cargoWasHandled(HandlingEvent event) {