Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6351976
Update equals and hashCode in Translator and corresponding tests
travisrieglerleidos Apr 22, 2025
4d7af86
Update equals and hashCode in TestComplexInputObject and correspondin…
travisrieglerleidos Apr 22, 2025
ad58f04
Update equals and hashCode in TestComplexAppObject and corresponding …
travisrieglerleidos Apr 22, 2025
e19d4a7
Update equals and hashcode in TestObjectWrapper and corresponding tests
travisrieglerleidos Apr 23, 2025
c3721e8
Update equals and hashcode in TestAppObject and corresponding tests
travisrieglerleidos Apr 23, 2025
a9cf750
Update equals and hashcode in TestInputObject and corresponding tests
travisrieglerleidos Apr 23, 2025
6f94b46
Update equals and hashcode in TranslationSpec and corresponding tests
travisrieglerleidos Apr 23, 2025
a7fd1b7
Remove initialized status from testEquals and testHashCode in AT_Tran…
travisrieglerleidos Apr 23, 2025
9254255
Update equals and hashCode in TaskitEngineData and corresponding tests
travisrieglerleidos Apr 23, 2025
5bd7aab
Update equals and hashCode in TaskitEngine and corresponding tests
travisrieglerleidos Apr 24, 2025
f1f490d
Removed unnecessary equals and hashCode and corresponding tests for T…
travisrieglerleidos Apr 24, 2025
aaaee5d
Move seeded random object generation from individual test classes to …
travisrieglerleidos Apr 24, 2025
e0a6460
Update TestInputObject and TestAppObject to fully use enums and updat…
travisrieglerleidos Apr 24, 2025
decfbdf
Refactor DynamicTranslationSpec into a separate enum and update corre…
travisrieglerleidos Apr 28, 2025
0489b87
Remove hashCode and equals from ProtobufTaskitEngine and update relat…
travisrieglerleidos Apr 28, 2025
0a1ccac
Remove testEquals and testHashCode from AT_ProtobufTaskitEngine
travisrieglerleidos Apr 28, 2025
c1c3a22
enum rename/slight refactor
bischoffz Apr 28, 2025
7f26b8a
Remove TestEnumTranslator/Id and move TestEnumTranslationSpec to be i…
travisrieglerleidos Apr 29, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public final <T> ITranslationSpec getTranslationSpecForClass(Class<T> classRef)
}

/**
* A hash code implementation consistent with equals().
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,29 +302,31 @@ public static Builder builder() {
return new Builder();
}

/**
* Standard implementation consistent with the {@link #equals(Object)} method.
* Note that we do not include the classToSpec map as part of the hash code
* contract, as there is never a case where it would differ from the
* translationSpec set, since both data structures get populated in the same
* addTranslationSpec() method. The data structure that matters is the list of
* translation specs, not the mapping, which only exists as a convenience map
* for translation purposes.
*/
@Override
public int hashCode() {
/*
* Note that we do not include the classToSpec map as part of the hash code
* contract, as there is never a case where it would differ from the
* translationSpec set, since both data structures get populated in the same
* addTranslationSpec() method. The data structure that matters is the list of
* translation specs, not the mapping, which only exists as a convenience map
* for translation purposes
*/
return Objects.hash(translationSpecs);
}

/**
* Two {@link TaskitEngineData} instances are equal if and only if
* their translationSpecs are equal. Note that we do not include the classToSpec
* map as part of the equals contract, as there is never a case where it would
* differ from the translationSpec set, since both data structures get populated
* in the same addTranslationSpec() method. The data structure that matters is
* the list of translation specs, not the mapping, which only exists as a
* convenience map for translation purposes.
*/
@Override
public boolean equals(Object obj) {
/*
* Note that we do not include the classToSpec map as part of the equals
* contract, as there is never a case where it would differ from the
* translationSpec set, since both data structures get populated in the same
* addTranslationSpec() method. The data structure that matters is the list of
* translation specs, not the mapping, which only exists as a convenience map
* for translation purposes
*/
if (this == obj) {
return true;
}
Expand All @@ -333,7 +335,7 @@ public boolean equals(Object obj) {
return false;
}

if (!(obj instanceof TaskitEngineData)) {
if (getClass() != obj.getClass()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,4 @@ protected <I> I readFile(File file, Class<I> inputClassRef) throws IOException {

return this.gson.fromJson(jsonObject.toString(), inputClassRef);
}

@Override
public int hashCode() {
return super.hashCode();
}

@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* Test class representing a class with various variables, including a Complex
* class.
* class, and an enum.
* <p>
* <b>Should NOT</b> be used outside of testing.
* </p>
Expand Down Expand Up @@ -97,11 +97,11 @@ public void setTestAppEnum(TestAppEnum testAppEnum) {
}

/**
* Hash code implementation consistent with equals()
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
return Objects.hash(integer, bool, string, testComplexAppObject);
return Objects.hash(integer, bool, string, testComplexAppObject, testAppEnum);
}

/**
Expand All @@ -121,6 +121,6 @@ public boolean equals(Object obj) {
}
TestAppObject other = (TestAppObject) obj;
return integer == other.integer && bool == other.bool && Objects.equals(string, other.string)
&& Objects.equals(testComplexAppObject, other.testComplexAppObject);
&& Objects.equals(testComplexAppObject, other.testComplexAppObject) && testAppEnum == other.testAppEnum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void setNumEntities(int numEntities) {
}

/**
* Hash code implentation consistent with equals().
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setNumEntities(int numEntities) {
}

/**
* Hash code implementation consistent with equals().
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gov.hhs.aspr.ms.taskit.core.testsupport.objects;

/**
* Complement enum to {@link TestAppEnum}.
* <p>
* <b>Should NOT</b> be used outside of testing.
* </p>
*/
public enum TestInputEnum {
TEST1,
TEST2
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
/**
* Complement class to {@link TestAppObject}
* <p>
* Note this class does not have an enum variable.
* </p>
* <p>
* <b>Should NOT</b> be used outside of testing.
* </p>
*/
Expand All @@ -16,6 +13,7 @@ public class TestInputObject {
private boolean bool;
private String string;
private TestComplexInputObject testComplexInputObject;
private TestInputEnum testInputEnum;

/**
* @return value of the integer variable
Expand Down Expand Up @@ -82,16 +80,32 @@ public void setTestComplexInputObject(TestComplexInputObject testComplexInputObj
}

/**
* Hash code implementation consistent with equals().
* @return the value of the enum variable
*/
public TestInputEnum getTestInputEnum() {
return this.testInputEnum;
}

/**
* Sets the value of the enum variable.
*
* @param testInputEnum the value to set
*/
public void setTestInputEnum(TestInputEnum testInputEnum) {
this.testInputEnum = testInputEnum;
}

/**
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
return Objects.hash(integer, bool, string, testComplexInputObject);
return Objects.hash(integer, bool, string, testComplexInputObject, testInputEnum);
}

/**
* Two {@link TestInputObject}s are equal if and only if their integers, bools,
* strings, and testComplexInputObjects are equal.
* strings, testComplexInputObjects, and testInputEnums are equal.
*/
@Override
public boolean equals(Object obj) {
Expand All @@ -106,7 +120,6 @@ public boolean equals(Object obj) {
}
TestInputObject other = (TestInputObject) obj;
return integer == other.integer && bool == other.bool && Objects.equals(string, other.string)
&& Objects.equals(testComplexInputObject, other.testComplexInputObject);
&& Objects.equals(testComplexInputObject, other.testComplexInputObject) && testInputEnum == other.testInputEnum;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public void setWrappedObject(Object wrappedObject) {
}

/**
* Hash code implementation consistent with equals().
* Standard implementation consistent with the {@link #equals(Object)} method
*/
@Override
public int hashCode() {
return Objects.hashCode(wrappedObject);
return Objects.hash(wrappedObject);
}

/**
Expand Down
Loading