Commit 95f5a108 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

API endpoint for fetch background

parent 36e9b494
......@@ -765,8 +765,15 @@ public class ProjectRestImpl extends BaseRestImpl {
return result;
}
public ProjectBackground getBackgroundById(String projectId, Integer backgroundId) {
throw new NotImplementedException();
public ProjectBackground getBackgroundById(String projectId, Integer backgroundId) throws ObjectNotFoundException {
List<ProjectBackground> backgrounds = getProjectByProjectId(projectId).getProjectBackgrounds();
for (ProjectBackground projectBackground : backgrounds) {
if (projectBackground.getId()==backgroundId) {
Hibernate.initialize(projectBackground.getProjectBackgroundImageLayer());
return projectBackground;
}
}
throw new ObjectNotFoundException("Background does not exist");
}
public Map<String, Object> removeBackground(String projectId, Integer backgroundId) {
......
......@@ -1016,8 +1016,8 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
mockMvc.perform(request)
.andExpect(status().is2xxSuccessful())
.andDo(document("projects/project_data/get_background_by_id",
projectPathParameters(),
responseFields()));
backgroundPathParameters(),
responseFields(getBackgroundFields())));
}
@Test
......@@ -1064,4 +1064,8 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
return pathParameters(parameterWithName("projectId").description("project identifier"));
}
private PathParametersSnippet backgroundPathParameters() {
return projectPathParameters().and(parameterWithName("backgroundId").description("background identifier"));
}
}
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