use of org.apache.rya.indexing.entity.storage.EntityStorage.EntityAlreadyExistsException in project incubator-rya by apache.
the class MongoEntityStorageIT method can_not_create_with_same_subject.
@Test
public void can_not_create_with_same_subject() throws Exception {
// A Type that will be stored.
final Entity entity = Entity.builder().setSubject(new RyaURI("urn:GTIN-14/00012345600012")).setExplicitType(new RyaURI("urn:icecream")).setProperty(new RyaURI("urn:icecream"), new Property(new RyaURI("urn:brand"), new RyaType(XMLSchema.STRING, "Awesome Icecream"))).setProperty(new RyaURI("urn:icecream"), new Property(new RyaURI("urn:flavor"), new RyaType(XMLSchema.STRING, "Chocolate"))).build();
// Create it.
final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
storage.create(entity);
// Try to create it again. This will fail.
boolean failed = false;
try {
storage.create(entity);
} catch (final EntityAlreadyExistsException e) {
failed = true;
}
assertTrue(failed);
}
Aggregations