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

test checking if invalid query results in BAD_REQUEST

parent fd42fb91
......@@ -557,6 +557,26 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
assertEquals(1, commentDao.getCommentByModel(map, null, null).size());
}
@Test
public void testAddElementCommentWithoutAllNecessaryData() throws Exception {
createUser(TEST_USER_LOGIN, TEST_USER_PASSWORD, map.getProject());
MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD);
String body = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("name", "test_user"),
new BasicNameValuePair("modelId", map.getId().toString()))));
RequestBuilder request = post(
"/projects/" + TEST_PROJECT + "/comments/models/" + map.getId() + "/bioEntities/elements/" + element.getId())
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
mockMvc.perform(request)
.andExpect(status().isBadRequest());
}
@Test
public void testAddElementCommentAsAdmin() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
......
package lcsb.mapviewer.web;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import java.awt.geom.Point2D;
import java.util.Arrays;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.transaction.annotation.Transactional;
import com.google.gson.JsonParser;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.Comment;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.map.CommentDao;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.interfaces.IUserService;
@RunWith(SpringJUnit4ClassRunner.class)
@Rollback
......@@ -52,7 +29,6 @@ public class CommentControllerIntegrationTestWithoutTransaction extends Controll
public void tearDown() {
}
@Test
public void testRemoveNonExistingCommentOnNonExistingMap() throws Exception {
RequestBuilder request = delete("/projects/*/comments/-1/")
......
Supports Markdown
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