Commit 0aa0adbe authored by Piotr Gawron's avatar Piotr Gawron
Browse files

filtering overlays doesn't work if data overlay doesn't have owner defined

parent a8c09c06
......@@ -6,8 +6,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
......@@ -23,6 +22,7 @@ import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.interfaces.IUserService;
@RunWith(SpringJUnit4ClassRunner.class)
......@@ -40,6 +40,9 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
@Autowired
private IUserService userService;
@Autowired
private IModelService modelService;
private User anonymous;
private Project project;
......@@ -52,6 +55,11 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
anonymous = userService.getUserByLogin(Configuration.ANONYMOUS_LOGIN);
}
@After
public void tearDown() {
modelService.removeModelFromCache(map);
}
@Test
public void testGetAllElements() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
......
......@@ -112,6 +112,30 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
.getAsJsonArray().size());
}
@Test
public void testListPublicOverlaysOverlaysWhenCreatorEmpty() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
Layout layout = new Layout();
layout.setProject(project);
layout.setPublicLayout(true);
layoutDao.add(layout);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/" + TEST_PROJECT + "/overlays/?publicOverlay=true&creator=xxx")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.session(session);
String response = mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andReturn().getResponse().getContentAsString();
assertEquals("There are none public overlays created by user xxx", 1, new JsonParser()
.parse(response)
.getAsJsonArray().size());
}
@Test
public void testListOverlaysByPublicFlag() throws Exception {
createAdmin(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
......@@ -906,5 +930,4 @@ public class OverlayControllerIntegrationTest extends ControllerIntegrationTest
.andExpect(status().is2xxSuccessful());
}
}
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