Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public abstract class PropertiesContainer<V> {
private final Map<String, V> properties = new HashMap<>();

public Map<String, V> getProperties() {
return properties;
return Collections.unmodifiableMap(properties);
}

public Set<String> keySet() {
return properties.keySet();
return Collections.unmodifiableSet(properties.keySet());
}

public Collection<V> values() {
return properties.values();
return Collections.unmodifiableCollection(properties.values());
}

public V get(String key) {
Expand All @@ -47,12 +47,6 @@ public void put(String key, V value) {
properties.put(key, value);
}

public void putAll(Map<String, V> map) {
if (map != null) {
properties.putAll(map);
}
}

public void remove(String key) {
properties.remove(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public VertexData deserialize(JsonParser p, DeserializationContext ctx) throws I
if (!config.isReservedField(prop.getKey())) {
VertexPropertyData pd = new VertexPropertyData(c.treeToValue(prop.getValue(), Object.class));
String key = prop.getKey();
pd.putAll(meta.get(key));
meta.getOrDefault(key, Collections.emptyMap()).forEach(pd::put);
data.put(key, pd);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.arangodb.tinkerpop.gremlin.persistence.VertexData;
import com.arangodb.tinkerpop.gremlin.persistence.VertexPropertyData;
import com.arangodb.tinkerpop.gremlin.utils.ArangoDBUtil;
import org.apache.tinkerpop.gremlin.structure.*;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
Expand Down Expand Up @@ -56,6 +57,7 @@ public <V> VertexProperty<V> property(
}

VertexPropertyData prop = new VertexPropertyData(value);
ArangoDBUtil.validateProperty(key, value, graph.config);
data.put(key, prop);
doUpdate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import static com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph.GRAPH_VARIABLES_COLLECTION;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

@SuppressWarnings("resource")
public class SimplePersistenceTest extends AbstractGremlinTest {
Expand Down Expand Up @@ -92,6 +93,45 @@ public void vertices() {
.containsEntry("meta", "metaValue");
}

@Test
@SuppressWarnings("unchecked")
public void settingKeyAsPropertyShouldFail() {
Vertex v = graph.addVertex(
T.id, "foo",
T.label, "bar"
);
Throwable thrown = catchThrowable(() -> v.property("_key", "test"));
assertThat(thrown)
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Property key can not be a reserved key");
}

@Test
@SuppressWarnings("unchecked")
public void settingIdAsPropertyShouldFail() {
Vertex v = graph.addVertex(
T.id, "foo",
T.label, "bar"
);
Throwable thrown = catchThrowable(() -> v.property("_id", "test"));
assertThat(thrown)
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Property key can not be a reserved key");
}

@Test
@SuppressWarnings("unchecked")
public void settingLabelAsPropertyShouldFail() {
Vertex v = graph.addVertex(
T.id, "foo",
T.label, "bar"
);
Throwable thrown = catchThrowable(() -> v.property("type", "test"));
assertThat(thrown)
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Property key can not be a reserved key");
}

@Test
@SuppressWarnings("unchecked")
public void edges() {
Expand Down