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

tests showing transactional problems with overlay controller

parent 028f046e
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.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.Before;
import org.junit.Test;
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.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.layout.Layout;
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.ConfigurationElementType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.map.LayoutDao;
import lcsb.mapviewer.services.interfaces.*;
import lcsb.mapviewer.services.interfaces.IConfigurationService;
@RunWith(SpringJUnit4ClassRunner.class)
@Rollback
......@@ -45,7 +27,7 @@ public class OverlayControllerIntegrationTestWithoutTransaction extends Controll
private static final String BUILD_IN_TEST_ADMIN_LOGIN = "admin";
private String defaultProjectId;
@Autowired
IConfigurationService configurationService;
......@@ -63,4 +45,53 @@ public class OverlayControllerIntegrationTestWithoutTransaction extends Controll
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
@Test
public void testGetReactionForNonExistingOverlay() throws Exception {
RequestBuilder request = get(
"/projects/" + defaultProjectId + "/overlays/-1/models/*/bioEntities/reactions/123/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
@Test
public void testGetElementForNonExistingOverlay() throws Exception {
RequestBuilder request = get(
"/projects/" + defaultProjectId + "/overlays/-1/models/*/bioEntities/elements/123/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
@Test
public void testRemoveNonExistingOverlay() throws Exception {
RequestBuilder request = delete("/projects/" + defaultProjectId + "/overlays/-1/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
@Test
public void testUpdateNonExistingOverlay() throws Exception {
String body = "xxx";
RequestBuilder request = patch("/projects/" + defaultProjectId + "/overlays/-1/")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body);
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
@Test
public void testFetchSourceForExistingOverlay() throws Exception {
RequestBuilder request = get("/projects/" + defaultProjectId + "/overlays/-1:downloadSource")
.contentType(MediaType.APPLICATION_FORM_URLENCODED);
mockMvc.perform(request)
.andExpect(status().is4xxClientError());
}
}
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