Search in sources :

Example 1 with Builder

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);
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) Builder(org.apache.rya.indexing.entity.model.Entity.Builder) Test(org.junit.Test)

Example 2 with Builder

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);
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) Builder(org.apache.rya.indexing.entity.model.Entity.Builder) Test(org.junit.Test)

Example 3 with Builder

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);
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) RyaURI(org.apache.rya.api.domain.RyaURI) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) Builder(org.apache.rya.indexing.entity.model.Entity.Builder) Test(org.junit.Test)

Example 4 with Builder

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++;
    }
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) Builder(org.apache.rya.indexing.entity.model.Entity.Builder) RyaType(org.apache.rya.api.domain.RyaType) RyaTypeUtils.shortRyaType(org.apache.rya.api.domain.RyaTypeUtils.shortRyaType) RyaTypeUtils.floatRyaType(org.apache.rya.api.domain.RyaTypeUtils.floatRyaType) RyaTypeUtils.uriRyaType(org.apache.rya.api.domain.RyaTypeUtils.uriRyaType) RyaTypeUtils.longRyaType(org.apache.rya.api.domain.RyaTypeUtils.longRyaType) RyaTypeUtils.stringRyaType(org.apache.rya.api.domain.RyaTypeUtils.stringRyaType) RyaTypeUtils.doubleRyaType(org.apache.rya.api.domain.RyaTypeUtils.doubleRyaType) RyaTypeUtils.byteRyaType(org.apache.rya.api.domain.RyaTypeUtils.byteRyaType) RyaTypeUtils.booleanRyaType(org.apache.rya.api.domain.RyaTypeUtils.booleanRyaType) RyaTypeUtils.dateRyaType(org.apache.rya.api.domain.RyaTypeUtils.dateRyaType) RyaTypeUtils.intRyaType(org.apache.rya.api.domain.RyaTypeUtils.intRyaType) Property(org.apache.rya.indexing.entity.model.Property)

Example 5 with Builder

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);
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) ReflectionToStringBuilder(org.apache.commons.lang.builder.ReflectionToStringBuilder) Builder(org.apache.rya.indexing.entity.model.Entity.Builder) Test(org.junit.Test)

Aggregations

ReflectionToStringBuilder (org.apache.commons.lang.builder.ReflectionToStringBuilder)8 Entity (org.apache.rya.indexing.entity.model.Entity)8 Builder (org.apache.rya.indexing.entity.model.Entity.Builder)8 Test (org.junit.Test)7 RyaType (org.apache.rya.api.domain.RyaType)3 RyaTypeUtils.booleanRyaType (org.apache.rya.api.domain.RyaTypeUtils.booleanRyaType)3 RyaTypeUtils.byteRyaType (org.apache.rya.api.domain.RyaTypeUtils.byteRyaType)3 RyaTypeUtils.dateRyaType (org.apache.rya.api.domain.RyaTypeUtils.dateRyaType)3 RyaTypeUtils.doubleRyaType (org.apache.rya.api.domain.RyaTypeUtils.doubleRyaType)3 RyaTypeUtils.floatRyaType (org.apache.rya.api.domain.RyaTypeUtils.floatRyaType)3 RyaTypeUtils.intRyaType (org.apache.rya.api.domain.RyaTypeUtils.intRyaType)3 RyaTypeUtils.longRyaType (org.apache.rya.api.domain.RyaTypeUtils.longRyaType)3 RyaTypeUtils.shortRyaType (org.apache.rya.api.domain.RyaTypeUtils.shortRyaType)3 RyaTypeUtils.stringRyaType (org.apache.rya.api.domain.RyaTypeUtils.stringRyaType)3 RyaTypeUtils.uriRyaType (org.apache.rya.api.domain.RyaTypeUtils.uriRyaType)3 Property (org.apache.rya.indexing.entity.model.Property)3 ImmutableList (com.google.common.collect.ImmutableList)2 Date (java.util.Date)2 List (java.util.List)2 Type (org.apache.rya.indexing.entity.model.Type)2