[SI-1022] adjustments due to code review
Signed-off-by: Holger Rudolph <holger.rudolph@pta.de>
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupController.java
index 49abe23..79e3817 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupController.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupController.java
@@ -67,11 +67,11 @@
@ApiResponse(code = 200, message = "Verteilergruppe erfolgreich zugeordnet"),
@ApiResponse(code = 500, message = "Konnte nicht durchgeführt werden")
})
- public ResponseEntity<FailureInformationDistributionGroupDto> insertFailureInfoGroup(
+ public ResponseEntity<FailureInformationDistributionGroupDto> insertFailureInfoDistributionGroup(
@PathVariable UUID failureInfoUuid,
@Validated @RequestBody DistributionGroupDto dgDto) {
- FailureInformationDistributionGroupDto savedGfDgDto = failureInformationDistributionGroupService.insertFailureInfoGroup(failureInfoUuid, dgDto);
+ FailureInformationDistributionGroupDto savedGfDgDto = failureInformationDistributionGroupService.insertFailureInfoDistributionGroup(failureInfoUuid, dgDto);
URI location = ServletUriComponentsBuilder
.fromCurrentRequestUri()
.path("/{groupid}")
@@ -88,10 +88,10 @@
@ApiResponse(code = 400, message = "Ungültige Anfrage"),
@ApiResponse(code = 404, message = "Nicht gefunden")
})
- public void deleteFailureInfoGroup(
+ public void deleteFailureInfoDistributionGroup(
@PathVariable UUID failureInfoUuid,
@PathVariable UUID groupUuid) {
- failureInformationDistributionGroupService.deleteFailureInfoGroup(failureInfoUuid, groupUuid);
+ failureInformationDistributionGroupService.deleteFailureInfoDistributionGroup(failureInfoUuid, groupUuid);
}
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
index 3cf89c4..32d253d 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/model/TblDistributionGroup.java
@@ -17,8 +17,6 @@
import lombok.Data;
import javax.persistence.*;
-import java.util.HashSet;
-import java.util.Set;
import java.util.UUID;
@Data
@@ -33,7 +31,4 @@
private String name;
private String distributionText;
- @ManyToMany(mappedBy = "distributionGroups")
- private Set<TblFailureInformation> failureInformations = new HashSet<>();
-
}
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupService.java
index b2404c9..02f9881 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupService.java
@@ -65,13 +65,13 @@
}
@Transactional
- public FailureInformationDistributionGroupDto insertFailureInfoGroup(UUID failureInfoUuid, DistributionGroupDto groupDto) {
+ public FailureInformationDistributionGroupDto insertFailureInfoDistributionGroup(UUID failureInfoUuid, DistributionGroupDto groupDto) {
TblFailureInformation failureInformation = failureInformationRepository.findByUuid(failureInfoUuid)
- .orElseThrow(NotFoundException::new);
+ .orElseThrow( () -> new NotFoundException("failure.info.uuid.not.existing"));
TblDistributionGroup distributionGroup = distributionGroupRepository.findByUuid(groupDto.getUuid())
- .orElseThrow(NotFoundException::new);
+ .orElseThrow( () -> new NotFoundException("distribution.group.uuid.not.existing"));
List<TblDistributionGroup> distributionGroups = failureInformation.getDistributionGroups();
for (TblDistributionGroup group : distributionGroups) {
@@ -91,7 +91,7 @@
}
@Transactional
- public void deleteFailureInfoGroup(UUID failureInfoUuid, UUID groupUuid) {
+ public void deleteFailureInfoDistributionGroup(UUID failureInfoUuid, UUID groupUuid) {
TblFailureInformation failureInformation = failureInformationRepository.findByUuid(failureInfoUuid)
.orElseThrow( () -> new BadRequestException("failure.info.uuid.not.existing"));
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupControllerTest.java
index 143cb43..c738b26 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupControllerTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationDistributionGroupControllerTest.java
@@ -63,7 +63,7 @@
public void shouldAssignDistributionGroupToFailureInfo() throws Exception {
FailureInformationDistributionGroupDto failureInfoGroupDto = MockDataHelper.mockFailureInformationDistributionGroupDto();
- when( failureInformationDistributionGroupService.insertFailureInfoGroup(any(UUID.class), any(DistributionGroupDto.class))).thenReturn(failureInfoGroupDto);
+ when( failureInformationDistributionGroupService.insertFailureInfoDistributionGroup(any(UUID.class), any(DistributionGroupDto.class))).thenReturn(failureInfoGroupDto);
mockMvc.perform(post("/grid-failure-informations/" + UUID.randomUUID().toString() + "/distribution-groups")
.contentType(MediaType.APPLICATION_JSON)
@@ -74,7 +74,7 @@
}
@Test
- public void shouldDeleteGroupForFailureInformation() throws Exception {
+ public void shouldDeleteDistributionGroupForFailureInformation() throws Exception {
mockMvc.perform(delete("/grid-failure-informations/" + UUID.randomUUID().toString() + "/distribution-groups/" + UUID.randomUUID())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful());
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupServiceTest.java
index a3be4d2..b0c4943 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationDistributionGroupServiceTest.java
@@ -91,7 +91,7 @@
when(distributionGroupRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(distributionGroup));
when(failureInformationDistributionGroupRepository.save(any(TblFailureInformationDistributionGroup.class))).thenReturn(failureInfoGroup);
- FailureInformationDistributionGroupDto savedDto = failureInformationDistributionGroupService.insertFailureInfoGroup(UUID.randomUUID(), groupDto);
+ FailureInformationDistributionGroupDto savedDto = failureInformationDistributionGroupService.insertFailureInfoDistributionGroup(UUID.randomUUID(), groupDto);
assertNotNull(savedDto.getDistributionGroupId());
assertEquals(savedDto.getDistributionGroupId(), failureInfoGroup.getFkTblDistributionGroup());
@@ -109,7 +109,7 @@
when(failureInformationDistributionGroupRepository.findByFkTblFailureInformationAndFkTblDistributionGroup(anyLong(), anyLong())).thenReturn(Optional.of(failureInfoGroup));
Mockito.doNothing().when(failureInformationDistributionGroupRepository).delete( isA( TblFailureInformationDistributionGroup.class ));
- failureInformationDistributionGroupService.deleteFailureInfoGroup(UUID.randomUUID(), UUID.randomUUID());
+ failureInformationDistributionGroupService.deleteFailureInfoDistributionGroup(UUID.randomUUID(), UUID.randomUUID());
Mockito.verify(failureInformationDistributionGroupRepository, times(1)).delete( failureInfoGroup );
}