From 63abd2e775542aa7439ca8bc24a959794c249d00 Mon Sep 17 00:00:00 2001 From: "m.kowalski3" Date: Mon, 27 May 2019 11:25:34 +0200 Subject: Add unit test for ErrorConfiguration Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski Change-Id: I7e324be0b75238bb782004ac1659d51e2c1f3ffc --- .../sdc/be/config/ErrorConfigurationTest.java | 119 ++++++++++++++------- 1 file changed, 79 insertions(+), 40 deletions(-) (limited to 'common-app-api/src/test/java/org') diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java index d9e6066224..6a45d1a8b7 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ErrorConfigurationTest.java @@ -1,49 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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.be.config; +import static org.junit.Assert.assertEquals; +import java.util.HashMap; import java.util.Map; - import org.junit.Test; public class ErrorConfigurationTest { - private ErrorConfiguration createTestSubject() { - return new ErrorConfiguration(); - } - - - @Test - public void testGetErrors() throws Exception { - ErrorConfiguration testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getErrors(); - } - - - @Test - public void testSetErrors() throws Exception { - ErrorConfiguration testSubject; - Map errors = null; - - // default test - testSubject = createTestSubject(); - testSubject.setErrors(errors); - } - - - - - - @Test - public void testToString() throws Exception { - ErrorConfiguration testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); - } + private ErrorConfiguration createTestSubject() { + return new ErrorConfiguration(); + } + + @Test + public void testGetErrors() throws Exception { + ErrorConfiguration testSubject; + Map result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getErrors(); + } + + + @Test + public void testSetErrors() throws Exception { + ErrorConfiguration testSubject; + Map errors = null; + + // default test + testSubject = createTestSubject(); + testSubject.setErrors(errors); + } + + @Test + public void testToString() throws Exception { + ErrorConfiguration testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.toString(); + } + + @Test + public void testGetErrorInfo() { + //given + Map errors = new HashMap<>(); + ErrorInfo errorInfo = new ErrorInfo(); + errorInfo.setCode(100); + errorInfo.setMessageId("1"); + errorInfo.setMessage("Mock message"); + errors.put("key", errorInfo); + ErrorConfiguration testSubject; + testSubject = createTestSubject(); + testSubject.setErrors(errors); + //when + ErrorInfo clonedErrorInfo = testSubject.getErrorInfo("key"); + //then + assertEquals(errorInfo.getErrorInfoType(), clonedErrorInfo.getErrorInfoType()); + assertEquals(errorInfo.getCode(), clonedErrorInfo.getCode()); + assertEquals(errorInfo.getMessageId(), clonedErrorInfo.getMessageId()); + assertEquals(errorInfo.getMessage(), clonedErrorInfo.getMessage()); + } } \ No newline at end of file -- cgit 1.2.3-korg