Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Add equals and hashcode method #11

Merged
merged 3 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -72,6 +78,8 @@
<arg>-Xvalue-constructor</arg>
<arg>-Xfluent-builder</arg>
<arg>-generateTools=n</arg>
<arg>-XsimpleEquals</arg>
<arg>-XsimpleHashCode</arg>
</args>
<plugins>
<plugin>
Expand All @@ -84,6 +92,11 @@
<artifactId>jaxb2-value-constructor</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>1.11.1</version>
</plugin>
</plugins>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package uk.gov.ons.ctp.response.party.definition;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class AssociationTest {

@Test
public void testEquals() {
// Given
Association association = new Association();
association.setPartyId("party id");
Association association2 = new Association();
association2.setPartyId("party id");

// When
boolean equal = association.equals(association2);

// Then
assertTrue(equal);
}
@Test
public void testNotEquals() {
// Given
Association association = new Association();
association.setPartyId("party id");
Association association2 = new Association();

// When
boolean equal = association.equals(association2);

// Then
assertFalse(equal);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package uk.gov.ons.ctp.response.party.definition;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class EnrolmentTest {

@Test
public void testEquals() {
// Given
Enrolment enrolment1 = new Enrolment();
enrolment1.setEnrolmentStatus("enrolment status");
enrolment1.setName("name");
enrolment1.setSurveyId("survey id");
Enrolment enrolment2 = new Enrolment();
enrolment2.setEnrolmentStatus("enrolment status");
enrolment2.setName("name");
enrolment2.setSurveyId("survey id");

// When
boolean equal = enrolment1.equals(enrolment2);

// Then
assertTrue(equal);
}
@Test
public void testNotEquals() {
// Given
Enrolment enrolment1 = new Enrolment();
enrolment1.setEnrolmentStatus("enrolment status");
enrolment1.setName("name");
enrolment1.setSurveyId("survey id");
Enrolment enrolment2 = new Enrolment();

// When
boolean equal = enrolment1.equals(enrolment2);

// Then
assertFalse(equal);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package uk.gov.ons.ctp.response.party.definition;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class PartyCreationRequestAttributesDTOTest {

@Test
public void testEquals() {
// Given
PartyCreationRequestAttributesDTO partyCreation1 = new PartyCreationRequestAttributesDTO();
partyCreation1.setBirthdate("birthdate");
partyCreation1.setCellNo(123);
partyCreation1.setCheckletter("checkletter");
partyCreation1.setCurrency("currency");
partyCreation1.setEntname1("entname1");
PartyCreationRequestAttributesDTO partyCreation2 = new PartyCreationRequestAttributesDTO();
partyCreation2.setBirthdate("birthdate");
partyCreation2.setCellNo(123);
partyCreation2.setCheckletter("checkletter");
partyCreation2.setCurrency("currency");
partyCreation2.setEntname1("entname1");

// When
boolean equal = partyCreation1.equals(partyCreation2);

// Then
assertTrue(equal);
}
@Test
public void testNotEquals() {
// Given
PartyCreationRequestAttributesDTO partyCreation1 = new PartyCreationRequestAttributesDTO();
partyCreation1.setBirthdate("birthdate");
partyCreation1.setCellNo(123);
partyCreation1.setCheckletter("checkletter");
partyCreation1.setCurrency("currency");
partyCreation1.setEntname1("entname1");
PartyCreationRequestAttributesDTO partyCreation2 = new PartyCreationRequestAttributesDTO();
partyCreation2.setBirthdate("birthdate");
partyCreation2.setCellNo(123);
partyCreation2.setCheckletter("checkletter");
partyCreation2.setCurrency("currency");

// When
boolean equal = partyCreation1.equals(partyCreation2);

// Then
assertFalse(equal);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package uk.gov.ons.ctp.response.party.definition;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class PartyCreationRequestDTOTest {

@Test
public void testEquals() {
// Given
PartyCreationRequestDTO partyCreationRequest1 = new PartyCreationRequestDTO();
partyCreationRequest1.setAttributes(new PartyCreationRequestAttributesDTO());
partyCreationRequest1.setSampleSummaryId("sample summary");
partyCreationRequest1.setSampleUnitRef("unit ref");
partyCreationRequest1.setSampleUnitType("unit type");
PartyCreationRequestDTO partyCreationRequest2 = new PartyCreationRequestDTO();
partyCreationRequest2.setAttributes(new PartyCreationRequestAttributesDTO());
partyCreationRequest2.setSampleSummaryId("sample summary");
partyCreationRequest2.setSampleUnitRef("unit ref");
partyCreationRequest2.setSampleUnitType("unit type");

// When
boolean equal = partyCreationRequest1.equals(partyCreationRequest2);

// Then
assertTrue(equal);
}

@Test
public void testNotEquals() {
// Given
PartyCreationRequestDTO partyCreationRequest1 = new PartyCreationRequestDTO();
partyCreationRequest1.setAttributes(new PartyCreationRequestAttributesDTO());
partyCreationRequest1.setSampleSummaryId("sample summary");
partyCreationRequest1.setSampleUnitRef("unit ref");
partyCreationRequest1.setSampleUnitType("unit type");
PartyCreationRequestDTO partyCreationRequest2 = new PartyCreationRequestDTO();
partyCreationRequest2.setAttributes(new PartyCreationRequestAttributesDTO());
partyCreationRequest2.setSampleSummaryId("sample summary");
partyCreationRequest2.setSampleUnitRef("unit ref");

// When
boolean equal = partyCreationRequest1.equals(partyCreationRequest2);

// Then
assertFalse(equal);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package uk.gov.ons.ctp.response.party.definition;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class SampleLinkCreationRequestDTOTest {

@Test
public void testEquals() {
// Given
SampleLinkCreationRequestDTO sampleLink1 = new SampleLinkCreationRequestDTO();
sampleLink1.setCollectionExerciseId("test");
SampleLinkCreationRequestDTO sampleLink2 = new SampleLinkCreationRequestDTO();
sampleLink2.setCollectionExerciseId("test");

// When
boolean equal = sampleLink1.equals(sampleLink2);

// Then
assertTrue(equal);
}

@Test
public void testNotEquals() {
// Given
SampleLinkCreationRequestDTO sampleLink1 = new SampleLinkCreationRequestDTO();
sampleLink1.setCollectionExerciseId("test");
SampleLinkCreationRequestDTO sampleLink2 = new SampleLinkCreationRequestDTO();

// When
boolean equal = sampleLink1.equals(sampleLink2);

// Then
assertFalse(equal);
}

}