summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/test
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2022-05-06 09:07:20 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2022-05-06 09:07:20 +0800
commitb1cf3bb5648e23c65d78a808d8185d44d0727b1c (patch)
tree2d794c16a70dfbd4dcf8f4746fe5949d37e082ed /holmes-actions/src/test
parent18166c0e75d5c8ca11eb7ea7c875ef03c7d74749 (diff)
Optimized retry in the exception branch
Missed a conditional branch before, now fixed that. Issue-ID: HOLMES-536 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn> Change-Id: I682d31e14b30d1fbeb903760ae0788a25806d9b0
Diffstat (limited to 'holmes-actions/src/test')
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/MsbRegisterTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/MsbRegisterTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/MsbRegisterTest.java
index 0201935..828fe0c 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/MsbRegisterTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/MsbRegisterTest.java
@@ -118,4 +118,39 @@ public class MsbRegisterTest {
PowerMock.verifyAll();
}
+
+ @Test
+ public void test_register2Msb_fail_n_times_due_to_exception() {
+ int requestTimes = 3;
+ expect(mockedJerseyClient.header("Accept", MediaType.APPLICATION_JSON)).andReturn(mockedJerseyClient).times(requestTimes);
+ expect(mockedJerseyClient.queryParam("createOrUpdate", true)).andReturn(mockedJerseyClient).times(requestTimes);
+ expect(mockedJerseyClient.post(anyObject(String.class),
+ anyObject(Entity.class),
+ anyObject(Class.class)))
+ .andThrow(new RuntimeException("Failure!")).times(requestTimes - 1);
+
+ expect(mockedJerseyClient.post(anyObject(String.class),
+ anyObject(Entity.class),
+ anyObject(Class.class)))
+ .andReturn(GsonUtil.jsonToBean("{\"serviceName\":\"holmes-engine-mgmt\"," +
+ "\"version\":\"v1\",\"url\":\"/api/holmes-engine-mgmt/v1\",\"protocol\":\"REST\"," +
+ "\"visualRange\":\"0|1\",\"lb_policy\":\"\",\"publish_port\":\"\",\"namespace\":\"\"," +
+ "\"network_plane_type\":\"\",\"host\":\"\",\"path\":\"/api/holmes-engine-mgmt/v1\"," +
+ "\"enable_ssl\":true,\"nodes\":[{\"ip\":\"127.0.0.1\",\"port\":\"9102\",\"checkType\":\"\"," +
+ "\"checkUrl\":\"\",\"tls_skip_verify\":true,\"ha_role\":\"\",\"nodeId\":\"_v1_holmes-engine-mgmt_127.0.0.1_9102\"," +
+ "\"status\":\"passing\"}],\"metadata\":[],\"labels\":[],\"status\":\"1\",\"is_manual\":false}",
+ MicroServiceFullInfo.class));
+
+ PowerMock.replayAll();
+
+ MsbRegister msbRegister = new MsbRegister();
+ msbRegister.setInterval(1);
+ try {
+ msbRegister.register2Msb(msi);
+ } catch (CorrelationException e) {
+ // Do nothing
+ }
+
+ PowerMock.verifyAll();
+ }
} \ No newline at end of file