use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectMetaData in project sechub by mercedes-benz.
the class ProjectUpdateAdministrationRestControllerMockTest method when_validator_marks_no_errors___calling_update_project_metadata_calls_update_service_and_returns_http_200.
@Test
public void when_validator_marks_no_errors___calling_update_project_metadata_calls_update_service_and_returns_http_200() throws Exception {
/* execute + test @formatter:off */
this.mockMvc.perform(post(https(PORT_USED).buildUpdateProjectMetaData(projectId)).contentType(MediaType.APPLICATION_JSON_VALUE).content("{\"metaData\":{\"key1\":\"value1\",\"key2\":\"value2\"}}")).andExpect(status().isOk());
ProjectMetaData metaData = new ProjectMetaData();
metaData.getMetaDataMap().put("key1", "value1");
metaData.getMetaDataMap().put("key2", "value2");
verify(mockedProjectUpdateMetaDataService).updateProjectMetaData(projectId, metaData);
/* @formatter:on */
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectMetaData in project sechub by mercedes-benz.
the class ProjectUpdateMetaDataServiceTest method project_found__but_metadata_empty_updates_with_empty_list.
@Test
public void project_found__but_metadata_empty_updates_with_empty_list() {
/* prepare */
when(repository.findById(projectId)).thenReturn(Optional.of(project));
ProjectMetaData emptyMetaData = new ProjectMetaData();
List<ProjectMetaDataEntity> emptyMetaDataEntryList = Collections.emptyList();
/* execute */
serviceToTest.updateProjectMetaData(projectId, emptyMetaData);
/* test */
verify(metaDataRepository).deleteAll(metaData);
verify(metaDataRepository).saveAll(emptyMetaDataEntryList);
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectMetaData in project sechub by mercedes-benz.
the class ProjectUpdateMetaDataServiceTest method project_found__and_2_metadata_entries_updated.
@Test
public void project_found__and_2_metadata_entries_updated() throws Exception {
/* prepare */
when(repository.findById(projectId)).thenReturn(Optional.of(project));
ProjectMetaData newMetaData = new ProjectMetaData();
newMetaData.getMetaDataMap().put("key3", "value3");
newMetaData.getMetaDataMap().put("key4", "value4");
List<ProjectMetaDataEntity> newMetaDataEntryList = Arrays.asList(new ProjectMetaDataEntity(projectId, "key3", "value3"), new ProjectMetaDataEntity(projectId, "key4", "value4"));
/* execute */
serviceToTest.updateProjectMetaData(projectId, newMetaData);
/* test */
verify(metaDataRepository).deleteAll(metaData);
verify(metaDataRepository).saveAll(newMetaDataEntryList);
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectMetaData in project sechub by mercedes-benz.
the class ProjectUpdateAdministrationRestController method updateProjectMetaData.
@UseCaseUpdateProjectMetaData(@Step(number = 1, name = "Rest call", description = "MetaData will be updated", needsRestDoc = true))
@RequestMapping(path = AdministrationAPIConstants.API_UPDATE_PROJECT_METADATA, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
public void updateProjectMetaData(@Validated @RequestBody ProjectJsonInput input, @PathVariable(name = "projectId") String projectId) {
/* @formatter:on */
Optional<ProjectMetaData> projectMetaData = input.getMetaData();
if (!projectMetaData.isPresent()) {
return;
}
ProjectMetaData metaData = projectMetaData.get();
updateProjectMetaDataService.updateProjectMetaData(projectId, metaData);
}
Aggregations