Search in sources :

Example 6 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class RelationshipIT method shouldReturn204WhenPropertiesAreRemovedFromRelationship.

@Test
@Title("Remove properties from a relationship")
@Graph(nodes = { @NODE(name = "Romeo", setNameProperty = true), @NODE(name = "Juliet", setNameProperty = true) }, relationships = { @REL(start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP(key = "cost", value = "high", type = GraphDescription.PropType.STRING) }) })
public void shouldReturn204WhenPropertiesAreRemovedFromRelationship() {
    Relationship loves = getFirstRelationshipFromRomeoNode();
    gen().expectedStatus(Status.NO_CONTENT.getStatusCode()).delete(functionalTestHelper.relationshipPropertiesUri(loves.getId())).entity();
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Graph(org.neo4j.test.GraphDescription.Graph) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 7 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class RelationshipIT method shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipStreaming.

@Test
@Graph(nodes = { @NODE(name = "Romeo", setNameProperty = true), @NODE(name = "Juliet", setNameProperty = true) }, relationships = { @REL(start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP(key = "cost", value = "high", type = GraphDescription.PropType.STRING) }) })
public void shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipStreaming() {
    data.get();
    Relationship loves = getFirstRelationshipFromRomeoNode();
    gen().withHeader(StreamingFormat.STREAM_HEADER, "true").expectedStatus(Status.NOT_FOUND.getStatusCode()).delete(getPropertiesUri(loves) + "/non-existent").entity();
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Graph(org.neo4j.test.GraphDescription.Graph) Test(org.junit.Test)

Example 8 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class RelationshipIT method set_all_properties_on_a_relationship.

@Test
@Graph(nodes = { @NODE(name = "Romeo", setNameProperty = true), @NODE(name = "Juliet", setNameProperty = true) }, relationships = { @REL(start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP(key = "cost", value = "high", type = GraphDescription.PropType.STRING), @PROP(key = "since", value = "1day", type = GraphDescription.PropType.STRING) }) })
public void set_all_properties_on_a_relationship() throws Exception {
    Relationship loves = getFirstRelationshipFromRomeoNode();
    assertThat(loves, inTx(graphdb(), hasProperty("cost").withValue("high")));
    gen().expectedStatus(ClientResponse.Status.NO_CONTENT).payload(JsonHelper.createJsonFrom(MapUtil.map("happy", false))).put(getRelPropsURI(loves)).entity();
    assertThat(loves, inTx(graphdb(), hasProperty("happy").withValue(false)));
    assertThat(loves, inTx(graphdb(), not(hasProperty("cost"))));
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Graph(org.neo4j.test.GraphDescription.Graph) Test(org.junit.Test)

Example 9 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class SetNodePropertiesIT method shouldReturn204WhenPropertyIsSet.

@Documented("Set property on node.\n" + "\n" + "Setting different properties will retain the existing ones for this node.\n" + "Note that a single value are submitted not as a map but just as a value\n" + "(which is valid JSON) like in the example\n" + "below.")
@Graph(nodes = { @NODE(name = "jim", properties = { @PROP(key = "foo2", value = "bar2") }) })
@Test
public void shouldReturn204WhenPropertyIsSet() throws Exception {
    Node jim = data.get().get("jim");
    gen.get().payload(JsonHelper.createJsonFrom("bar")).expectedStatus(204).put(getPropertyUri(jim, "foo").toString());
    assertThat(jim, inTx(graphdb(), hasProperty("foo")));
    assertThat(jim, inTx(graphdb(), hasProperty("foo2")));
}
Also used : Node(org.neo4j.graphdb.Node) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Example 10 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class SetNodePropertiesIT method shouldReturn204WhenPropertiesAreUpdated.

@Graph("jim knows joe")
@Documented("Update node properties.\n" + "\n" + "This will replace all existing properties on the node with the new set\n" + "of attributes.")
@Test
public void shouldReturn204WhenPropertiesAreUpdated() throws JsonParseException {
    Node jim = data.get().get("jim");
    assertThat(jim, inTx(graphdb(), not(hasProperty("age"))));
    gen.get().payload(JsonHelper.createJsonFrom(MapUtil.map("age", "18"))).expectedStatus(204).put(getPropertiesUri(jim));
    assertThat(jim, inTx(graphdb(), hasProperty("age").withValue("18")));
}
Also used : Node(org.neo4j.graphdb.Node) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test)

Aggregations

Graph (org.neo4j.test.GraphDescription.Graph)48 Test (org.junit.Test)47 Documented (org.neo4j.kernel.impl.annotations.Documented)21 Title (org.neo4j.test.TestData.Title)18 Node (org.neo4j.graphdb.Node)17 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)16 Transaction (org.neo4j.graphdb.Transaction)13 Relationship (org.neo4j.graphdb.Relationship)11 Map (java.util.Map)7 ArrayList (java.util.ArrayList)3 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)3 HashSet (java.util.HashSet)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 PrettyJSON (org.neo4j.server.rest.PrettyJSON)2 JsonHelper.jsonToMap (org.neo4j.server.rest.domain.JsonHelper.jsonToMap)2 Collection (java.util.Collection)1 List (java.util.List)1 JsonNode (org.codehaus.jackson.JsonNode)1 PathExpander (org.neo4j.graphdb.PathExpander)1