Search in sources :

Example 11 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerTest method testAddAttribute.

@Test(priority = 17)
public void testAddAttribute() throws Exception {
    ResourceType resourceType = configurationManager.addResourceType(getSampleResourceTypeAdd());
    Resource resource = configurationManager.addResource(resourceType.getName(), getSampleResource1Add());
    Attribute attribute = getSampleAttribute3();
    Attribute retrievedAttribute = configurationManager.addAttribute(resourceType.getName(), resource.getResourceName(), attribute);
    assertNotNull(retrievedAttribute.getAttributeId(), "Created resource type id cannot be null");
}
Also used : Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerTest method testGetExistingAttribute.

@Test(priority = 23)
public void testGetExistingAttribute() throws Exception {
    ResourceType resourceType = configurationManager.addResourceType(getSampleResourceTypeAdd());
    Resource resource = configurationManager.addResource(resourceType.getName(), getSampleResource1Add());
    Attribute retrievedAttribute = configurationManager.getAttribute(resourceType.getName(), resource.getResourceName(), SAMPLE_ATTRIBUTE_NAME1);
    assertEquals("Existing id should be equal to the retrieved id", SAMPLE_ATTRIBUTE_NAME1, retrievedAttribute.getKey());
}
Also used : Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerTest method testReplaceExistingResourceType.

@Test(priority = 4)
public void testReplaceExistingResourceType() throws Exception {
    ResourceTypeAdd resourceTypeAdd = getSampleResourceTypeAdd();
    ResourceType resourceTypeCreated = configurationManager.addResourceType(resourceTypeAdd);
    ResourceType resourceTypeReplaced = configurationManager.replaceResourceType(resourceTypeAdd);
    assertEquals("Existing id should be equal to the replaced id", resourceTypeCreated.getId(), resourceTypeReplaced.getId());
}
Also used : ResourceTypeAdd(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceTypeAdd) TestUtils.getSampleResourceTypeAdd(org.wso2.carbon.identity.configuration.mgt.core.util.TestUtils.getSampleResourceTypeAdd) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigurationManagerTest method testGetNonExistingResource.

@Test(priority = 13, expectedExceptions = ConfigurationManagementClientException.class)
public void testGetNonExistingResource() throws Exception {
    ResourceType resourceType = configurationManager.addResourceType(getSampleResourceTypeAdd());
    configurationManager.getResource(resourceType.getName(), SAMPLE_RESOURCE_NAME1);
    fail("Expected: " + ConfigurationManagementClientException.class.getName());
}
Also used : ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 15 with ResourceType

use of org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType in project carbon-identity-framework by wso2.

the class ConfigStoreBasedTemplateHandler method createResourceType.

private void createResourceType(String templateType) throws ConfigurationManagementException {
    ConfigurationManager configManager = TemplateManagerDataHolder.getInstance().getConfigurationManager();
    ResourceTypeAdd resourceType = new ResourceTypeAdd();
    resourceType.setName(templateType);
    resourceType.setDescription("This is the resource type for " + templateType);
    configManager.addResourceType(resourceType);
}
Also used : ResourceTypeAdd(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceTypeAdd) ConfigurationManager(org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager)

Aggregations

ResourceType (org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType)36 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 Test (org.testng.annotations.Test)27 Resource (org.wso2.carbon.identity.configuration.mgt.core.model.Resource)22 Attribute (org.wso2.carbon.identity.configuration.mgt.core.model.Attribute)9 InputStream (java.io.InputStream)7 ResourceFile (org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 XMLStreamException (javax.xml.stream.XMLStreamException)6 OMAttribute (org.apache.axiom.om.OMAttribute)6 OMElement (org.apache.axiom.om.OMElement)6 Resources (org.wso2.carbon.identity.configuration.mgt.core.model.Resources)6 Resource (org.wso2.carbon.registry.core.Resource)6 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)6 File (java.io.File)5 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)4 Mediation (org.wso2.carbon.apimgt.api.model.Mediation)4 JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)4