2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright © 2017-2018 Amdocs
\r
7 * ================================================================================
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
19 * ============LICENSE_END=========================================================
\r
21 package org.onap.aai.datarouter.service;
\r
23 import static org.junit.Assert.assertEquals;
\r
25 import java.io.File;
\r
26 import java.io.FileInputStream;
\r
27 import java.util.ArrayList;
\r
28 import java.util.List;
\r
29 import org.apache.commons.io.IOUtils;
\r
30 import org.junit.Before;
\r
31 import org.junit.Test;
\r
32 import org.onap.aai.datarouter.entity.POAAuditEvent;
\r
33 import org.onap.aai.datarouter.entity.POAServiceInstanceEntity;
\r
36 public class AuditServiceTest {
\r
38 private String eventJson;
\r
42 public void init() throws Exception {
\r
43 FileInputStream event = new FileInputStream( new File("src/test/resources/poa_event.json"));
\r
44 eventJson = IOUtils.toString(event, "UTF-8");
\r
48 public void testPOAEvent() throws Exception {
\r
50 POAAuditEvent auditEvent = POAAuditEvent.fromJson(eventJson);
\r
52 List<String> eventMessages = new ArrayList<String>();
\r
53 for (POAServiceInstanceEntity serviceInstance: auditEvent.getServiceInstanceList()) {
\r
54 serviceInstance.validate();
\r
55 serviceInstance.setxFromAppId("data-router");
\r
56 serviceInstance.setxTransactionId("111222888");
\r
57 eventMessages.add(serviceInstance.toJson());
\r
60 assertEquals(2, eventMessages.size());
\r