increasing test coverage in common-app-api exception catalog 91/94191/4
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Fri, 23 Aug 2019 09:12:50 +0000 (11:12 +0200)
committerTomasz Golabek <tomasz.golabek@nokia.com>
Fri, 23 Aug 2019 13:53:22 +0000 (13:53 +0000)
Issue-ID: SDC-2326
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Change-Id: I0dd6bc60c88acbcf1b3755627a7b10b874a549ba

common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java [new file with mode: 0644]
common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java [new file with mode: 0644]

diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java
new file mode 100644 (file)
index 0000000..3f1eaab
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class DeleteLastApplicationEnvironmentExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        expectedException.expect(DeleteLastApplicationEnvironmentException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new DeleteLastApplicationEnvironmentException(testMessage);
+    }
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(DeleteLastApplicationEnvironmentException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new DeleteLastApplicationEnvironmentException(testMessage, testThrowable);
+    }
+
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java
new file mode 100644 (file)
index 0000000..4952207
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class DeleteReferencedObjectExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        expectedException.expect(DeleteReferencedObjectException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new DeleteReferencedObjectException(testMessage);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java
new file mode 100644 (file)
index 0000000..3fa9d19
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class FunctionalExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() throws Exception {
+        final String testMessage = "test error message";
+        expectedException.expect(FunctionalException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new FunctionalException(testMessage);
+    }
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() throws Exception {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(FunctionalException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new FunctionalException(testMessage, testThrowable);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java
new file mode 100644 (file)
index 0000000..bbca082
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class IndexingServiceExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        expectedException.expect(IndexingServiceException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new IndexingServiceException(testMessage);
+    }
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(IndexingServiceException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new IndexingServiceException(testMessage, testThrowable);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java
new file mode 100644 (file)
index 0000000..c1770a3
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class InvalidArgumentExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        expectedException.expect(InvalidArgumentException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new InvalidArgumentException(testMessage);
+    }
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(InvalidArgumentException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new InvalidArgumentException(testMessage, testThrowable);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java
new file mode 100644 (file)
index 0000000..5086613
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class NotFoundExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateOneArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        expectedException.expect(NotFoundException.class);
+        expectedException.expectMessage(testMessage);
+
+        throw new NotFoundException(testMessage);
+    }
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(NotFoundException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new NotFoundException(testMessage, testThrowable);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java
new file mode 100644 (file)
index 0000000..274dcbf
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+
+public class OkResponseInfoTest {
+
+    @Test
+    public void validateArgConstructorsThrowsCorrectException() {
+        final String testMessageId = "test message id";
+        final String testMessage = "test error message: %0, %1";
+        final String[] testVariables = {"testVariable01", "testVariable02"};
+        final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+        OkResponseInfo okResponseInfo = new OkResponseInfo(testMessageId, testMessage, testVariables);
+        assertEquals(okResponseInfo.getMessageId(),testMessageId);
+        assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+        assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java
new file mode 100644 (file)
index 0000000..2de3335
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class PolicyExceptionTest {
+
+    @Test
+    public void validateNoArgConstructorsThrowsCorrectException() {
+
+        PolicyException okResponseInfo = new PolicyException();
+
+        assertNull(okResponseInfo.getMessageId());
+        assertNull(okResponseInfo.getFormattedErrorMessage());
+        assertNull(okResponseInfo.getVariables());
+
+    }
+
+    @Test
+    public void validateArgConstructorsThrowsCorrectException() {
+        final String testMessageId = "test message id";
+        final String testMessage = "test error message: %0, %1";
+        final String[] testVariables = {"testVariable01", "testVariable02"};
+        final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+        PolicyException okResponseInfo = new PolicyException(testMessageId, testMessage, testVariables);
+        assertEquals(okResponseInfo.getMessageId(),testMessageId);
+        assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+        assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java
new file mode 100644 (file)
index 0000000..a3c9933
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ServiceExceptionTest {
+
+    @Test
+    public void validateNoArgConstructorsThrowsCorrectException() {
+
+        ServiceException okResponseInfo = new ServiceException();
+
+        assertNull(okResponseInfo.getMessageId());
+        assertNull(okResponseInfo.getFormattedErrorMessage());
+        assertNull(okResponseInfo.getVariables());
+
+    }
+
+    @Test
+    public void validateArgConstructorsThrowsCorrectException() {
+        final String testMessageId = "test message id";
+        final String testMessage = "test error message: %0, %1";
+        final String[] testVariables = {"testVariable01", "testVariable02"};
+        final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+        ServiceException okResponseInfo = new ServiceException(testMessageId, testMessage, testVariables);
+        assertEquals(okResponseInfo.getMessageId(),testMessageId);
+        assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+        assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+    }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java
new file mode 100644 (file)
index 0000000..92096e5
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class VersionConflictExceptionTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void validateTwoArgConstructorsThrowsCorrectException() {
+        final String testMessage = "test error message";
+        final String testThrowableMessage = "test throwable";
+        final Throwable testThrowable = new Throwable(testThrowableMessage);
+        expectedException.expect(VersionConflictException.class);
+        expectedException.expectMessage(testMessage);
+        expectedException.expectCause(is(testThrowable));
+
+        throw new VersionConflictException(testMessage, testThrowable);
+    }
+}