diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java index 94fde9822..ed0f095b9 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java @@ -168,6 +168,19 @@ public static TPrivate createPrivate(List compasTopos) { return tPrivate; } + /** + * Create private of a given type containing a simple string as value + * @param privateType type attribute of private element to create + * @param privateValue value of private to create + * @return the complete private + */ + public static TPrivate createStringPrivate(String privateType, String privateValue) { + TPrivate tPrivate = new TPrivate(); + tPrivate.setType(privateType); + tPrivate.getContent().add(privateValue); + return tPrivate; + } + /** * Create Private of given type as parameter * @param jaxbElement content of Private to create diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java index 4a36049fd..5a9b20954 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java @@ -211,6 +211,18 @@ public static Stream createPrivateTestSources() { new TCompasSystemVersion()); } + @Test + void createStringPrivate_should_return_new_private() { + //GIVEN + String privateType = "COMPAS-LNodeStatus"; + String compasLNodeStatus = "on"; + //WHEN + TPrivate result = PrivateUtils.createStringPrivate(privateType, compasLNodeStatus); + //THEN + assertThat(result.getType()).contains(privateType); + assertThat(result.getContent()).containsExactly(compasLNodeStatus); + } + @Test void removePrivates_should_remove_privates() { // Given : setUp