/*
 *
 *   Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *   WSO2 Inc. licenses this file to you under the Apache License,
 *   Version 2.0 (the "License"); you may not use this file except
 *   in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 *
 */

package org.wso2.carbon.apimgt.impl.utils;

import org.junit.Assert;
import org.junit.Test;

public class APIUtilTest {

    @Test
    public void testGetAPINamefromRESTAPI() {
        String restAPI = "admin--map";
        String apiName = APIUtil.getAPINamefromRESTAPI(restAPI);

        Assert.assertEquals(apiName, "map");
    }

    @Test
    public void testGetAPIProviderFromRESTAPI() {
        String restAPI = "admin--map";
        String providerName = APIUtil.getAPIProviderFromRESTAPI(restAPI, null);

        Assert.assertEquals(providerName, "admin@carbon.super");

        restAPI = "user@test.com--map";
        providerName = APIUtil.getAPIProviderFromRESTAPI(restAPI, "test.com");
        Assert.assertEquals(providerName, "user@test.com");

        restAPI = "user-AT-test.com--map";
        providerName = APIUtil.getAPIProviderFromRESTAPI(restAPI, "test.com");
        Assert.assertEquals(providerName, "user@test.com");

    }
}

@@ -735,16 +735,101 @@
 utils;%0A%0A
+import org.apache.http.client.HttpClient;%0Aimport org.apache.http.conn.scheme.Scheme;%0A
 import o
@@ -1715,20 +1715,1279 @@
 est.com%22);%0A%0A
+    %7D%0A%0A    @Test%0A    public void testGetHttpClient() %7B%0A        HttpClient client = APIUtil.getHttpClient(3244, %22http%22);%0A%0A        Assert.assertNotNull(client);%0A        Scheme scheme = client.getConnectionManager().getSchemeRegistry().get(%22http%22);%0A        Assert.assertEquals(3244, scheme.getDefaultPort());%0A%0A        client = APIUtil.getHttpClient(3244, %22https%22);%0A        Assert.assertNotNull(client);%0A        scheme = client.getConnectionManager().getSchemeRegistry().get(%22https%22);%0A        Assert.assertEquals(3244, scheme.getDefaultPort());%0A%0A        client = APIUtil.getHttpClient(-1, %22http%22);%0A        Assert.assertNotNull(client);%0A        scheme = client.getConnectionManager().getSchemeRegistry().get(%22http%22);%0A        Assert.assertEquals(80, scheme.getDefaultPort());%0A%0A        client = APIUtil.getHttpClient(-1, %22https%22);%0A        Assert.assertNotNull(client);%0A        scheme = client.getConnectionManager().getSchemeRegistry().get(%22https%22);%0A        Assert.assertEquals(443, scheme.getDefaultPort());%0A    %7D%0A%0A    @Test%0A    public void testGetHttpClientIgnoreHostNameVerify() %7B%0A        System.setProperty(%22org.wso2.ignoreHostnameVerification%22, %22true%22);%0A        HttpClient client = APIUtil.getHttpClient(3244, %22https%22);%0A%0A        Assert.assertNotNull(client);%0A%0A%0A
     %7D%0A%7D%0A

Test for getHttpClient