Commit d29bceb6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

tests checking if undefined project is handled properly

parent 921e0fb4
......@@ -95,6 +95,22 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.getAsJsonArray().size());
}
@Test
public void testListOfCommentsWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
createComments();
RequestBuilder request = get("/projects/*/comments/models/" + map.getIdModel() + "/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testCuratorSeesAllComments() throws Exception {
User curator = createCurator(TEST_CURATOR_LOGIN, TEST_CURATOR_PASSWORD);
......@@ -354,6 +370,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.getAsJsonArray().size());
}
@Test
public void testGetReactionCommentsWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
Comment comment = createReactionComment();
commentDao.add(comment);
RequestBuilder request = get(
"/projects/*/comments/models/" + map.getId() + "/bioEntities/reactions/" + reaction.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetReactionCommentsAsCurator() throws Exception {
User curator = createCurator(TEST_CURATOR_LOGIN, TEST_CURATOR_PASSWORD);
......@@ -419,6 +453,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.getAsJsonArray().size());
}
@Test
public void testGetElementCommentsWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
Comment comment = createElementComment();
commentDao.add(comment);
RequestBuilder request = get(
"/projects/*/comments/models/" + map.getId() + "/bioEntities/elements/" + element.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetElementCommentsAsCurator() throws Exception {
User curator = createCurator(TEST_CURATOR_LOGIN, TEST_CURATOR_PASSWORD);
......@@ -484,6 +536,24 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
.getAsJsonArray().size());
}
@Test
public void testGetPointCommentsWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
Comment comment = createComment();
commentDao.add(comment);
RequestBuilder request = get(
"/projects/*/comments/models/" + map.getId() + "/points/10.00,20.00")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testGetPointCommentsAsCurator() throws Exception {
User curator = createCurator(TEST_CURATOR_LOGIN, TEST_CURATOR_PASSWORD);
......@@ -552,6 +622,30 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals(1, commentDao.getCommentByModel(map, null, null).size());
}
@Test
public void testAddElementCommentWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("name", "test_user"),
new BasicNameValuePair("email", "a@a.lu"),
new BasicNameValuePair("content", "tes content"),
new BasicNameValuePair("pinned", "true"),
new BasicNameValuePair("coordinates", "10,2"),
new BasicNameValuePair("modelId", map.getId().toString()))));
RequestBuilder request = post(
"/projects/*/comments/models/" + map.getId() + "/bioEntities/elements/" + element.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testAddElementCommentWithoutAllNecessaryData() throws Exception {
createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD, map.getProject());
......@@ -650,6 +744,30 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals(1, commentDao.getCommentByModel(map, null, null).size());
}
@Test
public void testAddReactionCommentWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("name", "test_user"),
new BasicNameValuePair("email", "a@a.lu"),
new BasicNameValuePair("content", "tes content"),
new BasicNameValuePair("pinned", "true"),
new BasicNameValuePair("coordinates", "10,2"),
new BasicNameValuePair("modelId", map.getId().toString()))));
RequestBuilder request = post(
"/projects/*/comments/models/" + map.getId() + "/bioEntities/reactions/" + reaction.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
@Test
public void testAddPointCommentAsUserWithAccess() throws Exception {
createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD, map.getProject());
......@@ -700,6 +818,29 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals(1, commentDao.getCommentByModel(map, null, null).size());
}
@Test
public void testAddPointCommentWithUndefinedProject() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("name", "test_user"),
new BasicNameValuePair("email", "a@a.lu"),
new BasicNameValuePair("content", "tes content"),
new BasicNameValuePair("pinned", "true"),
new BasicNameValuePair("modelId", map.getId().toString()))));
RequestBuilder request = post(
"/projects/*/comments/models/" + map.getId() + "/points/10,2")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
mockMvc.perform(request)
.andExpect(status().isNotFound());
}
private Comment createComment() {
Comment comment = new Comment();
comment.setModel(map);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment