diff options
Diffstat (limited to 'rest-services/cbs-client/src/test')
3 files changed, 43 insertions, 42 deletions
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/ListenableCbsConfigTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/ListenableCbsConfigTest.java index b3ef1bd5..7546774b 100644 --- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/ListenableCbsConfigTest.java +++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/ListenableCbsConfigTest.java @@ -44,7 +44,7 @@ class ListenableCbsConfigTest { cut.listen(List.of("some-key"), subtreeOption -> actualChanges.updateAndGet( - changes -> changes.append(subtreeOption.flatMap(subtree -> subtree.get()).getOrElse("[None]"))) + changes -> changes.append(subtreeOption.flatMap(subtree -> subtree.get(List.empty())).getOrElse("[None]"))) ); @@ -75,7 +75,7 @@ class ListenableCbsConfigTest { cut.subtreeChanges(List.of("some-key")) .map(subtreeOption -> - subtreeOption.flatMap(subtree -> subtree.get()).getOrElse("[None]") + subtreeOption.flatMap(subtree -> subtree.get(List.empty())).getOrElse("[None]") ) .subscribe(replayProcessor); @@ -105,7 +105,7 @@ class ListenableCbsConfigTest { cut.subtreeChanges(List.of("streams", "publishes")) .map(subtreeOption -> - subtreeOption.flatMap(subtree -> subtree.get("topic1", "dmaap-url")).getOrElse("[None]") + subtreeOption.flatMap(subtree -> subtree.get(List.of("topic1", "dmaap-url"))).getOrElse("[None]") ) .subscribe(actualChanges); diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeParserTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeParserTest.java index 080f8097..c9ceeaf1 100644 --- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeParserTest.java +++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeParserTest.java @@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.listener; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import io.vavr.collection.List; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; @@ -39,8 +40,7 @@ class MerkleTreeParserTest { JsonObject jsonObject = new JsonObject(); MerkleTree<String> tree = cut.fromJsonObject(jsonObject); - - assertThat(tree.isSame(emptyTree())).isTrue(); + assertThat(tree.isSame(List.empty(), emptyTree())).isTrue(); } @Test @@ -51,7 +51,7 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("v1", "p1"); + .add(List.of("p1"), "v1"); assertThat(tree).isEqualTo(expected); } @@ -67,7 +67,7 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("v1", "p1", "p2", "p3"); + .add(List.of("p1", "p2", "p3"), "v1"); assertThat(tree).isEqualTo(expected); } @@ -82,8 +82,8 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("vA", "p1", "A") - .add("vB", "p1", "B"); + .add(List.of("p1", "A"), "vA") + .add(List.of("p1", "B"), "vB"); assertThat(tree).isEqualTo(expected); } @@ -100,8 +100,8 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("v1", "p1", "0") - .add("v2", "p1", "1", "p2"); + .add(List.of("p1", "0"), "v1") + .add(List.of("p1", "1", "p2"), "v2"); assertThat(tree).isEqualTo(expected); } @@ -123,10 +123,10 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("v1", "p1") - .add("v2", "p2", "0") - .add("v3", "p2", "1") - .add("v4", "p3", "p4"); + .add(List.of("p1"), "v1") + .add(List.of("p2", "0"), "v2") + .add(List.of("p2", "1"), "v3") + .add(List.of("p3", "p4"), "v4"); assertThat(tree).isEqualTo(expected); } @@ -144,11 +144,11 @@ class MerkleTreeParserTest { MerkleTree<String> tree = cut.fromJsonObject(jsonObject); MerkleTree<String> expected = emptyTree() - .add("1", "p1", "0") - .add("2", "p1", "1") - .add("3.0", "p1", "2") - .add("true", "p1", "3") - .add("999799799799799", "p1", "4"); + .add(List.of("p1", "0"), "1") + .add(List.of("p1", "1"), "2") + .add(List.of("p1", "2"), "3.0") + .add(List.of("p1", "3"), "true") + .add(List.of("p1", "4"), "999799799799799"); assertThat(tree).isEqualTo(expected); } diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeTest.java index dee1150e..1077ee60 100644 --- a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeTest.java +++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/listener/MerkleTreeTest.java @@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.listener; import static org.assertj.core.api.Assertions.assertThat; +import io.vavr.collection.List; import org.junit.jupiter.api.Test; /** @@ -33,38 +34,38 @@ class MerkleTreeTest { @Test void shouldBeAbleToGetEntries() { MerkleTree<String> cut = emptyTree() - .add("value1", "ala", "ma", "kota") - .add("value2", "ala", "ma", "psa"); + .add(List.of("ala","ma", "kota"), "value1") + .add(List.of("ala", "ma", "psa"),"value2"); - assertThat(cut.get("ala", "ma", "kota")).contains("value1"); - assertThat(cut.get("ala", "ma", "psa")).contains("value2"); + assertThat(cut.get(List.of("ala", "ma", "kota"))).contains("value1"); + assertThat(cut.get(List.of("ala", "ma", "psa"))).contains("value2"); } @Test void shouldReturnNoneForNonExistingPaths() { MerkleTree<String> cut = emptyTree() - .add("value1", "ala", "ma", "kota") - .add("value2", "ala", "ma", "psa"); + .add(List.of("ala", "ma", "kota"), "value1") + .add(List.of("ala", "ma", "psa"),"value2"); - assertThat(cut.get("ala", "je", "obiad")).isEmpty(); + assertThat(cut.get(List.of("ala", "je", "obiad"))).isEmpty(); } @Test void shouldReturnNoneWhenNodeDoesntContainValue() { MerkleTree<String> cut = emptyTree() - .add("value1", "ala", "ma", "kota") - .add("value2", "ala", "ma", "psa"); + .add(List.of("ala", "ma", "kota"),"value1") + .add(List.of("ala", "ma", "psa"), "value2"); - assertThat(cut.get("ala", "ma")).isEmpty(); + assertThat(cut.get(List.of("ala", "ma"))).isEmpty(); } @Test void shouldNotCreateNewObjectWhenNothingChanged() { MerkleTree<String> cut = emptyTree() - .add("some value", "ala", "ma", "kota"); + .add(List.of("ala", "ma", "kota"), "some value"); - final MerkleTree<String> result = cut.add("some value", "ala", "ma", "kota"); + final MerkleTree<String> result = cut.add(List.of("ala", "ma", "kota"),"some value"); assertThat(result).isSameAs(cut); } @@ -72,21 +73,21 @@ class MerkleTreeTest { @Test void shouldRecalculateHashesAfterAddingNewNode() { MerkleTree<String> cut = emptyTree() - .add("value1", "ala", "ma", "kota") - .add("value2", "ala", "ma", "psa") - .add("value3", "ala", "name"); + .add(List.of("ala", "ma", "kota"), "value1") + .add(List.of("ala", "ma", "psa"), "value2") + .add(List.of("ala", "name"), "value3"); - final MerkleTree<String> modified = cut.add("value4", "ala", "surname"); + final MerkleTree<String> modified = cut.add(List.of("ala", "surname"), "value4"); assertThat(modified).isNotSameAs(cut); - assertThat(modified.hashOf("ala", "ma")).isEqualTo(cut.hashOf("ala", "ma")); - assertThat(modified.hashOf("ala", "ma", "kota")).isEqualTo(cut.hashOf("ala", "ma", "kota")); - assertThat(modified.hashOf("ala", "ma", "psa")).isEqualTo(cut.hashOf("ala", "ma", "psa")); - assertThat(modified.hashOf("ala", "name")).isEqualTo(cut.hashOf("ala", "name")); + assertThat(modified.hashOf(List.of("ala", "ma"))).isEqualTo(cut.hashOf(List.of("ala", "ma"))); + assertThat(modified.hashOf(List.of("ala", "ma", "kota"))).isEqualTo(cut.hashOf(List.of("ala", "ma", "kota"))); + assertThat(modified.hashOf(List.of("ala", "ma", "psa"))).isEqualTo(cut.hashOf(List.of("ala", "ma", "psa"))); + assertThat(modified.hashOf(List.of("ala", "name"))).isEqualTo(cut.hashOf(List.of("ala", "name"))); - assertThat(modified.hashOf("ala", "surname")).isNotEqualTo(cut.hashOf("ala", "surname")); - assertThat(modified.hashOf("ala")).isNotEqualTo(cut.hashOf("ala")); + assertThat(modified.hashOf(List.of("ala", "surname"))).isNotEqualTo(cut.hashOf(List.of("ala", "surname"))); + assertThat(modified.hashOf(List.of("ala"))).isNotEqualTo(cut.hashOf(List.of("ala"))); assertThat(modified.hash()).isNotEqualTo(cut.hash()); } |