Skip to content
Snippets Groups Projects
Commit ccc850e0 authored by buczekp's avatar buczekp
Browse files

[LMS-1894] fixed tests (implemented missing equals and hashCodes)

SVN: 18993
parent 0ce2049e
No related branches found
No related tags found
No related merge requests found
......@@ -140,4 +140,42 @@ public class Project extends CodeWithRegistration<Project> implements IAttachmen
return identifier;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (!(obj instanceof Project))
{
return false;
}
Project other = (Project) obj;
if (identifier == null)
{
if (other.identifier != null)
{
return false;
}
} else if (!identifier.equals(other.identifier))
{
return false;
}
return true;
}
}
......@@ -16,7 +16,6 @@
package ch.systemsx.cisd.openbis.generic.shared.basic.dto;
/**
* Controlled vocabulary.
*
......@@ -102,4 +101,53 @@ public class Vocabulary extends CodeWithRegistration<Vocabulary> implements IVoc
this.urlTemplate = urlTemplate;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (!(obj instanceof Vocabulary))
{
return false;
}
Vocabulary other = (Vocabulary) obj;
if (getCode() == null)
{
if (other.getCode() != null)
{
return false;
}
} else if (!getCode().equals(other.getCode()))
{
return false;
}
if (id == null)
{
if (other.id != null)
{
return false;
}
} else if (!id.equals(other.id))
{
return false;
}
return true;
}
}
......@@ -252,7 +252,11 @@ public final class CommonClientServiceTest extends AbstractClientServiceTest
@Test
public final void testListProjects()
{
List<Project> entities = Arrays.asList(new Project());
final Project project1 = new Project();
project1.setIdentifier("p1");
final Project project2 = new Project();
project1.setIdentifier("p2");
List<Project> entities = Arrays.asList(project1, project2);
final DefaultResultSetConfig<String, Project> criteria =
DefaultResultSetConfig.createFetchAll();
prepareListEntities(entities, criteria);
......@@ -313,7 +317,11 @@ public final class CommonClientServiceTest extends AbstractClientServiceTest
private <T> void assertEqualEntities(List<T> entities, final ResultSet<T> resultSet)
{
assertEquals(entities.size(), resultSet.getList().size());
assertEquals(entities.get(0), resultSet.getList().get(0).getOriginalObject());
GridRowModels<T> resultSetList = resultSet.getList();
for (int i = 0; i < entities.size(); i++)
{
assertEquals(entities.get(i), resultSetList.get(i).getOriginalObject());
}
assertEquals(entities.size(), resultSet.getTotalLength());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment