summaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2020-08-12 13:07:37 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2020-08-14 13:43:09 +0100
commitb9de2097bb3e2cf386d4f6ad765464b55c3442f6 (patch)
tree2ea908c4e2b1b716d36adacd019af546b8eab75d /main/src/test/java/org
parentc7b6db0e0688a6e42279fd85968258e9e880291d (diff)
Changes to make Policy-API container crash with non zero exitCode
Change-Id: I9e46aa87bfefbd56ef0077017293df34b654e36f Issue-ID: POLICY-2755 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
index 90397755..0c4eb4ed 100644
--- a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +23,15 @@
package org.onap.policy.api.main.startstop;
import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
import org.onap.policy.api.main.parameters.CommonTestData;
import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.resources.MessageConstants;
/**
* Class to perform unit test of Main.
@@ -51,15 +54,15 @@ public class TestMain {
@Test
public void testMain_NoArguments() {
final String[] apiConfigParameters = {};
- final Main main = new Main(apiConfigParameters);
- assertNull(main.getParameters());
+ assertThatThrownBy(() -> new Main(apiConfigParameters)).isInstanceOf(PolicyApiRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_API));
}
@Test
public void testMain_InvalidArguments() {
final String[] apiConfigParameters = {"parameters/ApiConfigParameters.json"};
- final Main main = new Main(apiConfigParameters);
- assertNull(main.getParameters());
+ assertThatThrownBy(() -> new Main(apiConfigParameters)).isInstanceOf(PolicyApiRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_API));
}
@Test
@@ -71,7 +74,7 @@ public class TestMain {
@Test
public void testMain_InvalidParameters() {
final String[] apiConfigParameters = {"-c", "parameters/ApiConfigParameters_InvalidName.json"};
- final Main main = new Main(apiConfigParameters);
- assertNull(main.getParameters());
+ assertThatThrownBy(() -> new Main(apiConfigParameters)).isInstanceOf(PolicyApiRuntimeException.class)
+ .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_API));
}
}