use of nl.knaw.huygens.timbuctoo.model.properties.converters.Converter in project timbuctoo by HuygensING.
the class LocalPropertyTest method saveSetsOptionsPropertyWhenTheConverterHasOptions.
@Test
public void saveSetsOptionsPropertyWhenTheConverterHasOptions() throws JsonProcessingException {
final String propertyName = "testProp";
final String clientPropName = "clientPropName";
final String[] options = { "val1", "val2" };
Converter converter = new StringArrayToEncodedArrayOfLimitedValues(options);
LocalProperty property = new LocalProperty(propertyName, converter);
Vertex result = property.save(graph, clientPropName);
assertThat(result, likeVertex().withProperty(OPTIONS_PROPERTY_NAME, new ObjectMapper().writeValueAsString(options)).withProperty(PROPERTY_TYPE_NAME, converter.getUniqueTypeIdentifier()));
}
use of nl.knaw.huygens.timbuctoo.model.properties.converters.Converter in project timbuctoo by HuygensING.
the class LocalPropertyTest method saveCreatesANewVertexWithCorrectLabelAndProperties.
@Test
public void saveCreatesANewVertexWithCorrectLabelAndProperties() {
final String propertyName = "testProp";
final String propertyType = "type";
final String clientPropName = "clientPropName";
Converter converter = mock(Converter.class);
given(converter.getUniqueTypeIdentifier()).willReturn(propertyType);
LocalProperty property = new LocalProperty(propertyName, converter);
Vertex result = property.save(graph, clientPropName);
assertThat(result, likeVertex().withLabel(DATABASE_LABEL).withProperty(DATABASE_PROPERTY_NAME, propertyName).withProperty(CLIENT_PROPERTY_NAME, clientPropName).withProperty(PROPERTY_TYPE_NAME, propertyType));
}
use of nl.knaw.huygens.timbuctoo.model.properties.converters.Converter in project timbuctoo by HuygensING.
the class PropertyTypesTest method localPropertyReturnsLocalPropertyWithCorrectPropNameAndCorrectConverter.
@Test
public void localPropertyReturnsLocalPropertyWithCorrectPropNameAndCorrectConverter() throws IOException {
Converter converter = mock(Converter.class);
JsonNode value = jsn("value");
given(converter.jsonToTinkerpop(value)).willReturn("converted-value");
LocalProperty instance = localProperty("propName", converter);
Vertex vertex = mock(Vertex.class);
VertexProperty vertexProperty = mock(VertexProperty.class);
given(vertex.property("propName")).willReturn(vertexProperty);
instance.setJson(vertex, null);
instance.setJson(vertex, value);
verify(vertex, times(1)).property("propName", "converted-value");
verify(vertexProperty, times(1)).remove();
}
Aggregations