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");
}
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");
}
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");
}
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());
}
}
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();
}
Aggregations