Skip to content

Commit

Permalink
rebased with CoJ syncedAt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenRobertsHEE committed Sep 20, 2023
1 parent 3aca8cd commit a57e85b
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ProgrammeMembershipServiceTest {
private static final String DIFFERENT_PROGRAMME_MEMBERSHIP_UUID = UUID.randomUUID().toString();
private static final Instant COJ_SIGNED_AT = Instant.now();
private static final GoldGuideVersion GOLD_GUIDE_VERSION = GoldGuideVersion.GG9;
private static final Instant COJ_SYNCED_AT = Instant.now();

private ProgrammeMembershipService service;
private TraineeProfileRepository repository;
Expand Down Expand Up @@ -117,7 +118,8 @@ void shouldAddProgrammeMembershipWhenTraineeFoundAndNoProgrammeMembershipsExists
expectedProgrammeMembership.setEndDate(END_DATE.plusDays(100));
expectedProgrammeMembership.setProgrammeCompletionDate(COMPLETION_DATE.plusDays(100));
expectedProgrammeMembership.setConditionsOfJoining(
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION));
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION,
COJ_SYNCED_AT.plus(Duration.ofDays(100))));

assertThat("Unexpected programme membership.", programmeMembership.get(),
is(expectedProgrammeMembership));
Expand Down Expand Up @@ -149,7 +151,8 @@ void shouldAddProgrammeMembershipWhenTraineeFoundAndProgrammeMembershipNotExists
expectedProgrammeMembership.setEndDate(END_DATE.plusDays(100));
expectedProgrammeMembership.setProgrammeCompletionDate(COMPLETION_DATE.plusDays(100));
expectedProgrammeMembership.setConditionsOfJoining(
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION));
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION,
COJ_SYNCED_AT.plus(Duration.ofDays(100))));

assertThat("Unexpected programme membership.", programmeMembership.get(),
is(expectedProgrammeMembership));
Expand Down Expand Up @@ -183,7 +186,8 @@ void shouldUpdateProgrammeMembershipWhenTraineeFoundAndProgrammeMembershipExists
expectedProgrammeMembership.setEndDate(END_DATE.plusDays(100));
expectedProgrammeMembership.setProgrammeCompletionDate(COMPLETION_DATE.plusDays(100));
expectedProgrammeMembership.setConditionsOfJoining(
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION));
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(100)), GOLD_GUIDE_VERSION,
COJ_SYNCED_AT.plus(Duration.ofDays(100))));

assertThat("Unexpected programme membership.", programmeMembership.get(),
is(expectedProgrammeMembership));
Expand Down Expand Up @@ -213,6 +217,7 @@ void shouldNotUpdateProgrammeMembershipCojWhenNewCojNull() {
assertThat("Unexpected signed at.", conditionsOfJoining.signedAt(), is(COJ_SIGNED_AT));
assertThat("Unexpected signed version.", conditionsOfJoining.version(),
is(GoldGuideVersion.GG9));
assertThat("Unexpected synced at.", conditionsOfJoining.syncedAt(), is(COJ_SYNCED_AT));
}

@Test
Expand Down Expand Up @@ -248,7 +253,7 @@ void shouldNotUpdateProgrammeMembershipCojWhenNewCojNotSigned() {
ProgrammeMembership newProgrammeMembership = createProgrammeMembership(
EXISTING_PROGRAMME_MEMBERSHIP_UUID, MODIFIED_SUFFIX, 100);
ConditionsOfJoining newConditionsOfJoining
= new ConditionsOfJoining(null, GoldGuideVersion.GG9);
= new ConditionsOfJoining(null, GoldGuideVersion.GG9, null);
newProgrammeMembership.setConditionsOfJoining(newConditionsOfJoining);

Optional<ProgrammeMembership> programmeMembership = service
Expand All @@ -262,6 +267,7 @@ void shouldNotUpdateProgrammeMembershipCojWhenNewCojNotSigned() {
ConditionsOfJoining conditionsOfJoining = updatedProgrammeMembership.getConditionsOfJoining();
assertThat("Unexpected signed at.", conditionsOfJoining.signedAt(),
is(COJ_SIGNED_AT));
assertThat("Unexpected synced at.", conditionsOfJoining.syncedAt(), is(COJ_SYNCED_AT));
}

@Test
Expand Down Expand Up @@ -330,7 +336,8 @@ void shouldCacheCojFromDeleteProgrammeMembershipsWhenCojSigned() {
void shouldNotCacheCojFromDeleteProgrammeMembershipsWhenCojNotSigned() {
ProgrammeMembership programmeMembership = createProgrammeMembership(
EXISTING_PROGRAMME_MEMBERSHIP_UUID, ORIGINAL_SUFFIX, 0);
programmeMembership.setConditionsOfJoining(new ConditionsOfJoining(null, GoldGuideVersion.GG9));
programmeMembership.setConditionsOfJoining(
new ConditionsOfJoining(null, GoldGuideVersion.GG9, null));

TraineeProfile traineeProfile = new TraineeProfile();
traineeProfile.getProgrammeMemberships().add(programmeMembership);
Expand Down Expand Up @@ -437,6 +444,9 @@ void shouldSignCojWhenTraineeProgrammeMembershipFound() {
assertThat("Unexpected COJ version.",
programmeMembership.get().getConditionsOfJoining().version(),
is(GoldGuideVersion.getLatest()));
assertThat("Unexpected COJ syncedAt.",
programmeMembership.get().getConditionsOfJoining().syncedAt(),
nullValue());
}

@Test
Expand Down Expand Up @@ -486,7 +496,7 @@ private ProgrammeMembership createProgrammeMembership(String tisId, String strin
programmeMembership.setProgrammeCompletionDate(COMPLETION_DATE.plusDays(dateAdjustmentDays));
programmeMembership.setConditionsOfJoining(
new ConditionsOfJoining(COJ_SIGNED_AT.plus(Duration.ofDays(dateAdjustmentDays)),
GOLD_GUIDE_VERSION));
GOLD_GUIDE_VERSION, COJ_SYNCED_AT.plus(Duration.ofDays(dateAdjustmentDays))));

return programmeMembership;
}
Expand Down

0 comments on commit a57e85b

Please sign in to comment.