2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.sdnc.config.audit.node;
26 import java.io.IOException;
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32 import com.fasterxml.jackson.core.JsonParseException;
33 import com.fasterxml.jackson.databind.JsonMappingException;
34 import com.fasterxml.jackson.databind.ObjectMapper;
37 public class CompareJsonData implements CompareDataInterface {
39 private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareJsonData.class);
44 public CompareJsonData(String payloadX, String payloadY)
46 this.payloadX = payloadX;
47 this.payloadY = payloadY;
51 public boolean compare() throws Exception
54 ObjectMapper dataMapper = new ObjectMapper();
55 boolean match = false;
58 Map<String, Object> controlData = (Map<String, Object>)(dataMapper.readValue(payloadX, Map.class));
59 Map<String, Object> testData = (Map<String, Object>)(dataMapper.readValue(payloadY, Map.class));
61 log.debug("Control Data :" + controlData);
62 log.debug("testData Data :" + testData);
64 if(controlData.equals(testData))
67 catch(JsonParseException e)
69 throw new Exception(e.getMessage());
71 catch(JsonMappingException e)
73 throw new Exception(e.getMessage());
75 catch(IOException ioe)
77 throw new Exception(ioe.getMessage());