Search in sources :

Example 46 with Label

use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.

the class WSDL11ProcessorImplTestCase method testSingleWSDL.

@Test
public void testSingleWSDL() throws Exception {
    WSDL11ProcessorImpl wsdl11Processor = new WSDL11ProcessorImpl();
    byte[] wsdlContentBytes = SampleTestObjectCreator.createDefaultWSDL11Content();
    wsdl11Processor.init(wsdlContentBytes);
    Assert.assertTrue(wsdl11Processor.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor.getWsdlInfo(), SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER, null);
    // validate the content from getWSDL() after initializing the WSDL processor
    byte[] originalWsdlContentFromProcessor = wsdl11Processor.getWSDL();
    WSDL11ProcessorImpl wsdl11Processor2 = new WSDL11ProcessorImpl();
    wsdl11Processor2.init(originalWsdlContentFromProcessor);
    Assert.assertTrue(wsdl11Processor2.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor2.getWsdlInfo(), SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER, null);
    // validate the content after updating endpoints using an API and Label
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    byte[] updatedWSDLWithEndpoint = wsdl11Processor.getUpdatedWSDL(api, label);
    // validate the content of wsdl11Processor's WSDL Info content after updating its endpoints
    assertDefaultSingleWSDLContent(wsdl11Processor.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER);
    // validate the content of wsdl11Processor's returned WSDL content after updating its endpoints
    WSDL11ProcessorImpl wsdl11Processor3 = new WSDL11ProcessorImpl();
    wsdl11Processor3.init(updatedWSDLWithEndpoint);
    Assert.assertTrue(wsdl11Processor3.canProcess());
    assertDefaultSingleWSDLContent(wsdl11Processor3.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, SampleTestObjectCreator.ORIGINAL_ENDPOINT_WEATHER);
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) API(org.wso2.carbon.apimgt.core.models.API) Test(org.testng.annotations.Test)

Example 47 with Label

use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.

the class WSDL20ProcessorImplTestCase method testWSDLArchive.

@Test
public void testWSDLArchive() throws Exception {
    String extractedLocation = SampleTestObjectCreator.createDefaultWSDL20Archive();
    WSDL20ProcessorImpl wsdl20Processor = new WSDL20ProcessorImpl();
    wsdl20Processor.initPath(extractedLocation);
    Assert.assertTrue(wsdl20Processor.canProcess());
    assertDefaultArchivedWSDLContent(wsdl20Processor.getWsdlInfo(), new String[] { ORIGINAL_ENDPOINT_MY_SERVICE, ORIGINAL_ENDPOINT_PURCHASE_ORDER }, null);
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    String updatedPath = wsdl20Processor.getUpdatedWSDLPath(api, label);
    WSDL20ProcessorImpl wsdl20Processor2 = new WSDL20ProcessorImpl();
    wsdl20Processor2.initPath(updatedPath);
    Assert.assertTrue(wsdl20Processor2.canProcess());
    assertDefaultArchivedWSDLContent(wsdl20Processor2.getWsdlInfo(), new String[] { UPDATED_ENDPOINT_API_LABEL }, new String[] { ORIGINAL_ENDPOINT_MY_SERVICE, ORIGINAL_ENDPOINT_PURCHASE_ORDER });
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) API(org.wso2.carbon.apimgt.core.models.API) Test(org.testng.annotations.Test)

Example 48 with Label

use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.

the class WSDL20ProcessorImplTestCase method testSingleWSDL.

@Test
public void testSingleWSDL() throws Exception {
    WSDL20ProcessorImpl wsdl20Processor = new WSDL20ProcessorImpl();
    byte[] wsdlContentBytes = SampleTestObjectCreator.createDefaultWSDL20Content();
    wsdl20Processor.init(wsdlContentBytes);
    Assert.assertTrue(wsdl20Processor.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor.getWsdlInfo(), ORIGINAL_ENDPOINT_MY_SERVICE, null);
    // validate the content from getWSDL() after initializing the WSDL processor
    byte[] originalWsdlContentFromProcessor = wsdl20Processor.getWSDL();
    WSDL20ProcessorImpl wsdl20Processor2 = new WSDL20ProcessorImpl();
    wsdl20Processor2.init(originalWsdlContentFromProcessor);
    Assert.assertTrue(wsdl20Processor2.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor2.getWsdlInfo(), ORIGINAL_ENDPOINT_MY_SERVICE, null);
    // validate the content after updating endpoints using an API and Label
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Label label = SampleTestObjectCreator.createLabel(SAMPLE_LABEL_NAME, SampleTestObjectCreator.LABEL_TYPE_STORE).build();
    byte[] updatedWSDLWithEndpoint = wsdl20Processor.getUpdatedWSDL(api, label);
    // validate the content of wsdl20Processor's WSDL Info content after updating its endpoints
    assertDefaultSingleWSDLContent(wsdl20Processor.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, ORIGINAL_ENDPOINT_MY_SERVICE);
    // validate the content of wsdl20Processor's returned WSDL content after updating its endpoints
    WSDL20ProcessorImpl wsdl20Processor3 = new WSDL20ProcessorImpl();
    wsdl20Processor3.init(updatedWSDLWithEndpoint);
    Assert.assertTrue(wsdl20Processor3.canProcess());
    assertDefaultSingleWSDLContent(wsdl20Processor3.getWsdlInfo(), UPDATED_ENDPOINT_API_LABEL, ORIGINAL_ENDPOINT_MY_SERVICE);
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) API(org.wso2.carbon.apimgt.core.models.API) Test(org.testng.annotations.Test)

Example 49 with Label

use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.

the class MappingUtil method convertToLabels.

/**
 * Converts labelDTOs into labels
 *
 * @param labelDTOs List of LabelDTOs
 * @return List of Labels
 */
public static List<Label> convertToLabels(List<LabelDTO> labelDTOs) {
    List<Label> labels = new ArrayList<>();
    for (LabelDTO labelDTO : labelDTOs) {
        String labelId = UUID.randomUUID().toString();
        Label label = new Label.Builder().id(labelId).name(labelDTO.getName()).accessUrls(labelDTO.getAccessUrls()).build();
        labels.add(label);
    }
    return labels;
}
Also used : Label(org.wso2.carbon.apimgt.core.models.Label) ArrayList(java.util.ArrayList) LabelDTO(org.wso2.carbon.apimgt.rest.api.core.dto.LabelDTO)

Example 50 with Label

use of org.wso2.carbon.apimgt.core.models.Label in project carbon-apimgt by wso2.

the class ConfigurationsAPI method environments.

/**
 * Get environment configurations from deployment.yaml and returns the list of environments
 *
 * @return Response List of environments: {"environments":[
 * {"host":"localhost:9292","loginTokenPath":"/login/token","label":"Development"},
 * {"host":"localhost:9293","loginTokenPath":"/login/token","label":"Production"}
 * ]}
 */
@GET
@Path("/environments")
@Produces(MediaType.APPLICATION_JSON)
public Response environments() {
    APIMUIConfigurations apimUIConfigurations = ConfigurationService.getInstance().getApimUIConfigurations();
    EnvironmentConfigBean environmentConfigBean = new EnvironmentConfigBean();
    environmentConfigBean.setEnvironments(apimUIConfigurations.getEnvironments());
    return Response.ok(environmentConfigBean, MediaType.APPLICATION_JSON).build();
}
Also used : EnvironmentConfigBean(org.wso2.carbon.apimgt.rest.api.configurations.utils.bean.EnvironmentConfigBean) APIMUIConfigurations(org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Label (org.wso2.carbon.apimgt.core.models.Label)65 ArrayList (java.util.ArrayList)52 Test (org.testng.annotations.Test)45 LabelDAO (org.wso2.carbon.apimgt.core.dao.LabelDAO)32 API (org.wso2.carbon.apimgt.core.models.API)29 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)28 SQLException (java.sql.SQLException)21 PreparedStatement (java.sql.PreparedStatement)20 HashMap (java.util.HashMap)16 Connection (java.sql.Connection)15 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)14 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)13 Test (org.junit.Test)12 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)11 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)11 Map (java.util.Map)10 BeforeTest (org.testng.annotations.BeforeTest)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)8 Response (javax.ws.rs.core.Response)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8