use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class ChangeListenerTest method callsOnPropertyUpdateOnReplaceEntity.
@Test
public void callsOnPropertyUpdateOnReplaceEntity() throws Exception {
ChangeListener changeListener = new ChangeListenerImpl(vertex -> {
assertThat(vertex, likeVertex().withProperty("isLatest", true).withProperty("rev", 2));
Long prevVersions = stream(vertex.vertices(Direction.BOTH, VERSION_OF)).collect(Collectors.counting());
assertThat(prevVersions, is(1L));
});
UUID id = UUID.randomUUID();
ChangeListener spy = spy(changeListener);
DataStoreOperations instance = forReplaceCall(spy, id, 1);
UpdateEntity updateEntity = new UpdateEntity(id, newArrayList(), 1);
updateEntity.setModified(new Change());
Collection collectionMock = mock(Collection.class);
instance.replaceEntity(collectionMock, updateEntity);
verify(spy).onPropertyUpdate(same(collectionMock), any(), any());
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class FulltextIndexChangeListenerTest method onCreateHandlesWwDocumentsUsingCustomLogic.
@Test
public void onCreateHandlesWwDocumentsUsingCustomLogic() {
IndexHandler indexHandler = mock(IndexHandler.class);
GraphWrapper graphWrapper = newGraph().withVertex("doc", v -> v.withProperty("wwdocument_name", "foo").withOutgoingRelation("isCreatedBy", "authorA", r -> r.withAccepted("wwrelation", true).withIsLatest(true)).withOutgoingRelation("isCreatedBy", "authorB", r -> r.withAccepted("wwrelation", true).withIsLatest(true))).withVertex("authorA", v -> v.withProperty("wwperson_name", "authorA")).withVertex("authorB", v -> v.withProperty("wwperson_name", "authorB")).wrap();
FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper);
Collection collection = new VresBuilder().withVre("womenwriters", "ww", vre -> vre.withCollection("wwdocuments", coll -> coll.withDisplayName(localProperty("wwdocument_name"))).withCollection("wwpersons", coll -> coll.withDisplayName(localProperty("wwperson_name")))).build().getCollection("wwdocuments").get();
Vertex vertex = graphWrapper.getGraph().traversal().V().next();
instance.onCreate(collection, vertex);
verify(indexHandler).upsertIntoQuickSearchIndex(collection, "authorA; authorB foo", vertex, null);
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class TinkerPopPropertyConverterTest method fromThrowsAnUnknownPropertyExceptionWhenThePropertyDoesNotExistInTheCollection.
@Test(expected = UnknownPropertyException.class)
public void fromThrowsAnUnknownPropertyExceptionWhenThePropertyDoesNotExistInTheCollection() throws UnknownPropertyException, IOException {
Collection collection = mock(Collection.class);
when(collection.getProperty(PROPERTY_NAME)).thenReturn(Optional.empty());
TinkerPopPropertyConverter instance = new TinkerPopPropertyConverter(collection);
instance.from(PROPERTY_NAME, STRING_VALUE);
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class TinkerPopPropertyConverterTest method fromReturnsADatablePropertyWithADecodedStringValue.
// Datable tests
@Test
public void fromReturnsADatablePropertyWithADecodedStringValue() throws Exception {
Collection collection = mock(Collection.class);
ReadableProperty readableProperty = mock(ReadableProperty.class);
when(readableProperty.getUniqueTypeId()).thenReturn("datable");
when(collection.getProperty(PROPERTY_NAME)).thenReturn(Optional.of(readableProperty));
TinkerPopPropertyConverter instance = new TinkerPopPropertyConverter(collection);
TimProperty<?> from = instance.from(PROPERTY_NAME, "\"1800\"");
assertThat(from.getValue(), is("1800"));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class JsonCrudService method createEntity.
private UUID createEntity(Collection collection, ObjectNode input, User user) throws IOException, PermissionFetchingException {
List<TimProperty<?>> timProperties = jsonToEntityMapper.getDataProperties(collection, input);
Optional<Collection> baseCollection = mappings.getCollectionForType(collection.getAbstractType());
UUID id = timDbAccess.createEntity(collection, baseCollection, timProperties, user);
return id;
}
Aggregations