use of org.apache.rya.indexing.entity.model.Entity.Builder in project incubator-rya by apache.
the class DuplicateDataDetectorIT method testCompareSmartUris.
@Test
public void testCompareSmartUris() throws SmartUriException, ConfigurationException {
final Entity entity1 = createBobEntity();
final Entity entity2 = new Builder(entity1).build();
final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector();
final boolean areDuplicates = duplicateDataDetector.compareSmartUris(entity1.getSmartUri(), entity2.getSmartUri());
assertTrue(areDuplicates);
}
use of org.apache.rya.indexing.entity.model.Entity.Builder in project incubator-rya by apache.
the class DuplicateDataDetectorIT method testCompareEntities.
@Test
public void testCompareEntities() throws SmartUriException, ConfigurationException {
final Entity entity1 = createBobEntity();
final Entity entity2 = new Builder(entity1).build();
final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector();
final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2);
assertTrue(areDuplicates);
}
use of org.apache.rya.indexing.entity.model.Entity.Builder in project incubator-rya by apache.
the class DuplicateDataDetectorIT method testEntityMissingType.
@Test
public void testEntityMissingType() throws SmartUriException, ConfigurationException {
final Entity entity1 = createBobEntity();
final Builder builder = new Builder(entity1);
builder.setExplicitType(new RyaURI("urn:example/manager"));
final Entity entity2 = builder.build();
final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector();
final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2);
assertFalse(areDuplicates);
}
use of org.apache.rya.indexing.entity.model.Entity.Builder in project incubator-rya by apache.
the class DuplicateDataDetectorIT method testProperty.
/**
* Creates two entities to test where one property is different from the
* other. Multiple different values for the property are provided by
* {@code testInputs}.
* @param testInputs the {@link List} of {@link TestInput} to insert into
* the property.
* @param typeIdUri the type ID {@link RyaURI} that the property falls
* under. (not {@code null})
* @param propertyNameUri the property name {@link RyaURI}.
* (not {@code null})
* @param equivalentTermsMap the {@link Map} of terms that are considered
* equivalent to each other.
* @throws SmartUriException
*/
private static void testProperty(final List<TestInput> testInputs, final RyaURI typeIdUri, final RyaURI propertyNameUri, final Map<String, List<String>> equivalentTermsMap) throws SmartUriException {
requireNonNull(typeIdUri);
requireNonNull(propertyNameUri);
final Entity entity1 = createBobEntity();
int count = 0;
for (final TestInput testInput : testInputs) {
System.out.println("Test #" + count + ": " + testInput.toString());
final Object testValue = testInput.getValue();
final Tolerance tolerance = testInput.getTolerance();
final boolean expected = testInput.getExpected();
final Builder builder = new Builder(entity1);
final RyaType ryaType = RyaTypeUtils.getRyaTypeForClass(testValue.getClass(), testValue);
builder.setProperty(typeIdUri, new Property(propertyNameUri, ryaType));
final Entity entity2 = builder.build();
final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector(tolerance, equivalentTermsMap);
final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2);
final String originalValue = entity1.lookupTypeProperty(typeIdUri, propertyNameUri).get().getValue().getData();
final String message = createErrorMessage(originalValue, testValue, expected, areDuplicates, tolerance);
assertEquals(message, expected, areDuplicates);
count++;
}
}
use of org.apache.rya.indexing.entity.model.Entity.Builder in project incubator-rya by apache.
the class DuplicateDataDetectorIT method testEntitySubjectsDifferent.
@Test
public void testEntitySubjectsDifferent() throws SmartUriException, ConfigurationException {
final Entity entity1 = createBobEntity();
final Builder builder = new Builder(entity1);
builder.setSubject(createRyaUri("Susan"));
final Entity entity2 = builder.build();
final DuplicateDataDetector duplicateDataDetector = new DuplicateDataDetector();
final boolean areDuplicates = duplicateDataDetector.compareEntities(entity1, entity2);
assertTrue(areDuplicates);
}
Aggregations