use of org.apache.rya.indexing.entity.model.Entity in project incubator-rya by apache.
the class MongoDbSmartUriIT method testUpdate.
@Test
public void testUpdate() throws SmartUriException {
smartUriConverter.storeEntity(BOB_ENTITY);
// New properties to add
final RyaURI hasNickName = createRyaUri("hasNickName");
final RyaURI hasWindowOffice = createRyaUri("hasWindowOffice");
final Entity.Builder builder = Entity.builder(BOB_ENTITY);
builder.setProperty(PERSON_TYPE_URI, new Property(HAS_AGE, shortRyaType((short) 41)));
builder.setProperty(PERSON_TYPE_URI, new Property(hasNickName, stringRyaType("Bobby")));
builder.setProperty(EMPLOYEE_TYPE_URI, new Property(HAS_POSITION_TITLE, stringRyaType("Assistant Regional Manager")));
builder.setProperty(EMPLOYEE_TYPE_URI, new Property(hasWindowOffice, booleanRyaType(true)));
builder.setVersion(BOB_ENTITY.getVersion() + 1);
builder.rebuildSmartUri();
final Entity newBobEntity = builder.build();
smartUriConverter.updateEntity(BOB_ENTITY, newBobEntity);
final Entity resultEntity = smartUriConverter.queryEntity(BOB_ENTITY.getSubject());
assertEquals(newBobEntity.getVersion(), resultEntity.getVersion());
assertEquals(newBobEntity.lookupTypeProperty(PERSON_TYPE, HAS_AGE), resultEntity.lookupTypeProperty(PERSON_TYPE, HAS_AGE));
assertEquals(newBobEntity.lookupTypeProperty(PERSON_TYPE, hasNickName), resultEntity.lookupTypeProperty(PERSON_TYPE, hasNickName));
assertEquals(newBobEntity.lookupTypeProperty(EMPLOYEE_TYPE, HAS_POSITION_TITLE), resultEntity.lookupTypeProperty(EMPLOYEE_TYPE, HAS_POSITION_TITLE));
assertEquals(newBobEntity.lookupTypeProperty(EMPLOYEE_TYPE, hasWindowOffice), resultEntity.lookupTypeProperty(EMPLOYEE_TYPE, hasWindowOffice));
assertEquals(newBobEntity.getSmartUri(), resultEntity.getSmartUri());
final String resultUriString = resultEntity.getSmartUri().stringValue();
assertTrue(resultUriString.contains(getRyaUriLocalName(hasWindowOffice)));
assertTrue(resultUriString.contains(getRyaUriLocalName(hasNickName)));
}
use of org.apache.rya.indexing.entity.model.Entity in project incubator-rya by apache.
the class MongoEntityIndexIT method ensureInEntityStore_Test.
@Test
public void ensureInEntityStore_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
final EntityStorage entities = indexer.getEntityStorage();
final RyaURI subject = new RyaURI("urn:alice");
final Optional<Entity> alice = entities.get(subject);
assertTrue(alice.isPresent());
} finally {
conn.close();
}
}
use of org.apache.rya.indexing.entity.model.Entity 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 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 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);
}
Aggregations