//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatListOfStrings() public virtual void CanFormatListOfStrings() { string entity = _json.assemble(ListRepresentation.strings("hello", "world")); string expectedString = JsonHelper.createJsonFrom(Arrays.asList("hello", "world")); assertEquals(expectedString, entity); }
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"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeJSONContentTypeOnPropertiesResponse() public virtual void ShouldBeJSONContentTypeOnPropertiesResponse() { string entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", "bar")); JaxRsResponse createResource = _req.post(_functionalTestHelper.dataUri() + "node/", entity); JaxRsResponse response = _req.get(createResource.Location.ToString() + "/properties"); assertThat(response.Type.ToString(), containsString(MediaType.APPLICATION_JSON)); }
protected internal static ThrowingConsumer <HttpServletResponse, IOException> Error(int code, object body) { return(response => { response.Status = code; response.addHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8"); response.OutputStream.write(JsonHelper.createJsonFrom(body).getBytes(StandardCharsets.UTF_8)); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetContentLengthHeaderForRetrievingProperties() public virtual void ShouldGetContentLengthHeaderForRetrievingProperties() { string entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", "bar")); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RestRequest request = req; RestRequest request = _req; JaxRsResponse createResponse = request.Post(_functionalTestHelper.dataUri() + "node/", entity); JaxRsResponse response = request.Get(createResponse.Location.ToString() + "/properties"); assertNotNull(response.Headers.get("Content-Length")); }
public virtual void IncorrectAuthentication() { // Given StartServerWithConfiguredUser(); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(401).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "incorrect")).expectedHeader("WWW-Authenticate", "Basic realm=\"Neo4j\"").post(DataURL()); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); JsonNode firstError = data.get("errors").get(0); assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized")); assertThat(firstError.get("message").asText(), equalTo("Invalid username or password.")); }
public virtual void SuccessfulAuthentication() { // Given StartServerWithConfiguredUser(); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(200).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "secret")).get(UserURL("neo4j")); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); assertThat(data.get("username").asText(), equalTo("neo4j")); assertThat(data.get("password_change_required").asBoolean(), equalTo(false)); assertThat(data.get("password_change").asText(), equalTo(PasswordURL("neo4j"))); }
public virtual void MissingAuthorization() { // Given StartServerWithConfiguredUser(); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(401).expectedHeader("WWW-Authenticate", "Basic realm=\"Neo4j\"").get(DataURL()); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); JsonNode firstError = data.get("errors").get(0); assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Unauthorized")); assertThat(firstError.get("message").asText(), equalTo("No authentication header supplied.")); }
public virtual void PasswordChangeRequired() { // Given StartServer(true); // Document RESTRequestGenerator.ResponseEntity response = Gen.get().expectedStatus(403).withHeader(HttpHeaders.AUTHORIZATION, HTTP.basicAuthHeader("neo4j", "neo4j")).get(DataURL()); // Then JsonNode data = JsonHelper.jsonNode(response.Entity()); JsonNode firstError = data.get("errors").get(0); assertThat(firstError.get("code").asText(), equalTo("Neo.ClientError.Security.Forbidden")); assertThat(firstError.get("message").asText(), equalTo("User is required to change their password.")); assertThat(data.get("password_change").asText(), equalTo(PasswordURL("neo4j"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetCorrectContentEncodingRetrievingProperties() throws org.neo4j.server.rest.domain.JsonParseException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGetCorrectContentEncodingRetrievingProperties() { string asianText = "\u4f8b\u5b50"; string germanText = "öäüÖÄÜß"; string complicatedString = asianText + germanText; string entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", complicatedString)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RestRequest request = req; RestRequest request = _req; JaxRsResponse createResponse = request.Post(_functionalTestHelper.dataUri() + "node/", entity); string response = ( string )JsonHelper.readJson(request.Get(GetPropertyUri(createResponse.Location.ToString(), "foo")).Entity); assertEquals(complicatedString, response); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetCorrectContentEncodingRetrievingPropertiesWithStreaming() throws org.neo4j.server.rest.domain.JsonParseException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGetCorrectContentEncodingRetrievingPropertiesWithStreaming() { string asianText = "\u4f8b\u5b50"; string germanText = "öäüÖÄÜß"; string complicatedString = asianText + germanText; string entity = JsonHelper.createJsonFrom(Collections.singletonMap("foo", complicatedString)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RestRequest request = req.header(org.neo4j.server.rest.repr.formats.StreamingJsonFormat.STREAM_HEADER, "true"); RestRequest request = _req.header(StreamingJsonFormat.STREAM_HEADER, "true"); JaxRsResponse createResponse = request.Post(_functionalTestHelper.dataUri() + "node/", entity); string response = ( string )JsonHelper.readJson(request.Get(GetPropertyUri(createResponse.Location.ToString(), "foo"), new MediaType("application", "json", stringMap("stream", "true"))).Entity); assertEquals(complicatedString, response); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatObjectWithStringField() public virtual void CanFormatObjectWithStringField() { string entity = _json.assemble(new MappingRepresentationAnonymousInnerClass(this)); assertEquals(JsonHelper.createJsonFrom(Collections.singletonMap("key", "expected string")), entity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatObjectWithNestedObject() public virtual void CanFormatObjectWithNestedObject() { _json.assemble(new MappingRepresentationAnonymousInnerClass4(this)); assertEquals(JsonHelper.createJsonFrom(Collections.singletonMap("nested", Collections.singletonMap("data", "expected data"))), _stream.ToString()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatObjectWithUriField() public virtual void CanFormatObjectWithUriField() { _json.assemble(new MappingRepresentationAnonymousInnerClass3(this)); assertEquals(JsonHelper.createJsonFrom(Collections.singletonMap("URL", "http://localhost/subpath")), _stream.ToString()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canFormatEmptyObject() public virtual void CanFormatEmptyObject() { _json.assemble(new MappingRepresentationAnonymousInnerClass(this)); assertEquals(JsonHelper.createJsonFrom(Collections.emptyMap()), _stream.ToString()); }