Search in sources :

Example 1 with OrgImportParams

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

the class JSONOrganizationAdapterTest method readManyOrgsWithStageTest.

@Test(expectedExceptions = AppException.class)
public void readManyOrgsWithStageTest() throws AppException {
    String testFile = JSONOrganizationAdapterTest.class.getResource(testPackage + "/OrganizationArray.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    OrgImportParams importParams = new OrgImportParams();
    importParams.setConfig(testFile);
    importParams.setStage("test-stage");
    JSONOrgAdapter adapter = new JSONOrgAdapter(importParams);
    // Stage for a list of organizations is not supported!
    adapter.getOrganizations();
}
Also used : OrgImportParams(com.axway.apim.organization.lib.OrgImportParams) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with OrgImportParams

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

the class JSONOrganizationAdapterTest method readSingleOrgTest.

@Test
public void readSingleOrgTest() throws AppException {
    String testFile = JSONOrganizationAdapterTest.class.getResource(testPackage + "/SingleOrganization.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    OrgImportParams importParams = new OrgImportParams();
    importParams.setConfig(testFile);
    JSONOrgAdapter adapter = new JSONOrgAdapter(importParams);
    List<Organization> orgs = adapter.getOrganizations();
    assertEquals(orgs.size(), 1, "Expected 1 org returned from the Adapter");
    Organization org = orgs.get(0);
    assertNotNull(org.getImage(), "Organization should have an image attached");
}
Also used : OrgImportParams(com.axway.apim.organization.lib.OrgImportParams) Organization(com.axway.apim.api.model.Organization) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with OrgImportParams

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

the class JSONOrganizationAdapterTest method readSingleOrgTestWithStagedConfig.

@Test
public void readSingleOrgTestWithStagedConfig() throws AppException {
    String testFile = JSONOrganizationAdapterTest.class.getResource(testPackage + "/SingleOrganization.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    OrgImportParams importParams = new OrgImportParams();
    importParams.setConfig(testFile);
    importParams.setStageConfig("StagedSingleOrganization.json");
    JSONOrgAdapter adapter = new JSONOrgAdapter(importParams);
    List<Organization> orgs = adapter.getOrganizations();
    assertEquals(orgs.size(), 1, "Expected 1 org returned from the Adapter");
    Organization org = orgs.get(0);
    assertNotNull(org.getImage(), "Organization should have an image attached");
    assertEquals(org.getDescription(), "Staged description for this organization");
}
Also used : OrgImportParams(com.axway.apim.organization.lib.OrgImportParams) Organization(com.axway.apim.api.model.Organization) File(java.io.File) Test(org.testng.annotations.Test)

Example 4 with OrgImportParams

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

the class JSONOrganizationAdapterTest method readManyOrgsTest.

@Test
public void readManyOrgsTest() throws AppException {
    String testFile = JSONOrganizationAdapterTest.class.getResource(testPackage + "/OrganizationArray.json").getPath();
    assertTrue(new File(testFile).exists(), "Test file doesn't exists");
    OrgImportParams importParams = new OrgImportParams();
    importParams.setConfig(testFile);
    JSONOrgAdapter adapter = new JSONOrgAdapter(importParams);
    List<Organization> orgs = adapter.getOrganizations();
    assertEquals(orgs.size(), 2, "Expected 2 apps returned from the Adapter");
}
Also used : OrgImportParams(com.axway.apim.organization.lib.OrgImportParams) Organization(com.axway.apim.api.model.Organization) File(java.io.File) Test(org.testng.annotations.Test)

Example 5 with OrgImportParams

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

the class OrganizationApp method importOrganization.

@CLIServiceMethod(name = "import", description = "Import organizatio(s) into the API-Manager")
public static int importOrganization(String[] args) {
    OrgImportParams params;
    try {
        params = (OrgImportParams) OrgImportCLIOptions.create(args).getParams();
    } catch (AppException e) {
        LOG.error("Error " + e.getMessage());
        return e.getError().getCode();
    /*} catch (ParseException e) {
			LOG.error("Error " + e.getMessage());
			return ErrorCode.MISSING_PARAMETER.getCode();*/
    }
    OrganizationApp orgApp = new OrganizationApp();
    return orgApp.importOrganization(params);
}
Also used : OrgImportParams(com.axway.apim.organization.lib.OrgImportParams) AppException(com.axway.apim.lib.errorHandling.AppException) CLIServiceMethod(com.axway.apim.cli.CLIServiceMethod)

Aggregations

OrgImportParams (com.axway.apim.organization.lib.OrgImportParams)8 Test (org.testng.annotations.Test)6 File (java.io.File)5 Organization (com.axway.apim.api.model.Organization)4 CLIServiceMethod (com.axway.apim.cli.CLIServiceMethod)1 CLIOptions (com.axway.apim.lib.CLIOptions)1 AppException (com.axway.apim.lib.errorHandling.AppException)1 OrganizationApp (com.axway.apim.organization.OrganizationApp)1 OrgDeleteCLIOptions (com.axway.apim.organization.lib.OrgDeleteCLIOptions)1 OrgExportCLIOptions (com.axway.apim.organization.lib.OrgExportCLIOptions)1 OrgImportCLIOptions (com.axway.apim.organization.lib.OrgImportCLIOptions)1 ValidationException (com.consol.citrus.exceptions.ValidationException)1