@@ -160,3 +160,31 @@ def test_generate_hash_code_invalid_name():
160160 attr = Field (name = name , type = "String" )
161161 with pytest .raises (ValueError ):
162162 generate_hash_code ([attr ])
163+
164+
165+ def test_generate_equals ():
166+ class_name = "MyClass"
167+ attr1 = field_exampleAttribute_int
168+ attr2 = field_someName_String
169+ attr3 = field_customData_CustomObject
170+ attributes = [attr1 , attr2 , attr3 ]
171+ expected = """
172+ @Override
173+ public boolean equals(Object obj) {
174+ if (this == obj)
175+ return true;
176+ if (!(obj instanceof MyClass))
177+ return false;
178+ MyClass that = (MyClass) obj;
179+ return Objects.equals(getExampleAttribute(), that.getExampleAttribute())
180+ && Objects.equals(getSomeName(), that.getSomeName())
181+ && Objects.equals(getCustomData(), that.getCustomData());
182+ }"""
183+ assert generate_equals (class_name , attributes ) == expected
184+
185+
186+ def test_generate_hash_code_invalid_name ():
187+ for name in illegal_names :
188+ attr = Field (name = name , type = "String" )
189+ with pytest .raises (ValueError ):
190+ generate_equals ("MyClass" , [attr ])
0 commit comments