Skip to content

Commit

Permalink
chore: initial commit of ee10 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and hantsy committed Oct 22, 2023
1 parent bc3adc5 commit ff13ff7
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 176 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ updates:
- dependency-name: "org.jboss.resteasy:resteasy-client"
update-types: [ "version-update:semver-major", "version-update:semver-minor"]
- dependency-name: "jakarta.platform:jakarta.jakartaee-api"
versions: [ "9.x" ]
versions: [ "10.x" ]
- dependency-name: "org.glassfish.jaxb:jaxb-runtime"
versions: [ "3.x" ]
versions: [ "4.x" ]
- dependency-name: "*"
update-types: [ "version-update:semver-major"]
5 changes: 5 additions & 0 deletions .github/workflows/arq-glassfish-managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
java-version: '21'
distribution: 'zulu'
cache: maven
- name: Set up Database
run: |
docker-compose up -d postgres
sleep 5
docker ps -a
- name: Build with Maven
run: |
mvn -B -q clean verify -Parq-glassfish-managed
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/arq-glassfish-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ jobs:
java-version: '21'
distribution: 'zulu'
cache: maven
- name: Set up Database
run: |
docker-compose up -d postgres
sleep 5
docker ps -a
- name: Run Glassfish Server
run: |
export GLASSFISH_ARCHIVE=glassfish7
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/arq-wildfly-managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ jobs:
distribution: 'zulu'
java-version: '21'
cache: "maven"
- name: Run integration test with -Parq-wildfly-managed
- name: Set up Database
run: |
docker-compose up -d postgres
sleep 5
docker ps -a
- name: Build with Maven
run: mvn clean verify -Parq-wildfly-managed
5 changes: 5 additions & 0 deletions .github/workflows/arq-wildfly-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
distribution: 'zulu'
java-version: '21'
cache: "maven"
- name: Set up Database
run: |
docker-compose up -d postgres
sleep 5
docker ps -a
- name: Run WildFly server
run: |
export WF_ARCHIVE=wildfly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@ 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.
}

/**
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ public class BookingServiceTest {
private static List<Itinerary> 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() {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class CargoInspectionServiceTest {
mock(HandlingEventRepository.class);

@SuppressWarnings("unchecked")
private final Event<Cargo> cargoEvent = (Event<Cargo>)mock(Event.class);
private final Event<Cargo> cargoEvent = (Event<Cargo>) mock(Event.class);

//
private CargoInspectionService service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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))
Expand All @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static org.junit.jupiter.api.Assertions.*;


public class CargoTest {

private final List<HandlingEvent> events = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import static org.junit.jupiter.api.Assertions.*;


public class ItineraryTest {

private Voyage voyage =
Expand Down Expand Up @@ -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));
}

Expand Down
Loading

0 comments on commit ff13ff7

Please sign in to comment.