Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sankaviv1 committed Nov 13, 2023
1 parent 2b0e0a1 commit 0cf8ab2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,6 @@ public static List<Element<Expert>> mapUpdatePartyDetailsFormToDQExperts(List<El
.eventAdded("Manage Contact Information Event")
.partyID(createPartyId())
.build()));
// Replace above to this in CIV-10382
// newExperts.addAll(wrapElements(appendWithNewPartyIds(Expert.builder()
// .firstName(formExpert.getFirstName())
// .lastName(formExpert.getLastName())
// .emailAddress(formExpert.getEmailAddress())
// .phoneNumber(formExpert.getPhoneNumber())
// .fieldOfExpertise(formExpert.getFieldOfExpertise())
// .dateAdded(LocalDate.now())
// .eventAdded("Manage Contact Information Event")
// .build())));
}
}
}
Expand Down Expand Up @@ -251,15 +241,6 @@ public static List<Element<Witness>> mapUpdatePartyDetailsFormToDQWitnesses(List
.eventAdded("Manage Contact Information Event")
.partyID(createPartyId())
.build()));
// Replace above to this in CIV-10382
// newWitnesses.addAll(wrapElements(appendWithNewPartyIds(Witness.builder()
// .firstName(formWitness.getFirstName())
// .lastName(formWitness.getLastName())
// .emailAddress(formWitness.getEmailAddress())
// .phoneNumber(formWitness.getPhoneNumber())
// .dateAdded(LocalDate.now())
// .eventAdded("Manage Contact Information Event")
// .build())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ static void setupSuite() {
@AfterAll
static void tearDown() {
partyIdMock.reset();
partyIdMock.close();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package uk.gov.hmcts.reform.civil.utils;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Party;
import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm;
Expand All @@ -15,6 +19,7 @@
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mockStatic;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP;
import static uk.gov.hmcts.reform.civil.enums.RespondentResponseType.FULL_DEFENCE;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
Expand All @@ -40,8 +45,24 @@
import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQExperts;
import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQWitnesses;

@SuppressWarnings("unchecked")
class ManageContactInformationUtilsTest {

private static final String PARTY_ID = "party-id";
private static MockedStatic partyIdMock;

@BeforeAll
static void setupSuite() {
partyIdMock = mockStatic(PartyUtils.class, Mockito.CALLS_REAL_METHODS);
partyIdMock.when(PartyUtils::createPartyId).thenReturn(PARTY_ID);
}

@AfterAll
static void tearDown() {
partyIdMock.reset();
partyIdMock.close();
}

@Test
void shouldAddCorrectOptions_forClaimant1AsLegalRep() {
CaseData caseDataWithExpertsAndWitnesses = CaseDataBuilder.builder()
Expand Down Expand Up @@ -312,12 +333,12 @@ void shouldEditExperts() {
void shouldAddExperts() {
Expert expectedExpert1 = Expert.builder().firstName("Lewis").lastName("John")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now())
.partyID(null) //change this for CIV-10382
.partyID(PARTY_ID)
.build();
Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1")
.emailAddress("expertemail")
.partyID(null) //change this for CIV-10382
.partyID(PARTY_ID)
.build();

assertThat(mapUpdatePartyDetailsFormToDQExperts(null, wrapElements(party, party2)))
Expand All @@ -331,7 +352,7 @@ void shouldAddExpertsWithExistingExperts() {
Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1")
.emailAddress("expertemail")
.partyID(null) //change this for CIV-10382
.partyID(PARTY_ID)
.build();

assertThat(mapUpdatePartyDetailsFormToDQExperts(wrapElements(expert1), wrapElements(party, party2)))
Expand Down Expand Up @@ -370,11 +391,11 @@ void shouldEditWitnesses() {
void shouldAddWitnesses() {
Witness expectedWitness1 = Witness.builder().firstName("Lewis").lastName("John")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now())
.partyID(null).build(); // CIV-10382
.partyID(PARTY_ID).build();
Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1")
.emailAddress("witnessemail")
.partyID(null).build(); // CIV-10382
.partyID(PARTY_ID).build();

assertThat(mapUpdatePartyDetailsFormToDQWitnesses(null, wrapElements(party, party2)))
.isEqualTo(wrapElements(expectedWitness1, expectedWitness2));
Expand All @@ -393,7 +414,7 @@ void shouldAddWitnessesWithExistingWitnesses() {
Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness")
.eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1")
.emailAddress("witnessemail")
.partyID(null) //change this for CIV-10382
.partyID(PARTY_ID)
.build();

assertThat(mapUpdatePartyDetailsFormToDQWitnesses(wrapElements(witness1), wrapElements(party, party2)))
Expand Down

0 comments on commit 0cf8ab2

Please sign in to comment.