Commit b7c33aad authored by Ina Curdt's avatar Ina Curdt
Browse files

SI-194, SI-253

parent d6f7d99c
......@@ -84,7 +84,7 @@ public class FailureInformationService {
setFromGridFailureInformationDto(tblFailureInformationToSave, failureInfoDto);
// Holen der nächstes Versionsnummer mit Hilfe der History-Tabelle
// Holen der nächsten Versionsnummer mit Hilfe der History-Tabelle
Long countVersions = htblfailureInformationRepository.countByUuid(failureInfoDto.getUuid());
tblFailureInformationToSave.setVersionNumber(countVersions + 1);
......
......@@ -122,9 +122,6 @@ public class FailureInformationControllerTest {
.andExpect(jsonPath("$.internExtern", is(failureInfoDto.getInternExtern())))
.andExpect(jsonPath("$.voltageLevel", is(failureInfoDto.getVoltageLevel())))
.andExpect(jsonPath("$.pressureLevel", is(failureInfoDto.getPressureLevel())))
//.andExpect(jsonPath("$.failureBegin", is(failureInfoDto.getFailureBegin().toString())))
//.andExpect(jsonPath("$.failureEndPlanned", is(failureInfoDto.getFailureEndPlanned().toString())))
//.andExpect(jsonPath("$.failureEndResupplied", is(failureInfoDto.getFailureEndResupplied().toString())))
.andExpect(jsonPath("$.probableReason", is(failureInfoDto.getProbableReason())))
.andExpect(jsonPath("$.internalRemark", is(failureInfoDto.getInternalRemark())))
.andExpect(jsonPath("$.postcode", is(failureInfoDto.getPostcode())))
......
......@@ -55,6 +55,8 @@ public class FailureInformationServiceTest {
private FailureTypeRepository failureTypeRepository;
@MockBean
private StatusRepository statusRepository;
@MockBean
private HtblFailureInformationRepository htblFailureInformationRepository;
@Test
public void shouldFindFailureInformations() {
......@@ -98,12 +100,17 @@ public class FailureInformationServiceTest {
when(failureClassificationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refFailureClassification));
when(failureTypeRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refFailureType));
when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
when(htblFailureInformationRepository.countByUuid(any(UUID.class))).thenReturn(5L);
when (failureInformationRepository.save(any(TblFailureInformation.class))).thenReturn(fiTbl);
when(failureInformationRepository.save(any(TblFailureInformation.class)))
.then((Answer<TblFailureInformation>) invocation -> {
Object[] args = invocation.getArguments();
return (TblFailureInformation) args[0];
});
FailureInformationDto savedDto = failureInformationService.updateFailureInfo(fiDto);
assertEquals(fiTbl.getUuid(), savedDto.getUuid());
assertEquals(savedDto.getVersionNumber(), 6L);
assertEquals(fiTbl.getResponsibility(), savedDto.getResponsibility());
assertEquals(fiTbl.getInternExtern(), savedDto.getInternExtern());
assertEquals(fiTbl.getVoltageLevel(), savedDto.getVoltageLevel());
......@@ -157,6 +164,7 @@ public class FailureInformationServiceTest {
FailureInformationDto savedDto = failureInformationService.updateFailureInfo(fiDto);
assertEquals(fiTbl.getUuid(), savedDto.getUuid());
assertEquals(fiTbl.getVersionNumber(), savedDto.getVersionNumber());
assertEquals(fiTbl.getResponsibility(), savedDto.getResponsibility());
assertEquals(fiTbl.getInternExtern(), savedDto.getInternExtern());
assertEquals(fiTbl.getVoltageLevel(), savedDto.getVoltageLevel());
......@@ -336,6 +344,7 @@ public class FailureInformationServiceTest {
FailureInformationDto savedDto = failureInformationService.insertFailureInfo(fiDto);
assertNotNull(savedDto.getUuid());
assertEquals(1L, savedDto.getVersionNumber());
assertEquals(fiDto.getResponsibility(), savedDto.getResponsibility());
assertEquals(fiDto.getInternExtern(), savedDto.getInternExtern());
assertEquals(fiDto.getVoltageLevel(), savedDto.getVoltageLevel());
......
......@@ -53,6 +53,7 @@ public class MockDataHelper {
public static FailureInformationDto mockFailureInformationDto() {
FailureInformationDto dto = new FailureInformationDto();
dto.setUuid(UUID.randomUUID());
dto.setVersionNumber(3L);
dto.setResponsibility("Vatter Abraham");
dto.setInternExtern(INTERNAL_SHORT);
dto.setVoltageLevel(Constants.VOLTAGE_LEVEL_MS);
......@@ -89,6 +90,7 @@ public class MockDataHelper {
public static TblFailureInformation mockTblFailureInformation() {
TblFailureInformation obj = new TblFailureInformation();
obj.setUuid(UUID.randomUUID());
obj.setVersionNumber(4L);
obj.setResponsibility("Vatter Abraham");
obj.setInternExtern(INTERNAL_SHORT);
obj.setVoltageLevel(Constants.VOLTAGE_LEVEL_MS);
......
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