Sonar Fixes policy/models, removing model-yaml
[policy/models.git] / models-tosca / src / test / java / org / onap / policy / models / tosca / simple / concepts / JpaToscaModelTest.java
index 839f0f8..61118c4 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2020 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. 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.
@@ -24,12 +24,12 @@ package org.onap.policy.models.tosca.simple.concepts;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Map;
 import java.util.TreeMap;
-
 import org.junit.Test;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfModelService;
@@ -42,7 +42,7 @@ import org.onap.policy.models.base.PfValidationResult;
  */
 public class JpaToscaModelTest {
 
-    private static final String KEY_IS_NULL = "key is marked @NonNull but is null";
+    private static final String KEY_IS_NULL = "key is marked .*on.*ull but is null";
     private static final String VERSION_001 = "0.0.1";
 
     @Test
@@ -52,17 +52,18 @@ public class JpaToscaModelTest {
         assertNotNull(new JpaToscaModel(new PfConceptKey(), new JpaToscaServiceTemplates()));
         assertNotNull(new JpaToscaModel(new JpaToscaModel()));
 
-        assertThatThrownBy(() -> new JpaToscaModel((PfConceptKey) null)).hasMessage(KEY_IS_NULL);
+        assertThatThrownBy(() -> new JpaToscaModel((PfConceptKey) null)).hasMessageMatching(KEY_IS_NULL);
 
-        assertThatThrownBy(() -> new JpaToscaModel(null, null)).hasMessage(KEY_IS_NULL);
+        assertThatThrownBy(() -> new JpaToscaModel(null, null)).hasMessageMatching(KEY_IS_NULL);
 
-        assertThatThrownBy(() -> new JpaToscaModel(null, new JpaToscaServiceTemplates())).hasMessage(KEY_IS_NULL);
+        assertThatThrownBy(() -> new JpaToscaModel(null, new JpaToscaServiceTemplates()))
+                .hasMessageMatching(KEY_IS_NULL);
 
         assertThatThrownBy(() -> new JpaToscaModel(new PfConceptKey(), null))
-                .hasMessage("serviceTemplates is marked @NonNull but is null");
+                .hasMessageMatching("serviceTemplates is marked .*on.*ull but is null");
 
         assertThatThrownBy(() -> new JpaToscaModel((JpaToscaModel) null))
-                .hasMessage("copyConcept is marked @NonNull but is null");
+                .hasMessageMatching("copyConcept is marked .*on.*ull but is null");
 
         PfConceptKey tstsKey = new PfConceptKey("tsts", VERSION_001);
         Map<PfConceptKey, JpaToscaServiceTemplate> tstMap = new TreeMap<>();
@@ -80,14 +81,14 @@ public class JpaToscaModelTest {
 
         assertEquals(-1, tm.compareTo(null));
         assertEquals(0, tm.compareTo(tm));
-        assertFalse(tm.compareTo(tm.getKey()) == 0);
+        assertNotEquals(0, tm.compareTo(tm.getKey()));
 
         PfConceptKey otherDtKey = new PfConceptKey("otherDt", VERSION_001);
         JpaToscaModel otherDt = new JpaToscaModel(otherDtKey);
 
-        assertFalse(tm.compareTo(otherDt) == 0);
+        assertNotEquals(0, tm.compareTo(otherDt));
         otherDt.setKey(tmKey);
-        assertFalse(tm.compareTo(otherDt) == 0);
+        assertNotEquals(0, tm.compareTo(otherDt));
         otherDt.setServiceTemplates(tsts);
         assertEquals(0, tm.compareTo(otherDt));
 
@@ -107,6 +108,6 @@ public class JpaToscaModelTest {
         assertTrue(PfModelService.existsModel(tm.getServiceTemplates().getId()));
         PfModelService.deregisterModel(tm.getServiceTemplates().getId());
 
-        assertThatThrownBy(() -> tm.validate(null)).hasMessage("resultIn is marked @NonNull but is null");
+        assertThatThrownBy(() -> tm.validate(null)).hasMessageMatching("resultIn is marked .*on.*ull but is null");
     }
 }