Search in sources :

Example 1 with AppImportParams

use of com.axway.apim.appimport.lib.AppImportParams in project apim-cli by Axway-API-Management-Plus.

the class JSONClientAppAdapterTest method testAppWithQuotaBasedOnAPIPath.

@Test
public void testAppWithQuotaBasedOnAPIPath() throws AppException {
    String testFile = JSONClientAppAdapterTest.class.getResource(testPackage + "/AppWithQuotaPerAPIPath.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    AppImportParams importParams = new AppImportParams();
    importParams.setConfig(testFile);
    ClientAppAdapter adapter = new JSONConfigClientAppAdapter(importParams);
    List<ClientApplication> apps = adapter.getApplications();
    assertEquals(apps.size(), 1, "Expected 1 app returned from the Adapter");
    ClientApplication app = apps.get(0);
    assertEquals(app.getName(), "Application with quota");
    assertEquals(app.getDescription(), "Application that configured quota per API-Path");
    APIQuota appQuota = app.getAppQuota();
    assertNotNull(appQuota, "appQuota is null");
    assertNotNull(appQuota.getRestrictions(), "appQuota restrictions are null");
    assertEquals(appQuota.getRestrictions().size(), 1, "Expected one restriction");
    QuotaRestriction restr1 = appQuota.getRestrictions().get(0);
    assertEquals(restr1.getApiId(), "72745ed9-f75b-428c-959c-b483eea497a1");
    assertEquals(restr1.getRestrictedAPI().getName(), "apiName-routeKeyD");
    assertEquals(restr1.getRestrictedAPI().getPath(), "/query-string-api-oadmin-839");
    assertEquals(restr1.getMethod(), "*");
    assertEquals(restr1.getType(), QuotaRestrictiontype.throttle);
    assertEquals(restr1.getConfig().get("messages"), "9999");
    assertEquals(restr1.getConfig().get("period"), "week");
    assertEquals(restr1.getConfig().get("per"), "1");
}
Also used : QuotaRestriction(com.axway.apim.api.model.QuotaRestriction) ClientApplication(com.axway.apim.api.model.apps.ClientApplication) APIQuota(com.axway.apim.api.model.APIQuota) AppImportParams(com.axway.apim.appimport.lib.AppImportParams) ClientAppAdapter(com.axway.apim.adapter.clientApps.ClientAppAdapter) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with AppImportParams

use of com.axway.apim.appimport.lib.AppImportParams in project apim-cli by Axway-API-Management-Plus.

the class JSONClientAppAdapterTest method testSingleAppAsArray.

@Test
public void testSingleAppAsArray() throws AppException {
    String testFile = JSONClientAppAdapterTest.class.getResource(testPackage + "/SingleClientAppAsArray.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    AppImportParams importParams = new AppImportParams();
    importParams.setConfig(testFile);
    ClientAppAdapter adapter = new JSONConfigClientAppAdapter(importParams);
    List<ClientApplication> apps = adapter.getApplications();
    assertEquals(apps.size(), 1, "Expected 1 app returned from the Adapter");
}
Also used : ClientApplication(com.axway.apim.api.model.apps.ClientApplication) AppImportParams(com.axway.apim.appimport.lib.AppImportParams) ClientAppAdapter(com.axway.apim.adapter.clientApps.ClientAppAdapter) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with AppImportParams

use of com.axway.apim.appimport.lib.AppImportParams in project apim-cli by Axway-API-Management-Plus.

the class JSONClientAppAdapterTest method testSingleApp.

@Test
public void testSingleApp() throws AppException {
    String testFile = JSONClientAppAdapterTest.class.getResource(testPackage + "/OneSingleClientApp.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    AppImportParams importParams = new AppImportParams();
    importParams.setConfig(testFile);
    ClientAppAdapter adapter = new JSONConfigClientAppAdapter(importParams);
    List<ClientApplication> apps = adapter.getApplications();
    assertEquals(apps.size(), 1, "Expected 1 app returned from the Adapter");
}
Also used : ClientApplication(com.axway.apim.api.model.apps.ClientApplication) AppImportParams(com.axway.apim.appimport.lib.AppImportParams) ClientAppAdapter(com.axway.apim.adapter.clientApps.ClientAppAdapter) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with AppImportParams

use of com.axway.apim.appimport.lib.AppImportParams in project apim-cli by Axway-API-Management-Plus.

the class ImportAppTestAction method runTest.

@Override
public void runTest(TestContext context) {
    AppImportParams params = new AppImportParams();
    addParameters(params, context);
    params.setConfig(this.configFile.getPath());
    ClientApplicationImportApp app = new ClientApplicationImportApp();
    LOG.info("Running " + app.getClass().getSimpleName() + " with params: " + params);
    ImportResult result = app.importApp(params);
    if (this.getExpectedReturnCode(context) != result.getRc()) {
        throw new ValidationException("Expected RC was: " + this.getExpectedReturnCode(context) + " but got: " + result.getRc());
    }
}
Also used : AppImportParams(com.axway.apim.appimport.lib.AppImportParams) ImportResult(com.axway.apim.lib.ImportResult) ValidationException(com.consol.citrus.exceptions.ValidationException) ClientApplicationImportApp(com.axway.apim.appimport.ClientApplicationImportApp)

Example 5 with AppImportParams

use of com.axway.apim.appimport.lib.AppImportParams in project apim-cli by Axway-API-Management-Plus.

the class ClientApplicationImportApp method importApp.

@CLIServiceMethod(name = "import", description = "Import application(s) into the API-Manager")
public static int importApp(String[] args) {
    AppImportParams params;
    try {
        params = (AppImportParams) AppImportCLIOptions.create(args).getParams();
    } catch (AppException e) {
        LOG.error("Error " + e.getMessage());
        return e.getError().getCode();
    }
    ClientApplicationImportApp app = new ClientApplicationImportApp();
    return app.importApp(params).getRc();
}
Also used : AppException(com.axway.apim.lib.errorHandling.AppException) AppImportParams(com.axway.apim.appimport.lib.AppImportParams) CLIServiceMethod(com.axway.apim.cli.CLIServiceMethod)

Aggregations

AppImportParams (com.axway.apim.appimport.lib.AppImportParams)11 Test (org.testng.annotations.Test)9 ClientAppAdapter (com.axway.apim.adapter.clientApps.ClientAppAdapter)8 File (java.io.File)8 ClientApplication (com.axway.apim.api.model.apps.ClientApplication)7 APIQuota (com.axway.apim.api.model.APIQuota)3 QuotaRestriction (com.axway.apim.api.model.QuotaRestriction)3 Image (com.axway.apim.api.model.Image)1 APIKey (com.axway.apim.api.model.apps.APIKey)1 ClientAppCredential (com.axway.apim.api.model.apps.ClientAppCredential)1 ClientAppOauthResource (com.axway.apim.api.model.apps.ClientAppOauthResource)1 OAuth (com.axway.apim.api.model.apps.OAuth)1 AppExportCLIOptions (com.axway.apim.appexport.lib.AppExportCLIOptions)1 ClientApplicationImportApp (com.axway.apim.appimport.ClientApplicationImportApp)1 AppImportCLIOptions (com.axway.apim.appimport.lib.AppImportCLIOptions)1 CLIServiceMethod (com.axway.apim.cli.CLIServiceMethod)1 CLIOptions (com.axway.apim.lib.CLIOptions)1 ImportResult (com.axway.apim.lib.ImportResult)1 AppException (com.axway.apim.lib.errorHandling.AppException)1 ValidationException (com.consol.citrus.exceptions.ValidationException)1