Commit a896009b authored by dietricf's avatar dietricf
Browse files
parents 8291abe0 825dc3a8
...@@ -20,7 +20,10 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessException; ...@@ -20,7 +20,10 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessException;
import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessGrid; import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessGrid;
import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessTask; import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessTask;
import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.DecisionTask; import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.DecisionTask;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.*; import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.DecideFailureInfoCanceled;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.DecideFailureInfoPlanned;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.ShortcutTask;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.UIStoreFailureInformationTask;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.DecisionTask.OutputPort.NO; import static org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.DecisionTask.OutputPort.NO;
...@@ -33,13 +36,13 @@ public class GfiGrid extends ProcessGrid { ...@@ -33,13 +36,13 @@ public class GfiGrid extends ProcessGrid {
public GfiGrid() throws ProcessException { public GfiGrid() throws ProcessException {
DecisionTask decidePlanned = new DecideFailureInfoPlanned(); DecisionTask decidePlanned = new DecideFailureInfoPlanned();
ProcessTask storeEditStatusPlanned = new StoreEditStatusServiceTask( PLANNED ); ProcessTask storeEditStatusPlanned = new ShortcutTask( PLANNED );
ProcessTask enterMessage = register( PLANNED, ProcessTask enterMessage = register( PLANNED,
new UIStoreFailureInformationTask("State PLANNED UI Task", true)); new UIStoreFailureInformationTask("State PLANNED UI Task", true));
register( NEW, enterMessage ); register( NEW, enterMessage );
ProcessTask storeEditStatusCreated = new StoreEditStatusServiceTask( CREATED ); ProcessTask storeEditStatusCreated = new ShortcutTask( CREATED );
ProcessTask qualifyMessage = register( CREATED, ProcessTask qualifyMessage = register( CREATED,
new UIStoreFailureInformationTask( "State CREATED UI Task", true)); new UIStoreFailureInformationTask( "State CREATED UI Task", true));
register( UPDATED, qualifyMessage); register( UPDATED, qualifyMessage);
......
package org.eclipse.openk.gridfailureinformation.bpmn.impl; package org.eclipse.openk.gridfailureinformation.bpmn.impl;
import lombok.Data; import lombok.Data;
import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapper;
import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository; import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository; import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
import org.eclipse.openk.gridfailureinformation.repository.StatusRepository; import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
...@@ -23,4 +24,7 @@ public class GfiProcessEnvironment { ...@@ -23,4 +24,7 @@ public class GfiProcessEnvironment {
@Autowired @Autowired
private FailureInformationService failureInformationService; private FailureInformationService failureInformationService;
@Autowired
private FailureInformationMapper failureInformationMapper;
} }
...@@ -6,10 +6,8 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessState; ...@@ -6,10 +6,8 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessState;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessEnvironment; import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessEnvironment;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState; import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException; import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException;
import org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException;
import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification; import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification;
import org.eclipse.openk.gridfailureinformation.model.RefStatus; import org.eclipse.openk.gridfailureinformation.model.RefStatus;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto; import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -37,22 +35,9 @@ public class ProcessHelper { ...@@ -37,22 +35,9 @@ public class ProcessHelper {
return refPlannedMeasure.getUuid().equals(dto.getFailureClassificationId()); return refPlannedMeasure.getUuid().equals(dto.getFailureClassificationId());
} }
public void setEditStatusAndStore(UUID failureInfoUuid, GfiProcessState state) { public FailureInformationDto storeFailureFromViewModel( FailureInformationDto dto ) {
TblFailureInformation obj = environment.getFailureInformationRepository().findByUuid(failureInfoUuid) FailureInformationDto savedDto = environment.getFailureInformationService().storeFailureInfo(dto, GfiProcessState.NEW);
.orElseThrow(() -> new NotFoundException("failure.information.not.found")); return savedDto;
Optional<RefStatus> optRefStatus = environment.getStatusRepository().findById(state.getStatusValue());
if( !optRefStatus.isPresent()) {
log.error("RefStatus <"+state.getStatusValue()+"> not found in DB");
throw new InternalServerErrorException("status.not.found");
}
obj.setRefStatusIntern(optRefStatus.get());
obj.setRefStatusExtern(optRefStatus.get());
environment.getFailureInformationRepository().save(obj);
}
public void storeFailureFromViewModel( FailureInformationDto dto ) {
environment.getFailureInformationService().storeFailureInfo(dto, GfiProcessState.NEW);
} }
public ProcessState getProcessStateFromStatusUuid( UUID statusUuid ) { public ProcessState getProcessStateFromStatusUuid( UUID statusUuid ) {
......
/*
*******************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************
*/
package org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks;
import lombok.extern.log4j.Log4j2;
import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessException;
import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.ServiceTask;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessState;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessSubject;
@Log4j2
public class StoreEditStatusServiceTask extends ServiceTask<GfiProcessSubject> {
protected final GfiProcessState stateToSave;
public StoreEditStatusServiceTask(GfiProcessState stateToSave) {
super("Bearbeitungsstatus-Status setzen: "+stateToSave);
this.stateToSave = stateToSave;
}
@Override
protected void onLeaveStep(GfiProcessSubject subject) throws ProcessException {
subject.getProcessHelper().setEditStatusAndStore( subject.getFailureInformationDto().getUuid(), stateToSave );
}
}
...@@ -20,6 +20,7 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessException; ...@@ -20,6 +20,7 @@ import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessException;
import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessState; import org.eclipse.openk.gridfailureinformation.bpmn.base.ProcessState;
import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.UserInteractionTask; import org.eclipse.openk.gridfailureinformation.bpmn.base.tasks.UserInteractionTask;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessSubject; import org.eclipse.openk.gridfailureinformation.bpmn.impl.GfiProcessSubject;
import org.eclipse.openk.gridfailureinformation.viewmodel.FailureInformationDto;
@Log4j2 @Log4j2
public class UIStoreFailureInformationTask extends UserInteractionTask<GfiProcessSubject> { public class UIStoreFailureInformationTask extends UserInteractionTask<GfiProcessSubject> {
...@@ -49,7 +50,8 @@ public class UIStoreFailureInformationTask extends UserInteractionTask<GfiProces ...@@ -49,7 +50,8 @@ public class UIStoreFailureInformationTask extends UserInteractionTask<GfiProces
@Override @Override
protected void onStayInTask(GfiProcessSubject subject) throws ProcessException { protected void onStayInTask(GfiProcessSubject subject) throws ProcessException {
subject.getProcessHelper().storeFailureFromViewModel(subject.getFailureInformationDto()); FailureInformationDto failureInformationDto = subject.getProcessHelper().storeFailureFromViewModel(subject.getFailureInformationDto());
subject.setFailureInformationDto(failureInformationDto);
} }
private boolean detectStateChanged( GfiProcessSubject subject ) { private boolean detectStateChanged( GfiProcessSubject subject ) {
......
...@@ -10,17 +10,17 @@ import java.util.Optional; ...@@ -10,17 +10,17 @@ import java.util.Optional;
@Component @Component
public class TblFailureInformationListener { public class TblFailureInformationListener {
@PrePersist // @PrePersist
public void failureInformationPrePersist(TblFailureInformation failureInformation) { // public void failureInformationPrePersist(TblFailureInformation failureInformation) {
failureInformation.setVersionNumber( // failureInformation.setVersionNumber(
Optional.ofNullable(failureInformation.getVersionNumber()).orElse(0L) // Optional.ofNullable(failureInformation.getVersionNumber()).orElse(0L)
+ 1); // + 1);
} // }
//
@PreUpdate // @PreUpdate
public void failureInformationPreUpdate(TblFailureInformation failureInformation) { // public void failureInformationPreUpdate(TblFailureInformation failureInformation) {
failureInformation.setVersionNumber( // failureInformation.setVersionNumber(
Optional.ofNullable(failureInformation.getVersionNumber()).orElse(0L) // Optional.ofNullable(failureInformation.getVersionNumber()).orElse(0L)
+ 1); // + 1);
} // }
} }
...@@ -130,13 +130,11 @@ public class FailureInformationService { ...@@ -130,13 +130,11 @@ public class FailureInformationService {
} }
} }
@Transactional //@Transactional
public FailureInformationDto insertFailureInfo(FailureInformationDto failureInfoDto, GfiProcessState initialState) { public FailureInformationDto insertFailureInfo(FailureInformationDto failureInfoDto, GfiProcessState initialState) {
failureInfoDto.setUuid(null); // force null here failureInfoDto.setUuid(null); // force null here
return processGrid( return storeFailureInfo(failureInfoDto, initialState);
storeFailureInfo(failureInfoDto, initialState)
);
} }
public FailureInformationDto updateFailureInfo(FailureInformationDto failureInfoDto) { public FailureInformationDto updateFailureInfo(FailureInformationDto failureInfoDto) {
...@@ -148,7 +146,7 @@ public class FailureInformationService { ...@@ -148,7 +146,7 @@ public class FailureInformationService {
TblFailureInformation tblFailureInformationToSave = failureInformationMapper.toTblFailureInformation(dto); TblFailureInformation tblFailureInformationToSave = failureInformationMapper.toTblFailureInformation(dto);
if(dto.getUuid() == null ) { if(dto.getUuid() == null ) {
tblFailureInformationToSave.setUuid(UUID.randomUUID()); tblFailureInformationToSave.setUuid(UUID.randomUUID());
tblFailureInformationToSave.setVersionNumber(0L); tblFailureInformationToSave.setVersionNumber(1L);
setFromGridFailureInformationDto(tblFailureInformationToSave, dto); setFromGridFailureInformationDto(tblFailureInformationToSave, dto);
RefStatus refStatus = statusRepository.findById(initialState.getStatusValue()) RefStatus refStatus = statusRepository.findById(initialState.getStatusValue())
...@@ -166,9 +164,14 @@ public class FailureInformationService { ...@@ -166,9 +164,14 @@ public class FailureInformationService {
tblFailureInformationToSave.setId(tblFailureInformation.getId()); tblFailureInformationToSave.setId(tblFailureInformation.getId());
setFromGridFailureInformationDto(tblFailureInformationToSave, dto); setFromGridFailureInformationDto(tblFailureInformationToSave, dto);
setVersionNumber(tblFailureInformationToSave);
} }
return enrichFailureInfo(failureInformationMapper.toFailureInformationDto(failureInformationRepository.save(tblFailureInformationToSave))); TblFailureInformation tblFailureInformationSaved = failureInformationRepository.save(tblFailureInformationToSave);
FailureInformationDto failureInformationDto = failureInformationMapper.toFailureInformationDto(tblFailureInformationSaved);
FailureInformationDto enrichedFailureInfo = enrichFailureInfo(failureInformationDto);
return enrichedFailureInfo;
} }
...@@ -267,6 +270,12 @@ public class FailureInformationService { ...@@ -267,6 +270,12 @@ public class FailureInformationService {
} }
} }
private void setVersionNumber(TblFailureInformation tblFailureInformation){
List<HtblFailureInformation> hfailureList = histFailureInformationRepository.findByUuid(tblFailureInformation.getUuid());
Long lastVersion = hfailureList.stream().map(HtblFailureInformation::getVersionNumber).max(Comparator.naturalOrder()).orElse(0L) ;
tblFailureInformation.setVersionNumber(lastVersion+1);
}
private FailureInformationDto enrichFailureInfo(FailureInformationDto failureInformationDto) { private FailureInformationDto enrichFailureInfo(FailureInformationDto failureInformationDto) {
// wenn Mittelspannung dann füge Adress-Polygonpunkte für Kartenanzeige hinzu // wenn Mittelspannung dann füge Adress-Polygonpunkte für Kartenanzeige hinzu
...@@ -366,7 +375,7 @@ public class FailureInformationService { ...@@ -366,7 +375,7 @@ public class FailureInformationService {
condensedFailureInformation.setRefStatusExtern(refStatusNew); condensedFailureInformation.setRefStatusExtern(refStatusNew);
condensedFailureInformation.setCondensed(true); condensedFailureInformation.setCondensed(true);
condensedFailureInformation.setCondensedCount(listSubordinatedFailureInfos.size()); condensedFailureInformation.setCondensedCount(listSubordinatedFailureInfos.size());
condensedFailureInformation.setVersionNumber(1L);
condensedFailureInformationSaved = failureInformationRepository.save(condensedFailureInformation); condensedFailureInformationSaved = failureInformationRepository.save(condensedFailureInformation);
//kennzeichne die Ursprungs-FailureInfos und speichere //kennzeichne die Ursprungs-FailureInfos und speichere
...@@ -374,6 +383,7 @@ public class FailureInformationService { ...@@ -374,6 +383,7 @@ public class FailureInformationService {
{ {
tblFailureInformation.setCondensed(false); tblFailureInformation.setCondensed(false);
tblFailureInformation.setTblFailureInformationCondensed(condensedFailureInformationSaved); tblFailureInformation.setTblFailureInformationCondensed(condensedFailureInformationSaved);
setVersionNumber(tblFailureInformation);
failureInformationRepository.save(tblFailureInformation); failureInformationRepository.save(tblFailureInformation);
} }
} }
...@@ -572,7 +582,9 @@ public class FailureInformationService { ...@@ -572,7 +582,9 @@ public class FailureInformationService {
addressPolygonPoints.add(twoValues); addressPolygonPoints.add(twoValues);
} }
failureInformationDto.setAddressPolygonPoints(addressPolygonPoints); if(!addressPolygonPoints.isEmpty()) {
failureInformationDto.setAddressPolygonPoints(addressPolygonPoints);
}
} }
} }
...@@ -25,7 +25,6 @@ import java.util.Optional; ...@@ -25,7 +25,6 @@ import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@DataJpaTest @DataJpaTest
...@@ -69,7 +68,7 @@ public class DecideFailureInfoPlannedTest { ...@@ -69,7 +68,7 @@ public class DecideFailureInfoPlannedTest {
FailureInformationDto savedDto = failureInformationService.updateFailureInfo(fiDto); FailureInformationDto savedDto = failureInformationService.updateFailureInfo(fiDto);
verify(processHelper, times(1)) verify(processHelper, times(1))
.setEditStatusAndStore(any( UUID.class ), eq(GfiProcessState.CREATED)); .storeFailureFromViewModel(any( FailureInformationDto.class ));
} }
} }
...@@ -33,7 +33,6 @@ import org.springframework.boot.test.mock.mockito.MockBean; ...@@ -33,7 +33,6 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import java.util.Optional; import java.util.Optional;
import java.util.UUID;
import static org.hibernate.validator.internal.util.Contracts.assertNotNull; import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
...@@ -92,8 +91,9 @@ public class GfiGridTest { ...@@ -92,8 +91,9 @@ public class GfiGridTest {
failureInformationService.updateFailureInfo(dtoToSave); failureInformationService.updateFailureInfo(dtoToSave);
verify(processHelper, times(1)) verify(processHelper, times(1))
.setEditStatusAndStore(any( UUID.class ), eq(GfiProcessState.CREATED)); .storeFailureFromViewModel(any(FailureInformationDto.class));
} }
...@@ -110,7 +110,22 @@ public class GfiGridTest { ...@@ -110,7 +110,22 @@ public class GfiGridTest {
failureInformationService.updateFailureInfo(dtoToSave); failureInformationService.updateFailureInfo(dtoToSave);
verify(processHelper, times(1)) verify(processHelper, times(1))
.setEditStatusAndStore(eq(dtoToSave.getUuid()), eq(GfiProcessState.CREATED)); .storeFailureFromViewModel(any(FailureInformationDto.class));
}
@Test
public void shouldCallStoreOnlyOnceWhenSavingWithNewCreated() {
FailureInformationDto dtoToSave = MockDataHelper.mockFailureInformationDto();
TblFailureInformation failureFromDB = MockDataHelper.mockTblFailureInformation();
RefStatus refStatusFromDB = MockDataHelper.mockRefStatus();
refStatusFromDB.setId(GfiProcessState.NEW.getStatusValue());
when( failureInformationRepository.findByUuid(eq(dtoToSave.getUuid()))).thenReturn(Optional.of(failureFromDB));
when( statusRepository.findByUuid(eq(failureFromDB.getRefStatusIntern().getUuid()))).thenReturn(Optional.of(refStatusFromDB));
failureInformationService.updateFailureInfo(dtoToSave);
verify(processHelper, times(1)).storeFailureFromViewModel(any(FailureInformationDto.class));
} }
} }
...@@ -18,10 +18,7 @@ package org.eclipse.openk.gridfailureinformation.bpmn.impl; ...@@ -18,10 +18,7 @@ package org.eclipse.openk.gridfailureinformation.bpmn.impl;
import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.ProcessHelper; import org.eclipse.openk.gridfailureinformation.bpmn.impl.tasks.ProcessHelper;
import org.eclipse.openk.gridfailureinformation.config.TestConfiguration; import org.eclipse.openk.gridfailureinformation.config.TestConfiguration;
import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException; import org.eclipse.openk.gridfailureinformation.exceptions.InternalServerErrorException;
import org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException;
import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification; import org.eclipse.openk.gridfailureinformation.model.RefFailureClassification;
import org.eclipse.openk.gridfailureinformation.model.RefStatus;
import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation;
import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository; import org.eclipse.openk.gridfailureinformation.repository.FailureClassificationRepository;
import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository; import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository;
import org.eclipse.openk.gridfailureinformation.repository.StatusRepository; import org.eclipse.openk.gridfailureinformation.repository.StatusRepository;
...@@ -88,40 +85,6 @@ public class ProcessHelperTest { ...@@ -88,40 +85,6 @@ public class ProcessHelperTest {
assertThrows( InternalServerErrorException.class, () -> processHelper.isFailureInfoPlanned(dto)); assertThrows( InternalServerErrorException.class, () -> processHelper.isFailureInfoPlanned(dto));
} }
@Test
public void shouldSetEditAndStore_ExceptionNotFound() {
when(failureInformationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.empty());
assertThrows(NotFoundException.class, () -> processHelper.setEditStatusAndStore(UUID.randomUUID(), GfiProcessState.NEW));
}
@Test
public void shouldSetEditAndStore_ExceptionInternalServerError() {
TblFailureInformation tblFailureInformation = MockDataHelper.mockTblFailureInformation();
when(failureInformationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of( tblFailureInformation ));
when(statusRepository.findById(GfiProcessState.NEW.getStatusValue())).thenReturn(Optional.empty());
assertThrows(InternalServerErrorException.class, () -> processHelper.setEditStatusAndStore(UUID.randomUUID(), GfiProcessState.NEW));
}
@Test
public void shouldSetEditAndStoreSuccessful() {
TblFailureInformation tblFailureInformation = MockDataHelper.mockTblFailureInformation();
tblFailureInformation.setRefStatusExtern(null);
tblFailureInformation.setRefStatusIntern(null);
when(failureInformationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of( tblFailureInformation ));
when(failureInformationRepository.save(any(TblFailureInformation.class))).thenReturn(null);
RefStatus refStatus = MockDataHelper.mockRefStatus();
when(statusRepository.findById(GfiProcessState.NEW.getStatusValue())).thenReturn(Optional.of(refStatus));
processHelper.setEditStatusAndStore(UUID.randomUUID(), GfiProcessState.NEW);
assertEquals(refStatus.getUuid(), tblFailureInformation.getRefStatusExtern().getUuid());
assertEquals(refStatus.getUuid(), tblFailureInformation.getRefStatusIntern().getUuid());
}
@Test @Test
public void shouldGetProcessStateFromStatus_Exception() { public void shouldGetProcessStateFromStatus_Exception() {
......
...@@ -62,7 +62,7 @@ public class UIStoreFailureInformationTaskTest { ...@@ -62,7 +62,7 @@ public class UIStoreFailureInformationTaskTest {
@Test @Test
public void shouldStayInTask() throws ProcessException { public void shouldStayInTask() throws ProcessException {
ProcessSubject subject = GfiProcessSubject.of(MockDataHelper.mockFailureInformationDto(), processHelper); ProcessSubject subject = GfiProcessSubject.of(MockDataHelper.mockFailureInformationDto(), processHelper);
doNothing().when(processHelper).storeFailureFromViewModel(any(FailureInformationDto.class)); //doNothing().when(processHelper).storeFailureFromViewModel(any(FailureInformationDto.class));
UIStoreTaskTester task = new UIStoreTaskTester("Testme", true); UIStoreTaskTester task = new UIStoreTaskTester("Testme", true);
task.leaveStep(subject); task.leaveStep(subject);
...@@ -76,7 +76,7 @@ public class UIStoreFailureInformationTaskTest { ...@@ -76,7 +76,7 @@ public class UIStoreFailureInformationTaskTest {
@Test @Test
public void shouldNotStayInTask() throws ProcessException { public void shouldNotStayInTask() throws ProcessException {
ProcessSubject subject = GfiProcessSubject.of(MockDataHelper.mockFailureInformationDto(), processHelper); ProcessSubject subject = GfiProcessSubject.of(MockDataHelper.mockFailureInformationDto(), processHelper);
doNothing().when(processHelper).storeFailureFromViewModel(any(FailureInformationDto.class)); //doNothing().when(processHelper).storeFailureFromViewModel(any(FailureInformationDto.class));
UIStoreTaskTester task = new UIStoreTaskTester("Testme", false); UIStoreTaskTester task = new UIStoreTaskTester("Testme", false);
task.leaveStep(subject); task.leaveStep(subject);
......
...@@ -121,6 +121,7 @@ public class FailureInformationServiceTest { ...@@ -121,6 +121,7 @@ public class FailureInformationServiceTest {
RefBranch refBranch = MockDataHelper.mockRefBranch(); RefBranch refBranch = MockDataHelper.mockRefBranch();
RefRadius refRadius = MockDataHelper.mockRefRadius(); RefRadius refRadius = MockDataHelper.mockRefRadius();
RefExpectedReason refExpectedReason = MockDataHelper.mockRefExpectedReason(); RefExpectedReason refExpectedReason = MockDataHelper.mockRefExpectedReason();
List<HtblFailureInformation> hFailureList = MockDataHelper.mockHistTblFailureInformationList();
when(failureInformationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(fiTbl)); when(failureInformationRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(fiTbl));
when(branchRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refBranch)); when(branchRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refBranch));
...@@ -129,7 +130,7 @@ public class FailureInformationServiceTest { ...@@ -129,7 +130,7 @@ public class FailureInformationServiceTest {
when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus)); when(statusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refStatus));
when(radiusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refRadius)); when(radiusRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refRadius));
when(expectedReasonRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refExpectedReason)); when(expectedReasonRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(refExpectedReason));
when(histFailureInformationRepository.countByUuid(any(UUID.class))).thenReturn(5L); when(histFailureInformationRepository.findByUuid(any(UUID.class))).thenReturn(hFailureList);
when(failureInformationRepository.save(any(TblFailureInformation.class))) when(failureInformationRepository.save(any(TblFailureInformation.class)))
.then((Answer<TblFailureInformation>) invocation -> { .then((Answer<TblFailureInformation>) invocation -> {
...@@ -182,6 +183,8 @@ public class FailureInformationServiceTest { ...@@ -182,6 +183,8 @@ public class FailureInformationServiceTest {
TblStation tblStation = MockDataHelper.mockTblStation(); TblStation tblStation = MockDataHelper.mockTblStation();
List<TblAddress> addressList = MockDataHelper.mockTblAddressList(); List<TblAddress> addressList = MockDataHelper.mockTblAddressList();