Skip to content

Commit

Permalink
Implement SonarCloud quality suggestions #159
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 8, 2023
1 parent ecdedc1 commit 4669d9b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/main/java/de/gwdg/metadataqa/api/model/XmlFieldInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof XmlFieldInstance))
if (!(obj instanceof XmlFieldInstance))
return false;

if (this == obj)
return true;

final XmlFieldInstance other = (XmlFieldInstance) obj;
if ( !Objects.equals(this.value, other.value)
|| !Objects.equals(this.language, other.language)) {
return false;
}

return true;
return Objects.equals(this.value, other.value)
&& Objects.equals(this.language, other.language);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@

public class XmlFieldInstanceTest extends TestCase {

@Test
public void test_isEmpty_1() {
XmlFieldInstance x = new XmlFieldInstance("test");
assertFalse(x.isEmpty());
}

@Test
public void test_isEmpty_2() {
XmlFieldInstance x = new XmlFieldInstance(null, "en");
assertFalse(x.isEmpty());
}

@Test
public void test_isEmpty_3() {
XmlFieldInstance x = new XmlFieldInstance(null);
assertTrue(x.isEmpty());
}

@Test
public void test_isEmpty_4() {
XmlFieldInstance x = new XmlFieldInstance(null, null);
assertTrue(x.isEmpty());
}

@Test
public void testToString_noLang() {
XmlFieldInstance x = new XmlFieldInstance("test");
Expand Down Expand Up @@ -60,4 +84,19 @@ public void testEquals_4() {
assertFalse(a.equals(b));
assertFalse(b.equals(a));
}

@Test
public void testEquals_5() {
XmlFieldInstance a = new XmlFieldInstance("test");
assertTrue(a.equals(a));
assertTrue(a.equals(a));
}

@Test
public void testEquals_6() {
XmlFieldInstance a = new XmlFieldInstance("test");
String b = "test";
assertFalse(a.equals(b));
assertFalse(b.equals(a));
}
}

0 comments on commit 4669d9b

Please sign in to comment.