Skip to content

Commit

Permalink
dao. read test-set entity
Browse files Browse the repository at this point in the history
  • Loading branch information
okean committed Jul 1, 2016
1 parent 08c9908 commit 196049f
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/java/org/alm/Dao.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.ws.rs.core.Response.Status;

import org.alm.model.Test;
import org.alm.model.TestSet;
import org.apache.commons.lang.StringUtils;

public final class Dao
Expand Down Expand Up @@ -111,6 +112,20 @@ public static Test readTest(String id) throws Exception
return connector().get(testUrl, Test.class, null, null);
}

/**
* Read the test set entity with the specified ID
*
* @param id
* @return
* @throws Exception
*/
public static TestSet readTestSet(String id) throws Exception
{
String testSetUrl = connector().buildEntityUrl("test-set", id);

return connector().get(testSetUrl, TestSet.class, null, null);
}

/**
* Gets an instance of RestConnector
*
Expand Down
57 changes: 57 additions & 0 deletions src/java/org/alm/model/TestSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.alm.model;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class TestSet extends Entity
{
public TestSet(Entity entity)
{
super(entity);
}

public TestSet()
{
type("test-set");
}

public String status()
{
return fieldValue("status");
}

public void status(String value)
{
fieldValue("status", value);
}

public String subtypeId()
{
return fieldValue("subtype-id");
}

public void subtypeId(String value)
{
fieldValue("subtype-id", value);
}

public String comment()
{
return fieldValue("comment");
}

public void comment(String value)
{
fieldValue("comment", value);
}

public String linkage()
{
return fieldValue("linkage");
}

public void linkage(String value)
{
fieldValue("linkage", value);
}
}
43 changes: 43 additions & 0 deletions src/test/java/org/alm/TestDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;

import org.alm.model.TestSet;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
Expand Down Expand Up @@ -111,6 +112,16 @@ public void readTestEntity() throws Exception
EntityAssert.assertEquals(actual, expected);
}

@Test(groups = { "crud", "entity" })
public void readTestSetEntity() throws Exception
{
TestSet expected = createTestSetEntity("2");

TestSet actual = Dao.readTestSet("2");

EntityAssert.assertEquals(actual, expected);
}

private static String authenticationPoint(String host, String port)
{
return String.format("http://%s:%s/qcbin/authentication-point", host, port);
Expand Down Expand Up @@ -141,6 +152,26 @@ private static org.alm.model.Test createTestEntity(String id)
return test;
}

private static TestSet createTestSetEntity(String id)
{
TestSet testSet = new TestSet();

testSet.status("Open");
testSet.subtypeId("101F3974-AD91-49d8-97EF-B3DEC6F0AEA3");
testSet.comment("<html>"
+ "<body>"
+ "<div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\">"
+ "For running tests on Mansfield Park planning tests</span></font></div>"
+ "</body>"
+ "</html>");
testSet.linkage("N");
testSet.id(id);
testSet.parentId("1");
testSet.name("Mansfield Testing");

return testSet;
}

@Path("/qcbin")
public static class RestApiStub
{
Expand Down Expand Up @@ -206,6 +237,18 @@ public org.alm.model.Test test(@PathParam("domain") String domain,
return test;
}

@GET
@Path("/rest/domains/{domain}/projects/{project}/test-sets/{id}")
@Produces("application/xml")
public TestSet testSet(@PathParam("domain") String domain,
@PathParam("project") String project,
@PathParam("id") String id)
{
TestSet testSet = createTestSetEntity(id);

return testSet;
}

private static Response unauthorizedResponse(UriInfo uriInfo)
{
URI baseUri = uriInfo.getBaseUri();
Expand Down
64 changes: 64 additions & 0 deletions src/test/java/org/alm/model/TestTestSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.alm.model;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class TestTestSet
{
TestSet testSet;

@BeforeMethod
public void initTestSetEntity()
{
testSet = new TestSet();
}

@Test(groups = { "test-set" })
public void type()
{
Assert.assertEquals(testSet.type(), "test-set");
}

@Test(groups = { "test-set" })
public void status()
{
testSet.status("Open");

Assert.assertEquals(testSet.status(), "Open");
}

@Test(groups = { "test-set" })
public void subtypeId()
{
testSet.subtypeId("101F3974-AD91-49d8-97EF-B3DEC6F0AEA3");

Assert.assertEquals(testSet.subtypeId(), "101F3974-AD91-49d8-97EF-B3DEC6F0AEA3");
}

@Test(groups = { "test-set" })
public void comment()
{
testSet.comment("<html>"
+ "<body>"
+ "<div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\">"
+ "For running tests on Mansfield Park planning tests</span></font></div>"
+ "</body>"
+ "</html>");

Assert.assertEquals(testSet.comment(), "<html>"
+ "<body>"
+ "<div align=\"left\"><font face=\"Arial\"><span style=\"font-size:8pt\">"
+ "For running tests on Mansfield Park planning tests</span></font></div>"
+ "</body>"
+ "</html>");
}

@Test(groups = { "test-set" })
public void linkage()
{
testSet.linkage("N");

Assert.assertEquals(testSet.linkage(), "N");
}
}

0 comments on commit 196049f

Please sign in to comment.