Skip to content
Snippets Groups Projects
Commit a4dadf97 authored by cramakri's avatar cramakri
Browse files

LMS-1510 Fixed problems with the implementation of equals in PlateIdentifier.

SVN: 15962
parent 1a4506a3
No related branches found
No related tags found
No related merge requests found
......@@ -48,11 +48,11 @@ public class PlateIdentifier implements Serializable
@Override
public boolean equals(Object obj)
{
if (obj == null || obj instanceof Plate == false)
if (obj == null || obj instanceof PlateIdentifier == false)
{
return false;
}
Plate that = (Plate) obj;
PlateIdentifier that = (PlateIdentifier) obj;
return plateCode.equals(that.getPlateCode())
&& ((spaceCodeOrNull != null && spaceCodeOrNull.equals(that.tryGetSpaceCode())) || (spaceCodeOrNull == null && that
.tryGetSpaceCode() == null));
......
/*
* Copyright 2010 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
/**
* @author Chandrasekhar Ramakrishnan
*/
public class PlateIdentifierTest extends AssertJUnit
{
@Test
public void testEqualityWithNonNullSpaceCode()
{
PlateIdentifier plateId1 = new PlateIdentifier("abcd", "MySpace");
PlateIdentifier plateId2 = new PlateIdentifier("abcd", "MySpace");
assertEquals(plateId1, plateId2);
assertEquals(plateId1.hashCode(), plateId2.hashCode());
}
@Test
public void testEqualityWithNullSpaceCode()
{
PlateIdentifier plateId1 = new PlateIdentifier("28948045-348", null);
PlateIdentifier plateId2 = new PlateIdentifier("28948045-348", null);
assertEquals(plateId1, plateId2);
assertEquals(plateId1.hashCode(), plateId2.hashCode());
}
}
/*
* Copyright 2010 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
/**
* @author Chandrasekhar Ramakrishnan
*/
public class PlateImageReferenceTest extends AssertJUnit
{
@Test
public void testEquality()
{
PlateImageReference plate1 = new PlateImageReference(1, 2, 3, 4, getDatasetIdentifier());
PlateImageReference plate2 = new PlateImageReference(1, 2, 3, 4, getDatasetIdentifier());
assertEquals(plate1, plate2);
assertEquals(plate1.hashCode(), plate2.hashCode());
}
private IDatasetIdentifier getDatasetIdentifier()
{
return new IDatasetIdentifier()
{
public String getDatasetCode()
{
return "9834598723-9834";
}
public String getDatastoreServerUrl()
{
return "http://localhost:8888";
}
};
}
}
/*
* Copyright 2010 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
/**
* @author Chandrasekhar Ramakrishnan
*/
public class WellPositionTest extends AssertJUnit
{
@Test
public void testEquality()
{
WellPosition pos1 = new WellPosition(9, 4);
WellPosition pos2 = new WellPosition(9, 4);
assertEquals(pos1, pos2);
assertEquals(pos1.hashCode(), pos2.hashCode());
}
}
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