2 * ============LICENSE_START=======================================================
3 * ONAP Policy Decision Models
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.errors.concepts;
23 import static org.assertj.core.api.Assertions.assertThatCode;
24 import static org.junit.Assert.assertEquals;
26 import java.util.Arrays;
27 import javax.ws.rs.core.Response;
28 import org.junit.Test;
29 import org.onap.policy.common.utils.coder.StandardCoder;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class ErrorResponseTest {
35 public static final Logger logger = LoggerFactory.getLogger(ErrorResponseTest.class);
39 assertThatCode(() -> {
40 ErrorResponse error = new ErrorResponse();
42 error.setResponseCode(Response.Status.NOT_ACCEPTABLE);
43 error.setErrorMessage("Missing metadata section");
45 error.setErrorDetails(Arrays.asList("You must have a metadata section with policy-id value"));
47 error.setWarningDetails(Arrays.asList("Please make sure topology template field is included."));
49 StandardCoder coder = new StandardCoder();
50 String jsonOutput = coder.encode(error);
52 logger.debug("Resulting json output {}", jsonOutput);
54 ErrorResponse deserializedResponse = coder.decode(jsonOutput, ErrorResponse.class);
56 assertEquals(deserializedResponse, error);
57 }).doesNotThrowAnyException();