mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add new methods
TestAddCommentInternalError and TestDeleteComment.
This commit is contained in:
parent
dff3cf7645
commit
dab9208168
@ -81,7 +81,7 @@ public class CommentManagementAPITest {
|
||||
public void testAddComments() throws Exception {
|
||||
Comment comment = CommentMgtTestHelper.getDummyComment("a", "a");
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
Response response = this.commentManagementAPI.addComments(comment, null);
|
||||
Response response = this.commentManagementAPI.addComments(comment, "a");
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(),
|
||||
"The response status should be 201.");
|
||||
@ -98,6 +98,19 @@ public class CommentManagementAPITest {
|
||||
Mockito.reset(commentsManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddCommentsInternalError() throws Exception {
|
||||
Comment comment = CommentMgtTestHelper.getDummyComment("a", "a");
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
Mockito.when(this.commentManagementAPI.addComments(Mockito.any(), Mockito.anyString()))
|
||||
.thenThrow(new CommentManagementException());
|
||||
Response response = this.commentManagementAPI.addComments(comment, null);
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
||||
"The response status should be 500.");
|
||||
Mockito.reset(commentsManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateComment() throws Exception {
|
||||
Comment comment = CommentMgtTestHelper.getDummyComment("a", "a");
|
||||
@ -127,6 +140,25 @@ public class CommentManagementAPITest {
|
||||
"The response status should be 404.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteComment() throws Exception {
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
Response response = this.commentManagementAPI.deleteComment(1);
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
|
||||
"The response status should be 200.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCommentInternalError() throws Exception {
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
Mockito.when(this.commentManagementAPI.deleteComment(Mockito.anyInt())).thenThrow(new CommentManagementException());
|
||||
Response response = this.commentManagementAPI.deleteComment(1);
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
|
||||
"The response status should be 500.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStars() throws Exception {
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
@ -158,7 +190,7 @@ public class CommentManagementAPITest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateInvalideStars() throws Exception {
|
||||
public void testUpdateInvalidStars() throws Exception {
|
||||
PowerMockito.stub(PowerMockito.method(APIUtil.class, "getCommentsManager")).toReturn(this.commentsManager);
|
||||
Response response = this.commentManagementAPI.updateStars(0, "a");
|
||||
Assert.assertNotNull(response, "The response object is null.");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user