File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,7 +193,23 @@ def test_generate_equals():
193193 assert generate_equals (class_name , attributes ) == expected
194194
195195
196- def test_generate_hash_code_invalid_name ():
196+ def test_generate_equals_one_field ():
197+ class_name = "AnotherClass"
198+ attr = field_someName_String
199+ expected = """
200+ @Override
201+ public boolean equals(Object obj) {
202+ if (this == obj)
203+ return true;
204+ if (!(obj instanceof AnotherClass))
205+ return false;
206+ AnotherClass that = (AnotherClass) obj;
207+ return Objects.equals(getSomeName(), that.getSomeName());
208+ }"""
209+ assert generate_equals (class_name , [attr ]) == expected
210+
211+
212+ def test_generate_equals_invalid_name ():
197213 for name in illegal_names :
198214 attr = Field (name = name , type = "String" )
199215 with pytest .raises (ValueError ):
You can’t perform that action at this time.
0 commit comments