public virtual void SetNodePropertiesInUnicode() { Node jim = Data.get()["jim"]; GenConflict.get().payload(JsonHelper.createJsonFrom(MapUtil.map("name", "\u4f8b\u5b50"))).expectedStatus(204).put(GetPropertiesUri(jim)); assertThat(jim, inTx(Graphdb(), hasProperty("name").withValue("\u4f8b\u5b50"))); }
public virtual void ShouldGet200ForProperties() { string entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", "bar")); JaxRsResponse createResponse = _req.post(_functionalTestHelper.dataUri() + "node/", entity); GenConflict.get().expectedStatus(200).get(createResponse.Location.ToString() + "/properties"); }
public virtual void ProvidingBadJSON() { string jsonString = "{\"to\" : \"" + getNodeUri(Data.get()["Joe"]) + "\", \"type\" : \"LOVES\", \"data\" : {\"foo\" : **BAD JSON HERE*** \"bar\"}}"; GenConflict.get().expectedStatus(Status.BAD_REQUEST.StatusCode).payload(jsonString).post(GetNodeUri(GetNode("Joe")) + "/relationships").entity(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void drop_non_existent_constraint() public virtual void DropNonExistentConstraint() { string labelName = _labels.newInstance(); string propertyKey = _properties.newInstance(); GenConflict.get().expectedStatus(404).delete(GetSchemaConstraintLabelUniquenessPropertyUri(labelName, propertyKey)); }
public virtual void ShouldGet200WhenRetrievingNodeCompact() { string uri = _nodeUri.ToString(); ResponseEntity entity = GenConflict.get().expectedType(CompactJsonFormat.MEDIA_TYPE).expectedStatus(200).get(uri); assertTrue(entity.Entity().Contains("self")); }
public virtual void AddingAnInvalidLabelToANode() { IDictionary <string, Node> nodes = Data.get(); string nodeUri = GetNodeUri(nodes["Clint Eastwood"]); GenConflict.get().expectedStatus(400).payload(createJsonFrom("")).post(nodeUri + "/labels"); }
public virtual void getLabelUniquenessPropertyConstraints() { Data.get(); string labelName = _labels.newInstance(); string propertyKey1 = _properties.newInstance(); string propertyKey2 = _properties.newInstance(); CreateLabelUniquenessPropertyConstraint(labelName, propertyKey1); CreateLabelUniquenessPropertyConstraint(labelName, propertyKey2); string result = GenConflict.get().expectedStatus(200).get(GetSchemaConstraintLabelUniquenessUri(labelName)).entity(); IList <IDictionary <string, object> > serializedList = jsonToList(result); IDictionary <string, object> constraint1 = new Dictionary <string, object>(); constraint1["type"] = ConstraintType.UNIQUENESS.name(); constraint1["label"] = labelName; constraint1["property_keys"] = singletonList(propertyKey1); IDictionary <string, object> constraint2 = new Dictionary <string, object>(); constraint2["type"] = ConstraintType.UNIQUENESS.name(); constraint2["label"] = labelName; constraint2["property_keys"] = singletonList(propertyKey2); assertThat(serializedList, hasItems(constraint1, constraint2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void already_indexed_relationship_should_not_fail_on_create_or_fail() public virtual void AlreadyIndexedRelationshipShouldNotFailOnCreateOrFail() { // Given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String index = indexes.newInstance(); string index = _indexes.newInstance(); string key = "name"; string value = "Peter"; GraphDatabaseService graphdb = graphdb(); _helper.createRelationshipIndex(index); Relationship rel; using (Transaction tx = graphdb.BeginTx()) { Node node1 = graphdb.CreateNode(); Node node2 = graphdb.CreateNode(); rel = node1.CreateRelationshipTo(node2, MyRelationshipTypes.Knows); graphdb.Index().forRelationships(index).add(rel, key, value); tx.Success(); } // When & Then GenConflict.get().expectedStatus(201).payloadType(MediaType.APPLICATION_JSON_TYPE).payload("{\"key\": \"" + key + "\", \"value\": \"" + value + "\", \"uri\":\"" + _functionalTestHelper.relationshipUri(rel.Id) + "\"}").post(_functionalTestHelper.relationshipIndexUri() + index + "?uniqueness=create_or_fail"); }
public virtual void ExecuteMultipleOperationsInBatchStreaming() { long idJoe = Data.get()["Joe"].Id; string jsonString = (new PrettyJSON()).array().@object().key("method").value("PUT").key("to").value("/node/" + idJoe + "/properties").key("body").@object().key("age").value(1).endObject().key("id").value(0).endObject().@object().key("method").value("GET").key("to").value("/node/" + idJoe).key("id").value(1).endObject().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").value(1).endObject().key("id").value(2).endObject().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").value(1).endObject().key("id").value(3).endObject().endArray().ToString(); string entity = GenConflict.get().expectedType(APPLICATION_JSON_TYPE).withHeader(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").payload(jsonString).expectedStatus(200).post(BatchUri()).entity(); IList <IDictionary <string, object> > results = JsonHelper.jsonToList(entity); assertEquals(4, results.Count); IDictionary <string, object> putResult = results[0]; IDictionary <string, object> getResult = results[1]; IDictionary <string, object> firstPostResult = results[2]; IDictionary <string, object> secondPostResult = results[3]; // Ids should be ok assertEquals(0, putResult["id"]); assertEquals(2, firstPostResult["id"]); assertEquals(3, secondPostResult["id"]); // Should contain "from" assertEquals("/node/" + idJoe + "/properties", putResult["from"]); assertEquals("/node/" + idJoe, getResult["from"]); assertEquals("/node", firstPostResult["from"]); assertEquals("/node", secondPostResult["from"]); // Post should contain location assertTrue((( string )firstPostResult["location"]).Length > 0); assertTrue((( string )secondPostResult["location"]).Length > 0); // Should have created by the first PUT request IDictionary <string, object> body = (IDictionary <string, object>)getResult["body"]; assertEquals(1, ((IDictionary <string, object>)body["data"])["age"]); }
public virtual void ShouldReturn400WhenSendinIncompatibleJsonProperties() { IDictionary <string, object> map = new Dictionary <string, object>(); map["jim"] = new Dictionary <string, object>(); GenConflict.get().payload(JsonHelper.createJsonFrom(map)).expectedStatus(400).put(GetPropertiesUri(Data.get()["jim"])); }
public virtual void ShouldReturn204WhenPropertiesAreUpdated() { Node jim = Data.get()["jim"]; assertThat(jim, inTx(Graphdb(), not(hasProperty("age")))); GenConflict.get().payload(JsonHelper.createJsonFrom(MapUtil.map("age", "18"))).expectedStatus(204).put(GetPropertiesUri(jim)); assertThat(jim, inTx(Graphdb(), hasProperty("age").withValue("18"))); }
public virtual void CreatingALoopRelationship() { Node joe = GetNode("Joe"); string jsonString = "{\"to\" : \"" + GetNodeUri(joe) + "\", \"type\" : \"LOVES\"}"; string entity = GenConflict.get().expectedStatus(Status.CREATED.StatusCode).payload(jsonString).post(GetNodeUri(GetNode("Joe")) + "/relationships").entity(); AssertProperRelationshipRepresentation(JsonHelper.jsonToMap(entity)); }
public virtual void CreatingARelationshipToANonexistingEndNode() { string jsonString = "{\"to\" : \"" + DataUri + "node/" + "999999\", \"type\" : \"LOVES\", \"data\" : {\"foo\" : \"bar\"}}"; GenConflict.get().expectedStatus(Status.BAD_REQUEST.StatusCode).payload(jsonString).post(GetNodeUri(GetNode("Joe")) + "/relationships").entity(); }
public virtual void ShouldRespondWith404WhenStartNodeDoesNotExist() { string jsonString = "{\"to\" : \"" + DataUri + "node/" + GetNode("Joe") + "\", \"type\" : \"LOVES\", \"data\" : {\"foo\" : \"bar\"}}"; GenConflict.get().expectedStatus(Status.NOT_FOUND.StatusCode).expectedType(MediaType.TEXT_HTML_TYPE).payload(jsonString).post(DataUri + "/node/12345/relationships").entity(); }
public virtual void ShouldReturn200OnGet() { _helper.createRelationship("KNOWS"); _helper.createRelationship("LOVES"); string result = GenConflict.get().expectedStatus(200).get(_functionalTestHelper.dataUri() + "relationship/types").entity(); assertThat(result, allOf(containsString("KNOWS"), containsString("LOVES"))); }
public virtual void ShouldGet404WhenRetrievingNonExistentNode() { long nonExistentNode = _helper.createNode(); _helper.deleteNode(nonExistentNode); URI nonExistentNodeUri = new URI(_functionalTestHelper.nodeUri() + "/" + nonExistentNode); GenConflict.get().expectedStatus(404).get(nonExistentNodeUri.ToString()); }
public virtual void Assert200OkFromGet() { string body = GenConflict.get().expectedStatus(200).get(DataUri).entity(); IDictionary <string, object> map = JsonHelper.jsonToMap(body); assertEquals(DataUri + "node", map["node"]); assertNotNull(map["node_index"]); assertNotNull(map["relationship_index"]); assertNotNull(map["extensions_info"]); assertNotNull(map["batch"]); assertNotNull(map["cypher"]); assertNotNull(map["indexes"]); assertNotNull(map["constraints"]); assertNotNull(map["node_labels"]); assertEquals(Version.Neo4jVersion, map["neo4j_version"]); // Make sure advertised urls work JaxRsResponse response; if (map["reference_node"] != null) { response = RestRequest.Req().get((string)map["reference_node"]); assertEquals(200, response.Status); response.Close(); } response = RestRequest.Req().get((string)map["node_index"]); assertTrue(response.Status == 200 || response.Status == 204); response.Close(); response = RestRequest.Req().get((string)map["relationship_index"]); assertTrue(response.Status == 200 || response.Status == 204); response.Close(); response = RestRequest.Req().get((string)map["extensions_info"]); assertEquals(200, response.Status); response.Close(); response = RestRequest.Req().post((string)map["batch"], "[]"); assertEquals(200, response.Status); response.Close(); response = RestRequest.Req().post((string)map["cypher"], "{\"query\":\"CREATE (n) RETURN n\"}"); assertEquals(200, response.Status); response.Close(); response = RestRequest.Req().get((string)map["indexes"]); assertEquals(200, response.Status); response.Close(); response = RestRequest.Req().get((string)map["constraints"]); assertEquals(200, response.Status); response.Close(); response = RestRequest.Req().get((string)map["node_labels"]); assertEquals(200, response.Status); response.Close(); }
public virtual void DeleteANamedPropertyFromANode() { long nodeId = _helper.createNode(); IDictionary <string, object> map = new Dictionary <string, object>(); map["name"] = "tobias"; _helper.setNodeProperties(nodeId, map); GenConflict.get().expectedStatus(204).delete(_functionalTestHelper.nodePropertyUri(nodeId, "name")); }
public virtual void ShouldReturn204WhenAllPropertiesAreRemoved() { long nodeId = _helper.createNode(); IDictionary <string, object> map = new Dictionary <string, object>(); map["jim"] = "tobias"; _helper.setNodeProperties(nodeId, map); GenConflict.get().expectedStatus(204).delete(_functionalTestHelper.nodePropertiesUri(nodeId)); }
public virtual void AddingMultipleLabelsToANode() { IDictionary <string, Node> nodes = Data.get(); string nodeUri = GetNodeUri(nodes["Clint Eastwood"]); GenConflict.get().expectedStatus(204).payload(createJsonFrom(new string[] { "Person", "Actor" })).post(nodeUri + "/labels"); // Then assertThat(nodes["Clint Eastwood"], inTx(Graphdb(), hasLabels("Person", "Actor"))); }
/// <summary> /// Create an index for a label and property key which already exists. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void create_existing_index() public virtual void CreateExistingIndex() { string labelName = _labels.newInstance(); string propertyKey = _properties.newInstance(); CreateIndex(labelName, propertyKey); IDictionary <string, object> definition = map("property_keys", singletonList(propertyKey)); GenConflict.get().expectedStatus(409).payload(createJsonFrom(definition)).post(GetSchemaIndexLabelUri(labelName)); }
public virtual void PutRelationshipOrFailIfAbsent() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String index = indexes.newInstance(); string index = _indexes.newInstance(); string key = "name"; string value = "Peter"; _helper.createRelationshipIndex(index); GenConflict.get().expectedStatus(201).payloadType(MediaType.APPLICATION_JSON_TYPE).payload("{\"key\": \"" + key + "\", \"value\": \"" + value + "\", \"uri\":\"" + _functionalTestHelper.relationshipUri(_helper.createRelationship("KNOWS", _helper.createNode(), _helper.createNode())) + "\"}").post(_functionalTestHelper.relationshipIndexUri() + index + "?uniqueness=create_or_fail"); }
public virtual void GetDegreeByDirectionAndType() { IDictionary <string, Node> nodes = Data.get(); string nodeUri = GetNodeUri(nodes["Root"]); // Document RESTRequestGenerator.ResponseEntity response = GenConflict.get().expectedStatus(200).get(nodeUri + "/degree/out/KNOWS&LIKES"); // Then assertEquals(3, JsonHelper.jsonNode(response.Response().Entity).asInt()); }
public virtual void ReplacingLabelsOnANode() { IDictionary <string, Node> nodes = Data.get(); string nodeUri = GetNodeUri(nodes["Clint Eastwood"]); // When GenConflict.get().expectedStatus(204).payload(createJsonFrom(new string[] { "Actor", "Director" })).put(nodeUri + "/labels"); // Then assertThat(nodes["Clint Eastwood"], inTx(Graphdb(), hasLabels("Actor", "Director"))); }
public virtual void RemovingANonExistentLabelFromANode() { IDictionary <string, Node> nodes = Data.get(); Node node = nodes["Clint Eastwood"]; string nodeUri = GetNodeUri(node); string labelName = "Person"; GenConflict.get().expectedStatus(204).delete(nodeUri + "/labels/" + labelName); assertThat(node, inTx(Graphdb(), not(hasLabel(label(labelName))))); }
public virtual void ListAllPropertyKeysEverUsed() { Data.get(); string uri = PropertyKeysUri; string body = GenConflict.get().expectedStatus(200).get(uri).entity(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<?> parsed = org.neo4j.helpers.collection.Iterables.asSet((java.util.List<?>) readJson(body)); ISet <object> parsed = Iterables.asSet((IList <object>)readJson(body)); assertTrue(parsed.Contains("name")); }
public virtual void ListingNodeLabels() { IDictionary <string, Node> nodes = Data.get(); string nodeUri = GetNodeUri(nodes["Clint Eastwood"]); string body = GenConflict.get().expectedStatus(200).get(nodeUri + "/labels").entity(); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<String> labels = (java.util.List<String>) readJson(body); IList <string> labels = (IList <string>)readJson(body); assertEquals(asSet("Actor", "Director"), Iterables.asSet(labels)); }
public virtual void GetAllNodesWithLabel() { Data.get(); string uri = GetNodesWithLabelUri("Actor"); string body = GenConflict.get().expectedStatus(200).get(uri).entity(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<?> parsed = (java.util.List<?>) readJson(body); IList <object> parsed = (IList <object>)readJson(body); assertEquals(asSet("Clint Eastwood", "Donald Sutherland"), Iterables.asSet(map(GetProperty("name", typeof(string)), parsed))); }
public virtual void ShouldReturn204WhenPropertiesAreUpdated() { Data.get(); IDictionary <string, object> map = new Dictionary <string, object>(); map["jim"] = "tobias"; GenConflict.get().payload(JsonHelper.createJsonFrom(map)).expectedStatus(204).put(_propertiesUri.ToString()); JaxRsResponse response = UpdatePropertiesOnServer(map); assertEquals(204, response.Status); response.Close(); }
public virtual void CreateARelationshipWithProperties() { string jsonString = "{\"to\" : \"" + DataUri + "node/" + GetNode("Sara").Id + "\", \"type\" : \"LOVES\", \"data\" : {\"foo\" : \"bar\"}}"; Node i = GetNode("Joe"); GenConflict.get().expectedStatus(Status.CREATED.StatusCode).payload(jsonString).post(GetNodeUri(i) + "/relationships"); using (Transaction tx = Graphdb().beginTx()) { assertTrue(i.HasRelationship(RelationshipType.withName("LOVES"))); } }