2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
  22  * ============LICENSE_END=========================================================
 
  25 package org.onap.appc.artifact.handler.utils;
 
  27 import static org.junit.Assert.assertTrue;
 
  28 import java.nio.charset.Charset;
 
  29 import org.apache.commons.io.IOUtils;
 
  30 import org.json.JSONObject;
 
  31 import org.junit.Test;
 
  32 import org.powermock.reflect.Whitebox;
 
  34 public class ArtifactHandlerProviderUtilTest {
 
  36     @Test(expected = Exception.class)
 
  37     public void testProcessTemplate() throws Exception {
 
  38         String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
 
  39                 .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
 
  40         JSONObject obj = new JSONObject();
 
  41         obj.put("artifact-name", "reference_JunitTestArtifact");
 
  42         obj.put("artifact-version", "0.01");
 
  43         obj.put("artifact-contents", artifact_conetent);
 
  44         ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
 
  45         ahprovider.processTemplate(obj.toString());
 
  48     @Test(expected = Exception.class)
 
  49     public void testcreateDummyRequestData() throws Exception {
 
  50         String artifact_conetent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
 
  51                 .getResourceAsStream("templates/reference_template.json"), Charset.defaultCharset());
 
  52         JSONObject obj = new JSONObject();
 
  53         obj.put("artifact-name", "reference_JunitTestArtifact");
 
  54         obj.put("artifact-version", "0.01");
 
  55         obj.put("artifact-contents", artifact_conetent);
 
  56         ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
 
  57         String requestInfo = ahprovider.createDummyRequestData();
 
  61     public void testEscapeSql() throws Exception {
 
  62         String testStr = "Test String is 'test'";
 
  63         ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
 
  64         ahprovider.escapeSql(testStr);
 
  69     public void testGetRandom() throws Exception {
 
  70         ArtifactHandlerProviderUtil ahprovider = new ArtifactHandlerProviderUtil();
 
  71         Whitebox.invokeMethod(ahprovider, "getRandom");
 
  76     public void testEscapeUtils() throws Exception {
 
  77         String str = "The Test string is 'test'";
 
  78         EscapeUtils.escapeSql(str);