From ad2fed21351ba36bf3ce93d6f6c001fbd9879dc5 Mon Sep 17 00:00:00 2001 From: JAFFRE Guillaume Date: Tue, 2 Jul 2024 11:30:45 +0200 Subject: [PATCH] feat(400-rsr-1034): Add a private LNodeStatus to the SSD file - create Utils for new String Private creation Signed-off-by: JAFFRE Guillaume --- .../compas/sct/commons/util/PrivateUtils.java | 13 +++++++++++++ .../compas/sct/commons/util/PrivateUtilsTest.java | 12 ++++++++++++ 2 files changed, 25 insertions(+) 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