@Test public void shouldReturnFalseForEqualsWhenPropertyIsDifferent() { // Given final Entity entity1 = new Entity("group"); entity1.setVertex("identifier"); entity1.putProperty("some property", "some value"); final Entity entity2 = cloneCoreFields(entity1); entity2.putProperty("some property", "some other value"); // When boolean isEqual = entity1.equals((Object) entity2); // Then assertFalse(isEqual); assertNotEquals(entity1.hashCode(), entity2.hashCode()); }
@Override @Test public void shouldReturnTrueForEqualsWhenAllCoreFieldsAreEqual() { // Given final Entity entity1 = new Entity("group"); entity1.setVertex("identifier"); entity1.putProperty("some property", "some value"); final Entity entity2 = cloneCoreFields(entity1); entity2.putProperty("some property", "some value"); // When boolean isEqual = entity1.equals((Object) entity2); // Then assertTrue(isEqual); assertEquals(entity1.hashCode(), entity2.hashCode()); }
@Test public void shouldConstructEntity() { // Given final String vertex = "vertex1"; final String propValue = "propValue"; // When final Entity entity = new Entity(TestGroups.ENTITY, vertex); entity.putProperty(TestPropertyNames.STRING, propValue); // Then assertEquals(TestGroups.ENTITY, entity.getGroup()); assertEquals(vertex, entity.getVertex()); assertEquals(propValue, entity.getProperty(TestPropertyNames.STRING)); }
@Override public Element getElement(final Review review) { final Entity entity = new Entity(Group.REVIEW, review.getFilmId()); entity.putProperty(Property.USER_ID, review.getUserId()); entity.putProperty(Property.RATING, (long) review.getRating()); entity.putProperty(Property.COUNT, 1); return entity; }
@Override public Element getElement(final Film film) { final Entity entity = new Entity(Group.FILM, film.getFilmId()); entity.putProperty(Property.NAME, film.getName()); entity.putProperty(Property.CERTIFICATE, film.getCertificate()); return entity; }
@Override public Element getElement(final Person person) { final Entity entity = new Entity(Group.PERSON, person.getUserId()); entity.putProperty(Property.NAME, person.getName()); entity.putProperty(Property.AGE, person.getAge()); return entity; }
if (includeEntities) { final Entity sourceEntity = new Entity("entityGroup", source); sourceEntity.putProperty("count", 1L); final HyperLogLogPlus sourceHLLPP = new HyperLogLogPlus(5, 5); sourceHLLPP.offer(destination); sourceEntity.putProperty("approxDegree", sourceHLLPP); results.add(sourceEntity); final Entity destinationEntity = new Entity("entityGroup", destination); destinationEntity.putProperty("count", 1L); final HyperLogLogPlus destinationHLLPP = new HyperLogLogPlus(5, 5); destinationHLLPP.offer(destination); destinationEntity.putProperty("approxDegree", destinationHLLPP); results.add(destinationEntity);