summaryrefslogtreecommitdiffstats
path: root/model/model-api/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'model/model-api/src/test')
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java31
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java27
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java22
3 files changed, 25 insertions, 55 deletions
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index e7330ee47..02195e4db 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
@@ -21,11 +21,10 @@
package org.onap.policy.apex.model.modelapi;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
@@ -144,24 +143,13 @@ public class ApexModelApiTest {
@Test
public void testApexModelUrl() throws IOException {
- ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
-
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ //ApexApiResult result = null;
+ assertThatThrownBy(() -> apexModel.readFromUrl(null))
+ .isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> apexModel.writeToUrl(null, true))
+ .isInstanceOf(IllegalArgumentException.class);
ApexApiResult result = null;
-
- try {
- result = apexModel.readFromUrl(null);
- fail("expecting an IllegalArgumentException");
- } catch (final Exception e) {
- assertTrue(e instanceof IllegalArgumentException);
- }
-
- try {
- result = apexModel.writeToUrl(null, true);
- fail("expecting an IllegalArgumentException");
- } catch (final Exception e) {
- assertTrue(e instanceof IllegalArgumentException);
- }
-
result = apexModel.readFromUrl("zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -174,9 +162,10 @@ public class ApexModelApiTest {
result = apexModel.writeToUrl("zooby://zooby/looby", false);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModelJSon = new ApexModelFactory().createApexModel(null, false);
final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json");
+
result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
index ac8f26095..a5f258e4c 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
@@ -1,28 +1,29 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.modelapi;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import java.util.Properties;
import java.util.UUID;
@@ -33,22 +34,12 @@ public class ModelFacadeTest {
@Test
public void testModelFacade() {
- try {
- new ModelFacade(null, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexModel may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelFacade(null, null, false))
+ .hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
- try {
- new ModelFacade(apexModel, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexProperties may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelFacade(apexModel, null, false))
+ .hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
final ModelFacade mf = new ModelFacade(apexModel, modelProperties, false);
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
index a34b4f474..4a1c3276c 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
@@ -21,9 +21,9 @@
package org.onap.policy.apex.model.modelapi;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
@@ -35,29 +35,19 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* Test the model handler facade.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ModelHandlerFacadeTest {
@Test
public void testModelHandlerFacade() throws IOException {
- try {
- new ModelHandlerFacade(null, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexModel may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelHandlerFacade(null, null, false))
+ .hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
- try {
- new ModelHandlerFacade(apexModel, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexProperties may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelHandlerFacade(apexModel, null, false))
+ .hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties, false);
assertNotNull(mhf);