Skip to content

Commit

Permalink
UTS-199 - Modified test case for RouteImplTest and FilterImplTest add…
Browse files Browse the repository at this point in the history
…ressing PR comment
  • Loading branch information
Luis Sztul authored and Jett Gamboa committed Jan 1, 2016
1 parent 65cf5d3 commit 9c66601
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
22 changes: 11 additions & 11 deletions src/test/java/spark/FilterImplTest.java
Expand Up @@ -25,28 +25,28 @@ public void testConstructor(){
public void handle(Request request, Response response) throws Exception { public void handle(Request request, Response response) throws Exception {
} }
}; };
assertEquals("Path is not equal", PATH_TEST, filter.getPath()); assertEquals("Should return path specified", PATH_TEST, filter.getPath());
assertEquals("Accept type is not equal", ACCEPT_TYPE_TEST, filter.getAcceptType()); assertEquals("Should return accept type specified", ACCEPT_TYPE_TEST, filter.getAcceptType());
} }


@Test @Test
public void testGets() throws Exception { public void testGets_thenReturnGetPathAndGetAcceptTypeSuccessfully() throws Exception {
filter = FilterImpl.create(PATH_TEST, ACCEPT_TYPE_TEST, null); filter = FilterImpl.create(PATH_TEST, ACCEPT_TYPE_TEST, null);
assertEquals("Path is not equal", PATH_TEST, filter.getPath()); assertEquals("Should return path specified", PATH_TEST, filter.getPath());
assertEquals("Accept type is not equal", ACCEPT_TYPE_TEST, filter.getAcceptType()); assertEquals("Should return accept type specified", ACCEPT_TYPE_TEST, filter.getAcceptType());
} }


@Test @Test
public void testCreate_withOutAssignAcceptTypeInTheParameters(){ public void testCreate_whenOutAssignAcceptTypeInTheParameters_thenReturnPathAndAcceptTypeSuccessfully(){
filter = FilterImpl.create(PATH_TEST, null); filter = FilterImpl.create(PATH_TEST, null);
assertEquals("Path is not equal", PATH_TEST, filter.getPath()); assertEquals("Should return path specified", PATH_TEST, filter.getPath());
assertEquals("Accept type is not equal", RouteImpl.DEFAULT_ACCEPT_TYPE, filter.getAcceptType()); assertEquals("Should return accept type specified", RouteImpl.DEFAULT_ACCEPT_TYPE, filter.getAcceptType());
} }


@Test @Test
public void testCreate_withAcceptTypeNullValueInTheParameters(){ public void testCreate_whenAcceptTypeNullValueInTheParameters_thenReturnPathAndAcceptTypeSuccessfully(){
filter = FilterImpl.create(PATH_TEST, null, null); filter = FilterImpl.create(PATH_TEST, null, null);
assertEquals("Path is not equal", PATH_TEST, filter.getPath()); assertEquals("Should return path specified", PATH_TEST, filter.getPath());
assertEquals("Accept type is not equal", RouteImpl.DEFAULT_ACCEPT_TYPE, filter.getAcceptType()); assertEquals("Should return accept type specified", RouteImpl.DEFAULT_ACCEPT_TYPE, filter.getAcceptType());
} }
} }
37 changes: 19 additions & 18 deletions src/test/java/spark/RouteImplTest.java
Expand Up @@ -29,18 +29,18 @@ public Object handle(Request request, Response response) throws Exception {
return null; return null;
} }
}; };
assertEquals("Path is not equal", PATH_TEST, route.getPath()); assertEquals("Should return path specified", PATH_TEST, route.getPath());
} }


@Test @Test
public void testGets() throws Exception { public void testGets_thenReturnGetPathAndGetAcceptTypeSuccessfully() throws Exception {
route = RouteImpl.create(PATH_TEST, ACCEPT_TYPE_TEST, null); route = RouteImpl.create(PATH_TEST, ACCEPT_TYPE_TEST, null);
assertEquals("Path is not equal", PATH_TEST, route.getPath()); assertEquals("Should return path specified", PATH_TEST, route.getPath());
assertEquals("Accept type is not equal", ACCEPT_TYPE_TEST, route.getAcceptType()); assertEquals("Should return accept type specified", ACCEPT_TYPE_TEST, route.getAcceptType());
} }


@Test @Test
public void testHandle() throws Exception { public void testHandle_thenReturnObjectValid() throws Exception {
Route routeMock = EasyMock.createMock(Route.class); Route routeMock = EasyMock.createMock(Route.class);
RouteImpl route = RouteImpl.create(PATH_TEST, routeMock); RouteImpl route = RouteImpl.create(PATH_TEST, routeMock);


Expand All @@ -50,35 +50,36 @@ public void testHandle() throws Exception {
Object value = route.handle(null, null); Object value = route.handle(null, null);
EasyMock.verify(routeMock); EasyMock.verify(routeMock);


assertNotNull("Value is null", value); assertNotNull("Should return null because the request and response from handle are null", value);
} }


@Test @Test
public void testCreate_withOutAssignAcceptTypeInTheParameters(){ public void testCreate_whenOutAssignAcceptTypeInTheParameters_thenReturnPathAndAcceptTypeSuccessfully(){
route = RouteImpl.create(PATH_TEST, null); route = RouteImpl.create(PATH_TEST, null);
assertEquals("Path is not equal", PATH_TEST, route.getPath()); assertEquals("Should return path specified", PATH_TEST, route.getPath());
assertEquals("Accept type is not equal", RouteImpl.DEFAULT_ACCEPT_TYPE, route.getAcceptType()); assertEquals("Should return accept type specified", RouteImpl.DEFAULT_ACCEPT_TYPE, route.getAcceptType());
} }


@Test @Test
public void testCreate_withAcceptTypeNullValueInTheParameters(){ public void testCreate_whenAcceptTypeNullValueInTheParameters_thenReturnPathAndAcceptTypeSuccessfully(){
route = RouteImpl.create(PATH_TEST, null, null); route = RouteImpl.create(PATH_TEST, null, null);
assertEquals("Path is not equal", PATH_TEST, route.getPath()); assertEquals("Should return path specified", PATH_TEST, route.getPath());
assertEquals("Accept type is not equal", RouteImpl.DEFAULT_ACCEPT_TYPE, route.getAcceptType()); assertEquals("Should return accept type specified", RouteImpl.DEFAULT_ACCEPT_TYPE, route.getAcceptType());
} }


@Test @Test
public void testRender_withElementParameterValid_thenReturnValidObject() throws Exception { public void testRender_whenElementParameterValid_thenReturnValidObject() throws Exception {
String finalObjValue = "object_value";
route = RouteImpl.create(PATH_TEST, null); route = RouteImpl.create(PATH_TEST, null);
Object value = route.render("object_value"); Object value = route.render(finalObjValue);
assertNotNull("Value is null", value); assertNotNull("Should return an Object because we configured it to have one", value);
assertEquals("Value is not equal", "object_value", value.toString()); assertEquals("Should return a string object specified", finalObjValue, value.toString());
} }


@Test @Test
public void testRender_withElementParameterIsNull_thenReturnNull() throws Exception { public void testRender_whenElementParameterIsNull_thenReturnNull() throws Exception {
route = RouteImpl.create(PATH_TEST, null); route = RouteImpl.create(PATH_TEST, null);
Object value = route.render(null); Object value = route.render(null);
assertNull("Value is not null", value); assertNull("Should return null because the element from render is null", value);
} }
} }

0 comments on commit 9c66601

Please sign in to comment.