2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 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.vid.mso.rest;
23 import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters;
24 import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
25 import static org.hamcrest.CoreMatchers.is;
26 import static org.hamcrest.MatcherAssert.assertThat;
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import com.google.common.collect.ImmutableList;
30 import java.io.IOException;
31 import org.onap.vid.testUtils.TestUtils;
32 import org.testng.annotations.Test;
34 public class TaskTest {
36 private final ObjectMapper mapper = new ObjectMapper();
37 private final String TASK_JSON = ""
39 + " \"taskId\": \"taskId\", "
40 + " \"type\": \"type\", "
41 + " \"nfRole\": \"nfRole\", "
42 + " \"subscriptionServiceType\": \"subscriptionServiceType\", "
43 + " \"originalRequestId\": \"originalRequestId\", "
44 + " \"originalRequestorId\": \"originalRequestorId\", "
45 + " \"buildingBlockName\": \"buildingBlockName\", "
46 + " \"buildingBlockStep\": \"buildingBlockStep\", "
47 + " \"errorSource\": \"errorSource\", "
48 + " \"errorCode\": \"errorCode\", "
49 + " \"errorMessage\": \"errorMessage\", "
50 + " \"validResponses\": [ "
57 private Task newTaskWithPopulatedFields() {
58 Task task = TestUtils.setStringsInStringProperties(new Task());
59 task.setValidResponses(ImmutableList.of("a", "b", "c"));
64 public void shouldHaveProperSettersAndGetters() {
65 assertThat(Task.class, hasValidGettersAndSetters());
69 public void serializeTask() throws IOException {
71 mapper.writeValueAsString(newTaskWithPopulatedFields()),
77 public void deserializeTask() throws IOException {
79 mapper.readValue(TASK_JSON, Task.class),
80 is(newTaskWithPopulatedFields())