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

removing non existent project throws proper exception

parent c31bae29
......@@ -506,6 +506,9 @@ public class ProjectRestImpl extends BaseRestImpl {
public Map<String, Object> removeProject(String token, String projectId, String path)
throws SecurityException, QueryException {
Project project = getProjectService().getProjectByProjectId(projectId, token);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
if (getConfigurationService().getConfigurationValue(ConfigurationElementType.DEFAULT_MAP)
.equals(project.getProjectId())) {
throw new OperationNotAllowedException("You cannot remove default map");
......
......@@ -15,6 +15,7 @@ import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -50,6 +51,12 @@ public class ProjectRestImplTest extends RestTestFunctions {
@Autowired
ProjectDao projectDao;
@Before
public void before() {
_projectRestImpl.setModelService(modelService);
_projectRestImpl.setProjectService(projectService);
}
@Test
public void testGetModelDataDependencies() throws Exception {
try {
......@@ -64,6 +71,16 @@ public class ProjectRestImplTest extends RestTestFunctions {
}
}
@Test(expected = ObjectNotFoundException.class)
public void testRemoveNonExistentProject() throws Exception {
try {
_projectRestImpl.removeProject(adminToken, "blabla", null);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test(expected = ObjectNotFoundException.class)
public void testGetInvalidMetaData() throws Exception {
ProjectRestImpl projectRest = createMockProjectRest(null);
......
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