2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.so.client.sdnc.lcm.beans.payload;
 
  23 import java.util.Collections;
 
  24 import org.junit.Test;
 
  25 import static org.junit.Assert.assertEquals;
 
  26 import static org.junit.Assert.fail;
 
  28 public class DownloadNESwPayloadTest extends LcmBasePayloadTest {
 
  29     private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\","
 
  30             + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}";
 
  32     private static String expectedDownloadNESwPayload =
 
  33             "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\","
 
  34                     + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}";
 
  36     public SwToBeDownloadedElement buildSwToBeDownloadedElement() {
 
  37         SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement();
 
  39         swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip");
 
  40         swToBeDownloadedElement.setSwFileSize(123456);
 
  41         swToBeDownloadedElement.setSwFileCompression("ZIP");
 
  42         swToBeDownloadedElement.setSwFileFormat("binary");
 
  44         return swToBeDownloadedElement;
 
  47     public DownloadNESwPayload buildDownloadNESwPayload() {
 
  48         DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload();
 
  50         downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
 
  51         downloadNESwPayload.setPlaybookName(playbookName);
 
  53         SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement();
 
  54         downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement));
 
  56         return downloadNESwPayload;
 
  60     public final void testSwToBeDownloadedElement() {
 
  61         SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement();
 
  64             String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement);
 
  65             assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString);
 
  66         } catch (Exception e) {
 
  67             fail("Convert SwToBeDownloadedElement to String error: " + e.toString());
 
  72     public final void testDownloadNESwPayload() {
 
  73         DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload();
 
  76             String downloadNESwPayloadString = convertToSting(downloadNESwPayload);
 
  77             assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString);
 
  78         } catch (Exception e) {
 
  79             fail("Convert DownloadNESwPayload to String error: " + e.toString());