Code Review
/
policy
/
models.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix Sonar Issues on policy-models-tosca
[policy/models.git]
/
models-tosca
/
src
/
test
/
java
/
org
/
onap
/
policy
/
models
/
tosca
/
simple
/
concepts
/
JpaToscaDataTypeTest.java
diff --git
a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
index
44bc534
..
7399fdc
100644
(file)
--- a/
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
+++ b/
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypeTest.java
@@
-1,6
+1,6
@@
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-202
0
Nordix Foundation.
+ * Copyright (C) 2019-202
1
Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@
-61,7
+61,10
@@
public class JpaToscaDataTypeTest {
assertThatThrownBy(() -> new JpaToscaDataType((JpaToscaDataType) null))
.isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> new JpaToscaDataType((JpaToscaDataType) null))
.isInstanceOf(NullPointerException.class);
+ }
+ @Test
+ public void testDataTypeProperties() {
PfConceptKey dtKey = new PfConceptKey("tdt", VERSION_001);
JpaToscaDataType tdt = new JpaToscaDataType(dtKey);
PfConceptKey dtKey = new PfConceptKey("tdt", VERSION_001);
JpaToscaDataType tdt = new JpaToscaDataType(dtKey);
@@
-109,6
+112,14
@@
public class JpaToscaDataTypeTest {
assertEquals(tdtClone0, tdt);
assertFalse(new JpaToscaDataType().validate("").isValid());
assertEquals(tdtClone0, tdt);
assertFalse(new JpaToscaDataType().validate("").isValid());
+ validateJpaToscaDataTypeOperations(tdt);
+
+ assertThatThrownBy(() -> {
+ tdt.validate(null);
+ }).hasMessageMatching("fieldName is marked .*on.*ull but is null");
+ }
+
+ private void validateJpaToscaDataTypeOperations(JpaToscaDataType tdt) {
assertTrue(tdt.validate("").isValid());
tdt.getConstraints().add(null);
assertTrue(tdt.validate("").isValid());
tdt.getConstraints().add(null);
@@
-120,11
+131,10
@@
public class JpaToscaDataTypeTest {
assertFalse(tdt.validate("").isValid());
tdt.getProperties().remove(null);
assertTrue(tdt.validate("").isValid());
assertFalse(tdt.validate("").isValid());
tdt.getProperties().remove(null);
assertTrue(tdt.validate("").isValid());
+ }
- assertThatThrownBy(() -> {
- tdt.validate(null);
- }).hasMessageMatching("fieldName is marked .*on.*ull but is null");
-
+ @Test
+ public void testDataTypeConstraints() {
ToscaDataType dat = new ToscaDataType();
dat.setName("name");
dat.setVersion("1.2.3");
ToscaDataType dat = new ToscaDataType();
dat.setName("name");
dat.setVersion("1.2.3");