Search in sources :

Example 1 with StandardImportParams

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

the class JSONRemoteHostAdapterTest method testNonStagedMultiRemoteHosts.

@Test
public void testNonStagedMultiRemoteHosts() throws AppException {
    StandardImportParams importParams = new StandardImportParams();
    String configFileName = this.getClass().getClassLoader().getResource(PACKAGE + "two-remotehosts-config.json").getFile();
    importParams.setConfig(configFileName);
    JSONAPIManagerConfigAdapter adapter = new JSONAPIManagerConfigAdapter(importParams);
    Map<String, RemoteHost> remoteHosts = adapter.getManagerConfig().getRemoteHosts();
    Assert.assertEquals(remoteHosts.size(), 2, "Two Remote Hosts are expected");
    RemoteHost remoteHost1 = remoteHosts.get("My-First-Remote-Host");
    RemoteHost remoteHost2 = remoteHosts.get("My-Second-Remote-Host");
    Assert.assertEquals(remoteHost1.getName(), "localhostrathna");
    Assert.assertEquals(remoteHost1.getPort(), new Integer(80));
    Assert.assertEquals(remoteHost1.getOrganization().getName(), "API Development");
    Assert.assertEquals(remoteHost1.getCreatedBy().getName(), "API Administrator");
    Assert.assertEquals(remoteHost1.getCreatedBy().getId(), "f60e3e05-cdf3-4b70-affc-4cb61a10f4bb");
    Assert.assertEquals(remoteHost2.getName(), "samplehost.com");
    Assert.assertEquals(remoteHost2.getPort(), new Integer(80));
    Assert.assertEquals(remoteHost2.getOrganization().getName(), "FHIR");
    Assert.assertEquals(remoteHost2.getCreatedBy().getName(), "Fred Smith");
    Assert.assertEquals(remoteHost2.getCreatedBy().getLoginName(), "fred");
    Assert.assertEquals(remoteHost2.getCreatedBy().getId(), "c888af4e-0728-4e82-880c-7cf490138220");
}
Also used : RemoteHost(com.axway.apim.api.model.RemoteHost) StandardImportParams(com.axway.apim.lib.StandardImportParams) Test(org.testng.annotations.Test)

Example 2 with StandardImportParams

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

the class RemoteHostCLIOptionsTest method testSettingsImportParams.

@Test
public void testSettingsImportParams() throws ParseException, AppException {
    String[] args = { "-c", "mySettings.json", "-stageConfig", "myStagedSettings.json" };
    CLIOptions options = APIManagerSetupImportCLIOptions.create(args);
    StandardImportParams params = (StandardImportParams) options.getParams();
    Assert.assertEquals(params.getConfig(), "mySettings.json");
    Assert.assertEquals(params.getStageConfig(), "myStagedSettings.json");
    Assert.assertNotNull(params.getProperties(), "Properties should never be null. They must be created as a base or per stage.");
}
Also used : APIManagerSetupImportCLIOptions(com.axway.apim.setup.lib.APIManagerSetupImportCLIOptions) RemoteHostsExportCLIOptions(com.axway.apim.setup.remotehosts.lib.RemoteHostsExportCLIOptions) CLIOptions(com.axway.apim.lib.CLIOptions) StandardImportParams(com.axway.apim.lib.StandardImportParams) Test(org.testng.annotations.Test)

Example 3 with StandardImportParams

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

the class ImportManagerConfigTestAction method runTest.

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

Example 4 with StandardImportParams

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

the class JSONAPIManagerConfigAdapterTest method testInvalidStagedConfig.

@Test
public void testInvalidStagedConfig() throws AppException {
    StandardImportParams importParams = new StandardImportParams();
    String configFileName = this.getClass().getClassLoader().getResource(PACKAGE + "apimanager-config.json").getFile();
    importParams.setConfig(configFileName);
    importParams.setStage("invalid-stage");
    JSONAPIManagerConfigAdapter adapter = new JSONAPIManagerConfigAdapter(importParams);
    APIManagerConfig managerConfig = adapter.getManagerConfig();
    Assert.assertEquals(managerConfig.getConfig().getPortalName(), "My API Manager");
}
Also used : APIManagerConfig(com.axway.apim.api.model.APIManagerConfig) StandardImportParams(com.axway.apim.lib.StandardImportParams) Test(org.testng.annotations.Test)

Example 5 with StandardImportParams

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

the class JSONAPIManagerConfigAdapterTest method testValidStagedConfig.

@Test
public void testValidStagedConfig() throws AppException {
    StandardImportParams importParams = new StandardImportParams();
    String configFileName = this.getClass().getClassLoader().getResource(PACKAGE + "apimanager-config.json").getFile();
    importParams.setConfig(configFileName);
    importParams.setStage("test-stage");
    JSONAPIManagerConfigAdapter adapter = new JSONAPIManagerConfigAdapter(importParams);
    APIManagerConfig managerConfig = adapter.getManagerConfig();
    Assert.assertEquals(managerConfig.getConfig().getPortalName(), "Axway API Manager Test-Stage");
}
Also used : APIManagerConfig(com.axway.apim.api.model.APIManagerConfig) StandardImportParams(com.axway.apim.lib.StandardImportParams) Test(org.testng.annotations.Test)

Aggregations

StandardImportParams (com.axway.apim.lib.StandardImportParams)11 Test (org.testng.annotations.Test)7 APIManagerConfig (com.axway.apim.api.model.APIManagerConfig)4 RemoteHost (com.axway.apim.api.model.RemoteHost)2 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 APIManagerSettingsApp (com.axway.apim.setup.APIManagerSettingsApp)1 APIManagerSetupImportCLIOptions (com.axway.apim.setup.lib.APIManagerSetupImportCLIOptions)1 RemoteHostsExportCLIOptions (com.axway.apim.setup.remotehosts.lib.RemoteHostsExportCLIOptions)1 ValidationException (com.consol.citrus.exceptions.ValidationException)1