Search in sources :

Example 1 with JsonObject

use of javax.json.JsonObject in project visualee by Thomas-S-B.

the class GraphCreatorTest method testBuildJSONNode.

@Test
public void testBuildJSONNode() {
    JavaSourceContainer.getInstance().clear();
    DependencyContainer.getInstance().clear();
    String name = "MyTestClass";
    String sourcecode = "test source code - Matt Pavolka Group - Something People Can Use";
    JavaSource javaSource = JavaSourceFactory.getInstance().newJavaSource("MyTestClass");
    javaSource.setGroup(2);
    javaSource.setPackagePath("de.test.test2");
    javaSource.setSourceCode(sourcecode);
    JsonObjectBuilder job = GraphCreator.buildJSONNode(javaSource);
    JsonObject node = job.build();
    assertEquals(name, node.getString("name"));
    assertEquals(2, node.getInt("group"));
    assertNotNull(node.getString("description"));
    assertEquals(sourcecode, node.getString("sourcecode"));
}
Also used : JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) JsonObject(javax.json.JsonObject) JsonObjectBuilder(javax.json.JsonObjectBuilder) Test(org.junit.Test)

Example 2 with JsonObject

use of javax.json.JsonObject in project javaee7-samples by javaee-samples.

the class NameAddResourceTest method shouldFailAtFirstNameNullValidation.

@Test
public void shouldFailAtFirstNameNullValidation() throws Exception {
    JsonObject name = startValidName().addNull("firstName").build();
    Response response = postName(name);
    assertFailedValidation(response);
}
Also used : Response(javax.ws.rs.core.Response) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Example 3 with JsonObject

use of javax.json.JsonObject in project javaee7-samples by javaee-samples.

the class NameAddResourceTest method shouldFailAtEmailComDomainValidation.

@Test
public void shouldFailAtEmailComDomainValidation() throws Exception {
    JsonObject name = startValidName().add("email", "other-than-com@domain.pl").build();
    Response response = postName(name);
    assertFailedValidation(response);
}
Also used : Response(javax.ws.rs.core.Response) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Example 4 with JsonObject

use of javax.json.JsonObject in project javaee7-samples by javaee-samples.

the class NameAddResourceTest method shouldFailAtLastNameSizeValidation.

@Test
public void shouldFailAtLastNameSizeValidation() throws Exception {
    JsonObject name = startValidName().add("lastName", "").build();
    Response response = postName(name);
    assertFailedValidation(response);
}
Also used : Response(javax.ws.rs.core.Response) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Example 5 with JsonObject

use of javax.json.JsonObject in project javaee7-samples by javaee-samples.

the class NameAddResourceTest method shouldFailAtFirstNameSizeValidation.

@Test
public void shouldFailAtFirstNameSizeValidation() throws Exception {
    JsonObject name = startValidName().add("firstName", "").build();
    Response response = postName(name);
    assertFailedValidation(response);
}
Also used : Response(javax.ws.rs.core.Response) JsonObject(javax.json.JsonObject) Test(org.junit.Test)

Aggregations

JsonObject (javax.json.JsonObject)214 Test (org.junit.Test)101 JsonArray (javax.json.JsonArray)58 StringReader (java.io.StringReader)52 Credentials (org.apache.commons.httpclient.Credentials)52 UsernamePasswordCredentials (org.apache.commons.httpclient.UsernamePasswordCredentials)52 ArrayList (java.util.ArrayList)51 HashMap (java.util.HashMap)47 NameValuePair (org.apache.commons.httpclient.NameValuePair)43 HttpTest (org.apache.sling.commons.testing.integration.HttpTest)41 JsonString (javax.json.JsonString)31 JsonReader (javax.json.JsonReader)25 HashSet (java.util.HashSet)16 Map (java.util.Map)12 Response (javax.ws.rs.core.Response)12 JsonObjectBuilder (javax.json.JsonObjectBuilder)11 NameValuePairList (org.apache.sling.commons.testing.integration.NameValuePairList)11 StringWriter (java.io.StringWriter)10 JsonException (javax.json.JsonException)10 JsonArrayBuilder (javax.json.JsonArrayBuilder)9