diff --git a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java index ae8366d..4a12063 100644 --- a/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java +++ b/scl-extension/src/main/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsField.java @@ -8,8 +8,9 @@ * For a description of the fields, see the XSD. */ public enum CompasExtensionsField { - SCL_NAME_EXTENSION("SclName"), - SCL_FILETYPE_EXTENSION("SclFileType"), + SCL_NAME("SclName"), + SCL_FILE_TYPE("SclFileType"), + LABELS("Labels"), FLOW("Flow"), CONNECTIVITY_NODE("ConnectivityNode"), BAY("Bay"), diff --git a/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManagerTest.java b/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManagerTest.java index c51723b..959b692 100644 --- a/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManagerTest.java +++ b/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/AbstractCompasExtensionsManagerTest.java @@ -11,7 +11,7 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.*; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME; class AbstractCompasExtensionsManagerTest { private AbstractCompasExtensionsManager manager = new AbstractCompasExtensionsManager() { @@ -19,7 +19,7 @@ class AbstractCompasExtensionsManagerTest { @Test void getCompasElement_WhenNullPassedAsList_ThenEmptyOptionalReturned() { - var result = manager.getCompasElement(null, SCL_NAME_EXTENSION); + var result = manager.getCompasElement(null, SCL_NAME); assertFalse(result.isPresent()); } @@ -27,7 +27,7 @@ void getCompasElement_WhenNullPassedAsList_ThenEmptyOptionalReturned() { @Test void getCompasElement_WhenCalledWithListContainingSclName_ThenSclNameReturned() { var elements = createElements(true); - var result = manager.getCompasElement(elements, SCL_NAME_EXTENSION); + var result = manager.getCompasElement(elements, SCL_NAME); assertTrue(result.isPresent()); assertEquals("project", result.get().getValue()); @@ -36,14 +36,14 @@ void getCompasElement_WhenCalledWithListContainingSclName_ThenSclNameReturned() @Test void getCompasElement_WhenCalledWithListNotContainingSclName_ThenEmptyOptionalReturned() { var elements = createElements(false); - var result = manager.getCompasElement(elements, SCL_NAME_EXTENSION); + var result = manager.getCompasElement(elements, SCL_NAME); assertFalse(result.isPresent()); } @Test void getCompasValue_WhenNullPassedAsList_ThenEmptyOptionalReturned() { - var result = manager.getCompasValue(null, SCL_NAME_EXTENSION, String.class); + var result = manager.getCompasValue(null, SCL_NAME, String.class); assertFalse(result.isPresent()); } @@ -51,7 +51,7 @@ void getCompasValue_WhenNullPassedAsList_ThenEmptyOptionalReturned() { @Test void getCompasValue_WhenCalledWithListContainingSclName_ThenSclNameReturned() { var elements = createElements(true); - var result = manager.getCompasValue(elements, SCL_NAME_EXTENSION, String.class); + var result = manager.getCompasValue(elements, SCL_NAME, String.class); assertTrue(result.isPresent()); assertEquals("project", result.get()); @@ -60,7 +60,7 @@ void getCompasValue_WhenCalledWithListContainingSclName_ThenSclNameReturned() { @Test void getCompasValue_WhenCalledWithListNotContainingSclName_ThenEmptyOptionalReturned() { var elements = createElements(false); - var result = manager.getCompasValue(elements, SCL_NAME_EXTENSION, String.class); + var result = manager.getCompasValue(elements, SCL_NAME, String.class); assertFalse(result.isPresent()); } @@ -69,7 +69,7 @@ private List createElements(boolean withSclName) { var elements = new ArrayList<>(); if (withSclName) { - var qname = new QName(CompasExtensionsConstants.COMPAS_EXTENSION_NS_URI, SCL_NAME_EXTENSION.getFieldName()); + var qname = new QName(CompasExtensionsConstants.COMPAS_EXTENSION_NS_URI, SCL_NAME.getFieldName()); var jaxbElement = new JAXBElement<>(qname, String.class, "project"); elements.add(jaxbElement); } diff --git a/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsFieldTest.java b/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsFieldTest.java index 7fea3ed..c67d760 100644 --- a/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsFieldTest.java +++ b/scl-extension/src/test/java/org/lfenergy/compas/scl/extensions/commons/CompasExtensionsFieldTest.java @@ -6,13 +6,13 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.*; class CompasExtensionsFieldTest { @Test void enum_WhenRetrievingTheFieldName_ThenTheCorrectStringIsReturned() { - assertEquals("SclName", SCL_NAME_EXTENSION.getFieldName()); - assertEquals("SclFileType", SCL_FILETYPE_EXTENSION.getFieldName()); + assertEquals("SclName", SCL_NAME.getFieldName()); + assertEquals("SclFileType", SCL_FILE_TYPE.getFieldName()); + assertEquals("Labels", LABELS.getFieldName()); } } diff --git a/scl2003/src/main/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManager.java b/scl2003/src/main/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManager.java index f70b54d..ef8826f 100644 --- a/scl2003/src/main/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManager.java +++ b/scl2003/src/main/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManager.java @@ -6,6 +6,7 @@ import org.lfenergy.compas.scl.extensions.commons.AbstractCompasExtensionsManager; import org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField; import org.lfenergy.compas.scl.extensions.model.SclFileType; +import org.lfenergy.compas.scl.extensions.model.TCompasLabels; import org.lfenergy.compas.scl2003.model.SCL; import org.lfenergy.compas.scl2003.model.TPrivate; @@ -13,8 +14,7 @@ import java.util.Optional; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.*; public class CompasExtensionsManager extends AbstractCompasExtensionsManager { public Optional getCompasPrivate(SCL scl) { @@ -27,12 +27,16 @@ public Optional getCompasPrivate(SCL scl) { return Optional.empty(); } - public Optional getCompasSclName(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_NAME_EXTENSION, String.class); + public Optional getCompasLabels(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, LABELS, TCompasLabels.class); } public Optional getCompasSclFileType(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_FILETYPE_EXTENSION, SclFileType.class); + return getCompasValue(compasPrivate, SCL_FILE_TYPE, SclFileType.class); + } + + public Optional getCompasSclName(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, SCL_NAME, String.class); } private Optional getCompasValue(TPrivate compasPrivate, CompasExtensionsField field, Class clazz) { diff --git a/scl2003/src/test/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManagerTest.java b/scl2003/src/test/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManagerTest.java index 5abf9f2..0b35a24 100644 --- a/scl2003/src/test/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManagerTest.java +++ b/scl2003/src/test/java/org/lfenergy/compas/scl2003/commons/CompasExtensionsManagerTest.java @@ -8,8 +8,8 @@ import static org.junit.jupiter.api.Assertions.*; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILE_TYPE; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME; import static org.lfenergy.compas.scl2003.util.ReadTestFile.readSCL; class CompasExtensionsManagerTest { @@ -44,7 +44,7 @@ void getCompasPrivate_WhenCalledWithoutPrivate_ThenNoCompasPrivateReturned() { @Test void getCompasElement_WhenCalledNullPassed_ThenNoNameReturned() { - var compasElement = manager.getCompasElement(null, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(null, SCL_NAME); assertFalse(compasElement.isPresent()); } @@ -55,7 +55,7 @@ void getCompasElement_WhenCalledWithoutSclName_ThenNoSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -67,7 +67,7 @@ void getCompasElement_WhenCalledWithSclName_ThenSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertTrue(compasElement.isPresent()); assertEquals("project", compasElement.get().getValue().toString()); @@ -80,7 +80,7 @@ void getCompasElement_WhenCalledWithoutFileType_ThenNoFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -92,7 +92,7 @@ void getCompasElement_WhenCalledWithFileType_ThenFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertTrue(compasElement.isPresent()); assertEquals(SclFileType.CID, compasElement.get().getValue()); @@ -163,6 +163,38 @@ void getCompasSclFileType_WhenCalledWithoutType_ThenNoTypeReturned() { }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); } + @Test + void getCompasLabels_WhenCalledNullPassed_ThenNoLabelsReturned() { + var value = manager.getCompasLabels(null); + + assertFalse(value.isPresent()); + } + + @Test + void getCompasLabels_WhenCalledWithLabels_ThenLabelsReturned() { + var scl = readSCL("scl_with_compas_private.scd"); + var compasPrivate = manager.getCompasPrivate(scl); + + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertTrue(labels.isPresent()); + assertEquals("Label1", labels.get().getLabel().get(0)); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + + @Test + void getCompasLabels_WhenCalledWithoutLabels_ThenNoLabelsReturned() { + var scl = readSCL("scl_without_labels_compas_private.scd"); + + var compasPrivate = manager.getCompasPrivate(scl); + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertFalse(labels.isPresent()); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + @Test void createCompasPrivate_WhenCalled_ThenNewCompasPrivateReturned() { var compasPrivate = manager.createCompasPrivate(); diff --git a/scl2003/src/test/resources/scl/scl_with_compas_private.scd b/scl2003/src/test/resources/scl/scl_with_compas_private.scd index c8729e5..f8844c3 100644 --- a/scl2003/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_with_compas_private.scd @@ -1,10 +1,13 @@ - + - project - CID + project + CID + + Label1 +
\ No newline at end of file diff --git a/scl2003/src/test/resources/scl/scl_without_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_compas_private.scd index 8e4d886..8fa13b1 100644 --- a/scl2003/src/test/resources/scl/scl_without_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_without_compas_private.scd @@ -1,6 +1,6 @@ - +
\ No newline at end of file diff --git a/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd index 42f6a12..b1aeefb 100644 --- a/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -1,9 +1,12 @@ - + - project + project + + Label1 +
\ No newline at end of file diff --git a/scl2003/src/test/resources/scl/scl_without_labels_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_labels_compas_private.scd new file mode 100644 index 0000000..9386124 --- /dev/null +++ b/scl2003/src/test/resources/scl/scl_without_labels_compas_private.scd @@ -0,0 +1,10 @@ + + + + + + project + CID + +
+ \ No newline at end of file diff --git a/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd index dc97f99..92b8873 100644 --- a/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2003/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -1,9 +1,12 @@ - + - CID + CID + + Label1 +
\ No newline at end of file diff --git a/scl2007b/src/main/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManager.java b/scl2007b/src/main/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManager.java index b00e0d1..e4b48a2 100644 --- a/scl2007b/src/main/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManager.java +++ b/scl2007b/src/main/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManager.java @@ -6,6 +6,7 @@ import org.lfenergy.compas.scl.extensions.commons.AbstractCompasExtensionsManager; import org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField; import org.lfenergy.compas.scl.extensions.model.SclFileType; +import org.lfenergy.compas.scl.extensions.model.TCompasLabels; import org.lfenergy.compas.scl2007b.model.SCL; import org.lfenergy.compas.scl2007b.model.TPrivate; @@ -13,8 +14,7 @@ import java.util.Optional; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.*; public class CompasExtensionsManager extends AbstractCompasExtensionsManager { public Optional getCompasPrivate(SCL scl) { @@ -34,12 +34,16 @@ private Optional getCompasValue(TPrivate compasPrivate, CompasExtensionsF return Optional.empty(); } + public Optional getCompasSclFileType(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, SCL_FILE_TYPE, SclFileType.class); + } + public Optional getCompasSclName(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_NAME_EXTENSION, String.class); + return getCompasValue(compasPrivate, SCL_NAME, String.class); } - public Optional getCompasSclFileType(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_FILETYPE_EXTENSION, SclFileType.class); + public Optional getCompasLabels(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, LABELS, TCompasLabels.class); } public TPrivate createCompasPrivate() { diff --git a/scl2007b/src/test/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManagerTest.java b/scl2007b/src/test/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManagerTest.java index b1d75b8..410bafa 100644 --- a/scl2007b/src/test/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManagerTest.java +++ b/scl2007b/src/test/java/org/lfenergy/compas/scl2007b/commons/CompasExtensionsManagerTest.java @@ -8,8 +8,8 @@ import static org.junit.jupiter.api.Assertions.*; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILE_TYPE; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME; import static org.lfenergy.compas.scl2007b.util.ReadTestFile.readSCL; class CompasExtensionsManagerTest { @@ -44,7 +44,7 @@ void getCompasPrivate_WhenCalledWithoutPrivate_ThenNoCompasPrivateReturned() { @Test void getCompasElement_WhenCalledNullPassed_ThenNoNameReturned() { - var compasElement = manager.getCompasElement(null, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(null, SCL_NAME); assertFalse(compasElement.isPresent()); } @@ -55,7 +55,7 @@ void getCompasElement_WhenCalledWithoutSclName_ThenNoSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -67,7 +67,7 @@ void getCompasElement_WhenCalledWithSclName_ThenSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertTrue(compasElement.isPresent()); assertEquals("project", compasElement.get().getValue().toString()); @@ -80,7 +80,7 @@ void getCompasElement_WhenCalledWithoutFileType_ThenNoFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -92,7 +92,7 @@ void getCompasElement_WhenCalledWithFileType_ThenFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertTrue(compasElement.isPresent()); assertEquals(SclFileType.CID, compasElement.get().getValue()); @@ -163,6 +163,38 @@ void getCompasSclFileType_WhenCalledWithoutType_ThenNoTypeReturned() { }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); } + @Test + void getCompasLabels_WhenCalledNullPassed_ThenNoLabelsReturned() { + var value = manager.getCompasLabels(null); + + assertFalse(value.isPresent()); + } + + @Test + void getCompasLabels_WhenCalledWithLabels_ThenLabelsReturned() { + var scl = readSCL("scl_with_compas_private.scd"); + var compasPrivate = manager.getCompasPrivate(scl); + + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertTrue(labels.isPresent()); + assertEquals("Label1", labels.get().getLabel().get(0)); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + + @Test + void getCompasLabels_WhenCalledWithoutLabels_ThenNoLabelsReturned() { + var scl = readSCL("scl_without_labels_compas_private.scd"); + + var compasPrivate = manager.getCompasPrivate(scl); + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertFalse(labels.isPresent()); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + @Test void createCompasPrivate_WhenCalled_ThenNewCompasPrivateReturned() { var compasPrivate = manager.createCompasPrivate(); diff --git a/scl2007b/src/test/resources/scl/scl_with_compas_private.scd b/scl2007b/src/test/resources/scl/scl_with_compas_private.scd index 80340ee..830687c 100644 --- a/scl2007b/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_with_compas_private.scd @@ -1,10 +1,14 @@ - + - project - CID + project + CID + + Label1 +
\ No newline at end of file diff --git a/scl2007b/src/test/resources/scl/scl_without_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_compas_private.scd index 9368462..322db77 100644 --- a/scl2007b/src/test/resources/scl/scl_without_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_without_compas_private.scd @@ -1,6 +1,6 @@ - +
\ No newline at end of file diff --git a/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd index 5f5b238..da144a9 100644 --- a/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -1,9 +1,13 @@ - + - project + project + + Label1 +
\ No newline at end of file diff --git a/scl2007b/src/test/resources/scl/scl_without_labels_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_labels_compas_private.scd new file mode 100644 index 0000000..0126a24 --- /dev/null +++ b/scl2007b/src/test/resources/scl/scl_without_labels_compas_private.scd @@ -0,0 +1,11 @@ + + + + + + project + CID + +
+ \ No newline at end of file diff --git a/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd index 7c6ed90..5b7965d 100644 --- a/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2007b/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -1,9 +1,13 @@ - + - CID + CID + + Label1 +
\ No newline at end of file diff --git a/scl2007b4/src/main/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManager.java b/scl2007b4/src/main/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManager.java index 23fb204..e54da46 100644 --- a/scl2007b4/src/main/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManager.java +++ b/scl2007b4/src/main/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManager.java @@ -6,6 +6,7 @@ import org.lfenergy.compas.scl.extensions.commons.AbstractCompasExtensionsManager; import org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField; import org.lfenergy.compas.scl.extensions.model.SclFileType; +import org.lfenergy.compas.scl.extensions.model.TCompasLabels; import org.lfenergy.compas.scl2007b4.model.SCL; import org.lfenergy.compas.scl2007b4.model.TPrivate; @@ -13,8 +14,7 @@ import java.util.Optional; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.*; public class CompasExtensionsManager extends AbstractCompasExtensionsManager { public Optional getCompasPrivate(SCL scl) { @@ -27,12 +27,16 @@ public Optional getCompasPrivate(SCL scl) { return Optional.empty(); } + public Optional getCompasSclName(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, SCL_NAME, String.class); + } + public Optional getCompasSclFileType(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_FILETYPE_EXTENSION, SclFileType.class); + return getCompasValue(compasPrivate, SCL_FILE_TYPE, SclFileType.class); } - public Optional getCompasSclName(TPrivate compasPrivate) { - return getCompasValue(compasPrivate, SCL_NAME_EXTENSION, String.class); + public Optional getCompasLabels(TPrivate compasPrivate) { + return getCompasValue(compasPrivate, LABELS, TCompasLabels.class); } @SuppressWarnings("rawtypes") diff --git a/scl2007b4/src/test/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManagerTest.java b/scl2007b4/src/test/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManagerTest.java index 28f9a04..b4ea8fb 100644 --- a/scl2007b4/src/test/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManagerTest.java +++ b/scl2007b4/src/test/java/org/lfenergy/compas/scl2007b4/commons/CompasExtensionsManagerTest.java @@ -8,8 +8,8 @@ import static org.junit.jupiter.api.Assertions.*; import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsConstants.COMPAS_SCL_EXTENSION_TYPE; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILETYPE_EXTENSION; -import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME_EXTENSION; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_FILE_TYPE; +import static org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField.SCL_NAME; import static org.lfenergy.compas.scl2007b4.util.ReadTestFile.readSCL; class CompasExtensionsManagerTest { @@ -44,7 +44,7 @@ void getCompasPrivate_WhenCalledWithoutPrivate_ThenNoCompasPrivateReturned() { @Test void getCompasElement_WhenCalledNullPassed_ThenNoNameReturned() { - var compasElement = manager.getCompasElement(null, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(null, SCL_NAME); assertFalse(compasElement.isPresent()); } @@ -55,7 +55,7 @@ void getCompasElement_WhenCalledWithoutSclName_ThenNoSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -67,7 +67,7 @@ void getCompasElement_WhenCalledWithSclName_ThenSclNameReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_NAME_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_NAME); assertTrue(compasElement.isPresent()); assertEquals("project", compasElement.get().getValue().toString()); @@ -80,7 +80,7 @@ void getCompasElement_WhenCalledWithoutFileType_ThenNoFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertFalse(compasElement.isPresent()); }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); @@ -92,7 +92,7 @@ void getCompasElement_WhenCalledWithFileType_ThenFileTypeReturned() { var compasPrivate = manager.getCompasPrivate(scl); compasPrivate.ifPresentOrElse(tPrivate -> { - var compasElement = manager.getCompasElement(tPrivate, SCL_FILETYPE_EXTENSION); + var compasElement = manager.getCompasElement(tPrivate, SCL_FILE_TYPE); assertTrue(compasElement.isPresent()); assertEquals(SclFileType.CID, compasElement.get().getValue()); @@ -163,6 +163,38 @@ void getCompasSclFileType_WhenCalledWithoutType_ThenNoTypeReturned() { }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); } + @Test + void getCompasLabels_WhenCalledNullPassed_ThenNoLabelsReturned() { + var value = manager.getCompasLabels(null); + + assertFalse(value.isPresent()); + } + + @Test + void getCompasLabels_WhenCalledWithLabels_ThenLabelsReturned() { + var scl = readSCL("scl_with_compas_private.scd"); + var compasPrivate = manager.getCompasPrivate(scl); + + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertTrue(labels.isPresent()); + assertEquals("Label1", labels.get().getLabel().get(0)); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + + @Test + void getCompasLabels_WhenCalledWithoutLabels_ThenNoLabelsReturned() { + var scl = readSCL("scl_without_labels_compas_private.scd"); + + var compasPrivate = manager.getCompasPrivate(scl); + compasPrivate.ifPresentOrElse(tPrivate -> { + var labels = manager.getCompasLabels(tPrivate); + + assertFalse(labels.isPresent()); + }, () -> fail(COMPAS_PRIVATE_NOT_FOUND)); + } + @Test void createCompasPrivate_WhenCalled_ThenNewCompasPrivateReturned() { var compasPrivate = manager.createCompasPrivate(); diff --git a/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd index c31cd10..36810f8 100644 --- a/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_with_compas_private.scd @@ -1,10 +1,14 @@ - - - project - CID - -
+ + + project + CID + + Label1 + + +
\ No newline at end of file diff --git a/scl2007b4/src/test/resources/scl/scl_without_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_compas_private.scd index 96f59ae..efa66d0 100644 --- a/scl2007b4/src/test/resources/scl/scl_without_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_without_compas_private.scd @@ -1,6 +1,7 @@ - -
+ +
\ No newline at end of file diff --git a/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd index 1efdd0b..b5d9a34 100644 --- a/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_without_filetype_compas_private.scd @@ -1,9 +1,13 @@ - - - project - -
+ + + project + + Label1 + + +
\ No newline at end of file diff --git a/scl2007b4/src/test/resources/scl/scl_without_labels_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_labels_compas_private.scd new file mode 100644 index 0000000..1fa9d75 --- /dev/null +++ b/scl2007b4/src/test/resources/scl/scl_without_labels_compas_private.scd @@ -0,0 +1,11 @@ + + + + + + project + CID + +
+ \ No newline at end of file diff --git a/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd b/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd index 9d7cfb9..3922c27 100644 --- a/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd +++ b/scl2007b4/src/test/resources/scl/scl_without_sclname_compas_private.scd @@ -1,9 +1,13 @@ - - - CID - -
+ + + CID + + Label1 + + +
\ No newline at end of file