Changes for Checkstyle 8.32
[policy/models.git] / models-tosca / src / test / java / org / onap / policy / models / tosca / simple / concepts / JpaToscaModelTest.java
index 40fbc05..51a5d3c 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Copyright (C) 2019-2020 Nordix Foundation.
  *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,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
@@ -51,17 +51,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<>();
@@ -73,8 +74,7 @@ public class JpaToscaModelTest {
         assertEquals(tm, tttClone0);
         assertEquals(0, tm.compareTo(tttClone0));
 
-        JpaToscaModel tttClone1 = new JpaToscaModel();
-        tm.copyTo(tttClone1);
+        JpaToscaModel tttClone1 = new JpaToscaModel(tm);
         assertEquals(tm, tttClone1);
         assertEquals(0, tm.compareTo(tttClone1));
 
@@ -91,7 +91,7 @@ public class JpaToscaModelTest {
         otherDt.setServiceTemplates(tsts);
         assertEquals(0, tm.compareTo(otherDt));
 
-        assertThatThrownBy(() -> tm.copyTo(null)).hasMessage("targetObject is marked @NonNull but is null");
+        assertThatThrownBy(() -> new JpaToscaModel((JpaToscaModel) null)).isInstanceOf(NullPointerException.class);
 
         assertEquals(2, tm.getKeys().size());
         assertEquals(2, new JpaToscaModel().getKeys().size());
@@ -101,12 +101,12 @@ public class JpaToscaModelTest {
         assertEquals(tttClone0, tm);
 
         assertFalse(new JpaToscaModel().validate(new PfValidationResult()).isValid());
-        assertFalse(tm.validate(new PfValidationResult()).isValid());
+        assertTrue(tm.validate(new PfValidationResult()).isValid());
 
         tm.register();
         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");
     }
 }