@Test public void testFetchHintsProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n2", "value2", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n3", "value3", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); FetchHints specificPropertiesFetchHints = FetchHints.builder() .setPropertyNamesToInclude("n1", "n3") .build(); Vertex v1WithoutN2 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1WithoutN2.getPropertyValue("n1")); assertThrowsException(() -> v1WithoutN2.getProperty("n1").getMetadata()); assertThrowsException(() -> v1WithoutN2.getPropertyValue("n2")); assertEquals("value3", v1WithoutN2.getPropertyValue("n3")); FetchHints noPropertiesFetchHints = FetchHints.NONE; Vertex v1WithNotProperties = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithNotProperties::getProperties); assertThrowsException(() -> v1WithNotProperties.getProperty("n1")); FetchHints allPropertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setPropertyNamesToInclude("n1", "n3") .build(); v1 = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1.getPropertyValue("n1")); assertEquals("value2", v1.getPropertyValue("n2")); assertEquals("value3", v1.getPropertyValue("n3")); }
@Test public void testFetchHintsProperties() { Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n1", "value1", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n2", "value2", VISIBILITY_A, AUTHORIZATIONS_A); v1.addPropertyValue("k1", "n3", "value3", VISIBILITY_A, AUTHORIZATIONS_A); graph.flush(); FetchHints specificPropertiesFetchHints = FetchHints.builder() .setPropertyNamesToInclude("n1", "n3") .build(); Vertex v1WithoutN2 = graph.getVertex("v1", specificPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1WithoutN2.getPropertyValue("n1")); assertThrowsException(() -> v1WithoutN2.getProperty("n1").getMetadata()); assertThrowsException(() -> v1WithoutN2.getPropertyValue("n2")); assertEquals("value3", v1WithoutN2.getPropertyValue("n3")); FetchHints noPropertiesFetchHints = FetchHints.NONE; Vertex v1WithNotProperties = graph.getVertex("v1", noPropertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithNotProperties::getProperties); assertThrowsException(() -> v1WithNotProperties.getProperty("n1")); FetchHints allPropertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setPropertyNamesToInclude("n1", "n3") .build(); v1 = graph.getVertex("v1", allPropertiesFetchHints, AUTHORIZATIONS_A); assertEquals("value1", v1.getPropertyValue("n1")); assertEquals("value2", v1.getPropertyValue("n2")); assertEquals("value3", v1.getPropertyValue("n3")); }
.setPropertyNamesToInclude("propBmeta") .build(); Vertex vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); .setPropertyNamesToInclude("propBmeta") .build(); vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A);
.setPropertyNamesToInclude("propBmeta") .build(); Vertex vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A); .setPropertyNamesToInclude("propBmeta") .build(); vertex = graph.getVertex("v1", fetchHints, AUTHORIZATIONS_A);
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }
@Test public void testFetchHintsExceptions() { Metadata prop1Metadata = Metadata.create(); prop1Metadata.add("metadata1", "metadata1Value", VISIBILITY_A); prop1Metadata.add("metadata2", "metadata2Value", VISIBILITY_A); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("prop1", "value1", prop1Metadata, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); FetchHints propertyFetchHints = FetchHints.builder() .setPropertyNamesToInclude("prop2") .build(); Vertex v1WithOnlyProp2 = graph.getVertex("v1", propertyFetchHints, AUTHORIZATIONS_A); assertNotNull(v1WithOnlyProp2.getProperties()); assertThrowsException(() -> v1WithOnlyProp2.getProperty("prop1")); FetchHints propertiesFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .build(); Vertex v1WithAllProperties = graph.getVertex("v1", propertiesFetchHints, AUTHORIZATIONS_A); assertThrowsException(v1WithAllProperties.getProperty("prop1")::getMetadata); FetchHints metadataFetchHints = FetchHints.builder() .setIncludeAllProperties(true) .setMetadataKeysToInclude("metadata1") .build(); Vertex v1WithOnlyMetadata1 = graph.getVertex("v1", metadataFetchHints, AUTHORIZATIONS_A); Property prop1 = v1WithOnlyMetadata1.getProperty("prop1"); assertNotNull(prop1.getMetadata()); assertNotNull(v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata1")); assertThrowsException(() -> v1WithOnlyMetadata1.getProperty("prop1").getMetadata().getEntry("metadata2")); }