import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@Override
public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+
if (o instanceof ChampObjectConstraint) {
final ChampObjectConstraint objectConstraint = (ChampObjectConstraint) o;
return false;
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(getType());
+ }
+
@Override
public String toString() {
return "{type: " + getType() +
*/
package org.onap.aai.champcore.model;
+import java.util.Objects;
import org.onap.aai.champcore.model.fluent.index.CreateObjectIndexable;
import org.onap.aai.champcore.model.fluent.index.impl.CreateObjectIndexableImpl;
return false;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getName(), getField().getName());
+ }
}
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Optional;
import org.onap.aai.champcore.model.fluent.relationship.CreateChampRelationshipable;
return false;
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(getKey());
+ }
+
@Override
public String toString() {
return "{key: " + (getKey().isPresent() ? getKey().get() : "")
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
return false;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getType(), getConnectionConstraints(), getPropertyConstraints());
+ }
}
*/
package org.onap.aai.champcore.model;
+import java.util.Objects;
import org.onap.aai.champcore.model.fluent.index.CreateRelationshipIndexable;
import org.onap.aai.champcore.model.fluent.index.impl.CreateRelationshipIndexableImpl;
return false;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getName(), getField().getName());
+ }
}
*/
package org.onap.aai.champcore.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
import org.junit.Test;
import org.onap.aai.champcore.ChampAPI;
import org.onap.aai.champcore.ChampGraph;
import org.onap.aai.champcore.exceptions.ChampIndexNotExistsException;
+import org.onap.aai.champcore.model.ChampField;
+import org.onap.aai.champcore.model.ChampField.Type;
import org.onap.aai.champcore.model.ChampObjectIndex;
+import org.onap.aai.champcore.model.ChampObjectIndex.Builder;
public class ChampObjectIndexTest extends BaseChampAPITest {
@Test
assertTrue(objectIndex.getType().equals("foo"));
assertTrue(objectIndex.getField().getName().equals("name"));
}
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods() {
+ ChampField champField1 = new ChampField.Builder("name").type(Type.STRING).build();
+ ChampField champField2 = new ChampField.Builder("differentName").type(Type.STRING).build();
+
+ ChampObjectIndex obj1 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj2 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj3 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj4 = new Builder("name", "type", champField2).build();
+ ChampObjectIndex obj5 = new Builder("differentName", "type", champField1).build();
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+
+ assertNotEquals(obj1, obj5);
+ assertNotEquals(obj1.hashCode(), obj5.hashCode());
+ }
}
*/
package org.onap.aai.champcore.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.junit.Test;
import org.onap.aai.champcore.ChampAPI;
import org.onap.aai.champcore.ChampGraph;
-import org.onap.aai.champcore.exceptions.*;
+import org.onap.aai.champcore.exceptions.ChampIndexNotExistsException;
+import org.onap.aai.champcore.exceptions.ChampMarshallingException;
+import org.onap.aai.champcore.exceptions.ChampObjectNotExistsException;
+import org.onap.aai.champcore.exceptions.ChampRelationshipNotExistsException;
+import org.onap.aai.champcore.exceptions.ChampSchemaViolationException;
+import org.onap.aai.champcore.exceptions.ChampTransactionException;
+import org.onap.aai.champcore.exceptions.ChampUnmarshallingException;
import org.onap.aai.champcore.model.ChampField;
import org.onap.aai.champcore.model.ChampRelationship;
import org.onap.aai.champcore.model.ChampRelationshipIndex;
-import java.util.Collection;
-import java.util.Optional;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.junit.Assert.assertTrue;
-
public class ChampRelationshipIndexTest extends BaseChampAPITest {
@Test
assertTrue(relationshipIndex.getType().equals("foo"));
assertTrue(relationshipIndex.getField().getName().equals("name"));
}
+
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods(){
+ ChampField champField1 = new ChampField.Builder("name").build();
+ ChampField champField2 = new ChampField.Builder("differentName").build();
+ ChampRelationshipIndex obj1 = new ChampRelationshipIndex.Builder("name","type",champField1).build();
+ ChampRelationshipIndex obj2 = new ChampRelationshipIndex.Builder("name","type",champField1).build();
+ ChampRelationshipIndex obj3 = new ChampRelationshipIndex.Builder("name","type",champField1).build();
+ ChampRelationshipIndex obj4 = new ChampRelationshipIndex.Builder("name","type",champField2).build();
+
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+ }
}
import org.onap.aai.champcore.exceptions.*;
import org.onap.aai.champcore.model.ChampObject;
import org.onap.aai.champcore.model.ChampRelationship;
+import org.onap.aai.champcore.model.ChampRelationship.Builder;
import org.onap.aai.champcore.model.ChampRelationship.ReservedPropertyKeys;
import org.onap.aai.champcore.model.ChampRelationship.ReservedTypes;
import java.util.Optional;
import java.util.stream.Collectors;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
public class ChampRelationshipTest extends BaseChampAPITest {
assertTrue(ChampRelationship.ReservedTypes.valueOf(type.name()) == type);
}
}
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods() {
+ ChampObject source = new ChampObject.Builder("type").build();
+ ChampObject target = new ChampObject.Builder("type").build();
+ ChampRelationship champRelationship = new Builder(source, target, "type").key("someKey").build();
+ ChampRelationship obj1 = new Builder(champRelationship).key("someKey").build();
+ ChampRelationship obj2 = new Builder(champRelationship).key("someKey").build();
+ ChampRelationship obj3 = new Builder(champRelationship).key("someKey").build();
+ ChampRelationship obj4 = new Builder(champRelationship).key("differentKey").build();
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+ }
public static ChampTransaction getTransaction() {
return new TestTransaction();
--- /dev/null
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2018 Nokia Intellectual Property. All rights reserved.
+ * ===================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.champcore.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.junit.Test;
+import org.onap.aai.champcore.model.ChampObjectConstraint.Builder;
+
+
+public class ChampObjectConstraintTest {
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods(){
+ ChampObjectConstraint obj1 = new Builder("type").build();
+ ChampObjectConstraint obj2 = new Builder("type").build();
+ ChampObjectConstraint obj3 = new Builder("type").build();
+ ChampObjectConstraint obj4 = new Builder("differentType").build();
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2018 Nokia Intellectual Property. All rights reserved.
+ * ===================================================================
+ * 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.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.champcore.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.HashSet;
+import org.junit.Test;
+
+
+
+public class ChampRelationshipConstraintTest {
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods(){
+ ChampRelationshipConstraint obj1 = new ChampRelationshipConstraint.Builder("type")
+ .connectionConstraints(new HashSet<>()).propertyConstraints(new HashSet<>()).build();
+ ChampRelationshipConstraint obj2 = new ChampRelationshipConstraint.Builder("type")
+ .connectionConstraints(new HashSet<>()).propertyConstraints(new HashSet<>()).build();
+ ChampRelationshipConstraint obj3 = new ChampRelationshipConstraint.Builder("type")
+ .connectionConstraints(new HashSet<>()).propertyConstraints(new HashSet<>()).build();
+ ChampRelationshipConstraint obj4 = new ChampRelationshipConstraint.Builder("differentType")
+ .connectionConstraints(new HashSet<>()).propertyConstraints(new HashSet<>()).build();
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+ }
+}
\ No newline at end of file