Skip to content

Commit c774600

Browse files
author
Dennis Labordus
committed
Moved Element Converter to Compas Core Repository and some small changes.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent e2e10ff commit c774600

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

service/src/test/java/org/lfenergy/compas/scl/data/service/CompasSclDataServiceTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.jupiter.api.Test;
88
import org.junit.jupiter.api.extension.ExtendWith;
99
import org.lfenergy.compas.core.commons.ElementConverter;
10+
import org.lfenergy.compas.scl.data.exception.CompasSclDataServiceException;
1011
import org.lfenergy.compas.scl.data.model.ChangeSetType;
1112
import org.lfenergy.compas.scl.data.model.SclType;
1213
import org.lfenergy.compas.scl.data.model.Version;
@@ -21,6 +22,7 @@
2122
import static java.util.Collections.emptyList;
2223
import static org.junit.jupiter.api.Assertions.*;
2324
import static org.lfenergy.compas.scl.data.Constants.*;
25+
import static org.lfenergy.compas.scl.data.exception.CompasSclDataServiceErrorCode.HEADER_NOT_FOUND_ERROR_CODE;
2426
import static org.mockito.Mockito.*;
2527

2628
@ExtendWith(MockitoExtension.class)
@@ -141,23 +143,21 @@ void update_WhenCalledWithCompasElements_ThenRepositoryIsCalled() {
141143
}
142144

143145
@Test
144-
void update_WhenCalledWithoutCompasElements_ThenRepositoryIsCalled() {
146+
void update_WhenCalledPreviousSclDoesNotContainHeader_ThenExceptionIsThrown() {
145147
var type = SclType.SCD;
146-
var name = "JUSTSOMENAME";
147148
var uuid = UUID.randomUUID();
148149
var changeSet = ChangeSetType.MAJOR;
149150
var scl = readSCL();
150-
var previousScl = readSCL();
151-
createCompasPrivate(previousScl, name, type);
152151

152+
var previousScl = readSCL();
153+
// Remove the Header from the previous version.
154+
processor.getChildNodeByName(previousScl, SCL_HEADER_ELEMENT_NAME)
155+
.ifPresent(element -> previousScl.removeChild(element));
153156
when(compasSclDataRepository.findByUUID(type, uuid)).thenReturn(previousScl);
154-
doNothing().when(compasSclDataRepository).create(type, uuid, scl, currentVersion.getNextVersion(changeSet));
155157

156-
compasSclDataService.update(type, uuid, changeSet, scl);
157-
158-
assertCompasExtenions(scl, name, type);
159-
verify(compasSclDataRepository, times(1)).create(type, uuid, scl, currentVersion.getNextVersion(changeSet));
160-
verify(compasSclDataRepository, times(1)).findByUUID(type, uuid);
158+
var exception = assertThrows(CompasSclDataServiceException.class,
159+
() -> compasSclDataService.update(type, uuid, changeSet, scl));
160+
assertEquals(HEADER_NOT_FOUND_ERROR_CODE, exception.getErrorCode());
161161
}
162162

163163
@Test

0 commit comments

Comments
 (0)