From 50daaac12878c4acd2a5d38e8964f293db02f674 Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Tue, 1 Sep 2020 06:41:16 +0200 Subject: Fixing instable test The testcase in question should wait util the available so that the data synchronization does not iterfere. Change-Id: I152bb5db25cb7d55a0c677595027ef72577f84c0 Issue-ID: CCSDK-2502 Signed-off-by: PatrikBuhr --- .../controllers/v2/ApplicationTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'a1-policy-management/src/test') diff --git a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java index 5ef70aa9..243ded43 100644 --- a/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java +++ b/a1-policy-management/src/test/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ApplicationTest.java @@ -253,9 +253,9 @@ class ApplicationTest { supervision.checkAllRics(); // The created policy should be put in the RIC // Wait until synch is completed - await().untilAsserted(() -> RicState.SYNCHRONIZING.equals(rics.getRic(ric1Name).getState())); - await().untilAsserted(() -> RicState.AVAILABLE.equals(rics.getRic(ric1Name).getState())); - await().untilAsserted(() -> RicState.AVAILABLE.equals(rics.getRic("ric2").getState())); + waitForRicState(ric1Name, RicState.SYNCHRONIZING); + waitForRicState(ric1Name, RicState.AVAILABLE); + waitForRicState("ric2", RicState.AVAILABLE); Policies ricPolicies = getA1Client(ric1Name).getPolicies(); assertThat(ricPolicies.size()).isEqualTo(1); @@ -466,6 +466,9 @@ class ApplicationTest { addPolicyType("type1", "ric1"); addPolicyType("type2", "ric2"); + waitForRicState("ric1", RicState.AVAILABLE); + waitForRicState("ric2", RicState.AVAILABLE); + String url = "/policy-schemas"; String rsp = this.restClient().get(url).block(); assertThat(rsp).contains("type1") // @@ -804,6 +807,11 @@ class ApplicationTest { .verify(); } + private void waitForRicState(String ricId, RicState state) throws ServiceException { + Ric ric = rics.getRic(ricId); + await().untilAsserted(() -> state.equals(ric.getState())); + } + private boolean checkWebClientError(Throwable throwable, HttpStatus expStatus, String responseContains, boolean expectApplicationProblemJsonMediaType) { assertTrue(throwable instanceof WebClientResponseException); -- cgit 1.2.3-korg