2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Copyright (C) 2017 Amdocs
 
   8  * =============================================================================
 
   9  * Modifications Copyright (C) 2018 IBM
 
  10  * =============================================================================
 
  11  * Licensed under the Apache License, Version 2.0 (the "License");
 
  12  * you may not use this file except in compliance with the License.
 
  13  * You may obtain a copy of the License at
 
  15  *      http://www.apache.org/licenses/LICENSE-2.0
 
  17  * Unless required by applicable law or agreed to in writing, software
 
  18  * distributed under the License is distributed on an "AS IS" BASIS,
 
  19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  20  * See the License for the specific language governing permissions and
 
  21  * limitations under the License.
 
  23  * ============LICENSE_END=========================================================
 
  26 package org.onap.sdnc.config.audit.node;
 
  28 import java.util.HashMap;
 
  30 import org.junit.Before;
 
  31 import org.junit.Test;
 
  32 import org.onap.sdnc.config.audit.node.CompareNode;
 
  33 import org.slf4j.Logger;
 
  34 import org.slf4j.LoggerFactory;
 
  36 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  37 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
  38 import static org.junit.Assert.assertEquals;
 
  40 public class TestCompareNodeCli {
 
  41     private static final Logger log = LoggerFactory.getLogger(TestCompareNodeCli.class);
 
  42     private CompareNode cmp;
 
  44     HashMap<String, String> testMap;
 
  50         cmp = new CompareNode();
 
  51         ctx = new SvcLogicContext();
 
  52         testMap = new HashMap<String, String>();
 
  56     public void TestCompareCliForSamePayload() throws SvcLogicException {
 
  57         testMap.put("compareDataType", "Cli");
 
  58         testMap.put("sourceData", "This is a Text Configuration of Device");
 
  59         testMap.put("targetData", "This is a Text Configuration of Device");
 
  60         cmp.compare(testMap, ctx);
 
  61         assert (ctx.getAttribute("STATUS").equals("SUCCESS"));
 
  65     public void TestCompareCliForNoPayload() throws SvcLogicException {
 
  66         testMap.put("compareDataType", "Cli");
 
  67         cmp.compare(testMap, ctx);
 
  68         assertEquals ("FAILURE",ctx.getAttribute("STATUS"));
 
  72     public void TestCompareCliFordifferentPayload() throws SvcLogicException {
 
  73         testMap.put("compareDataType", "Cli");
 
  74         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
 
  75         testMap.put("targetData", "This is a Text Configuration of Device");
 
  76         cmp.compare(testMap, ctx);
 
  77         assert (ctx.getAttribute("STATUS").equals("FAILURE"));
 
  81     public void TestCompareForMissingInput() throws SvcLogicException {
 
  82         testMap.put("sourceData", "This is a Text Negative test Configuration of Device");
 
  83         testMap.put("targetData.configuration-data", "This is a Text Configuration of Device");
 
  84         cmp.compare(testMap, ctx);
 
  85         assert (ctx.getAttribute("STATUS").equals("FAILURE"));