Skip to content

Commit 56283f2

Browse files
author
Dennis Labordus
committed
Implemented adding comments when doing create or update of SCL.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 04472b9 commit 56283f2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ void create_WhenCalledWithOutCompasExtension_ThenRepositoryIsCalledAndUUIDIsRetu
105105

106106
assertNotNull(uuid);
107107
assertCompasExtenions(scl, name, type);
108-
assertHistoryItem(scl, initialVersion);
108+
assertHistoryItem(scl, initialVersion, comment);
109109
verify(compasSclDataRepository, times(1)).create(eq(type), any(UUID.class), eq(scl), eq(initialVersion));
110110
}
111111

112112
@Test
113113
void create_WhenCalledWithCompasExtension_ThenRepositoryIsCalledAndUUIDIsReturned() {
114114
var type = SclType.SCD;
115115
var name = "JUSTSOMENAME";
116-
var comment = "Some comments";
116+
var comment = "";
117117
var who = "User A";
118118

119119
var scl = readSCL();
@@ -125,7 +125,7 @@ void create_WhenCalledWithCompasExtension_ThenRepositoryIsCalledAndUUIDIsReturne
125125

126126
assertNotNull(uuid);
127127
assertCompasExtenions(scl, name, type);
128-
assertHistoryItem(scl, initialVersion);
128+
assertHistoryItem(scl, initialVersion, comment);
129129
verify(compasSclDataRepository, times(1)).create(eq(type), any(UUID.class), eq(scl), eq(initialVersion));
130130
}
131131

@@ -135,7 +135,6 @@ void update_WhenCalledWithCompasElements_ThenRepositoryIsCalled() {
135135
var name = "JUSTSOMENAME";
136136
var uuid = UUID.randomUUID();
137137
var changeSet = ChangeSetType.MAJOR;
138-
var comment = "Some comments";
139138
var who = "User A";
140139
var nextVersion = initialVersion.getNextVersion(changeSet);
141140

@@ -147,10 +146,10 @@ void update_WhenCalledWithCompasElements_ThenRepositoryIsCalled() {
147146
when(compasSclDataRepository.findByUUID(type, uuid)).thenReturn(previousScl);
148147
doNothing().when(compasSclDataRepository).create(type, uuid, scl, nextVersion);
149148

150-
compasSclDataService.update(type, uuid, changeSet, who, comment, scl);
149+
compasSclDataService.update(type, uuid, changeSet, who, null, scl);
151150

152151
assertCompasExtenions(scl, name, type);
153-
assertHistoryItem(scl, nextVersion);
152+
assertHistoryItem(scl, nextVersion, null);
154153
verify(compasSclDataRepository, times(1)).create(type, uuid, scl, nextVersion);
155154
verify(compasSclDataRepository, times(1)).findByUUID(type, uuid);
156155
}
@@ -213,7 +212,7 @@ private void assertCompasExtenions(Element scl, String name, SclType type) {
213212
assertEquals(type.toString(), typeElement.get().getTextContent());
214213
}
215214

216-
private void assertHistoryItem(Element scl, Version version) {
215+
private void assertHistoryItem(Element scl, Version version, String comment) {
217216
var header = processor.getSclHeader(scl);
218217
assertTrue(header.isPresent());
219218

@@ -225,6 +224,9 @@ private void assertHistoryItem(Element scl, Version version) {
225224
// The last item should be the one added.
226225
var item = items.get(items.size() - 1);
227226
assertEquals(version.toString(), item.getAttribute(SCL_VERSION_ATTR));
227+
if (comment != null && !comment.isEmpty()) {
228+
assertTrue(item.getAttribute(SCL_WHAT_ATTR).contains(comment));
229+
}
228230
}
229231

230232
private Element readSCL() {

0 commit comments

Comments
 (0)