Search in sources :

Example 71 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractDummyTest method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    // We need to switch off the encryption checks. Some values cannot be encrypted as we do
    // not have a definition here
    InternalsConfig.encryptionChecks = false;
    provisioningService.postInit(initResult);
    resource = addResourceFromFile(getResourceDummyFilename(), IntegrationTestTools.DUMMY_CONNECTOR_TYPE, initResult);
    resourceType = resource.asObjectable();
    dummyResourceCtl = DummyResourceContoller.create(null);
    dummyResourceCtl.setResource(resource);
    dummyResourceCtl.extendSchemaPirate();
    dummyResource = dummyResourceCtl.getDummyResource();
    extraDummyResourceInit();
    DummyAccount dummyAccountDaemon = new DummyAccount(ACCOUNT_DAEMON_USERNAME);
    dummyAccountDaemon.setEnabled(true);
    dummyAccountDaemon.addAttributeValues("fullname", "Evil Daemon");
    dummyResource.addAccount(dummyAccountDaemon);
    daemonIcfUid = dummyAccountDaemon.getId();
    PrismObject<ShadowType> shadowDaemon = PrismTestUtil.parseObject(ACCOUNT_DAEMON_FILE);
    if (!isIcfNameUidSame()) {
        setIcfUid(shadowDaemon, dummyAccountDaemon.getId());
    }
    repositoryService.addObject(shadowDaemon, null, initResult);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount)

Example 72 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractDummyTest method rememberConnectorInstance.

protected void rememberConnectorInstance(PrismObject<ResourceType> resource) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
    OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + ".rememberConnectorInstance");
    rememberConnectorInstance(resourceManager.getConfiguredConnectorInstance(resource, ReadCapabilityType.class, false, result));
}
Also used : ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 73 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test000Integrity.

@Test
public void test000Integrity() throws Exception {
    final String TEST_NAME = "test000Integrity";
    TestUtil.displayTestTile(TEST_NAME);
    display("Dummy resource instance", dummyResource.toString());
    assertNotNull("Resource is null", resource);
    assertNotNull("ResourceType is null", resourceType);
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result).asObjectable();
    String connectorOid = resource.getConnectorRef().getOid();
    ConnectorType connector = repositoryService.getObject(ConnectorType.class, connectorOid, null, result).asObjectable();
    assertNotNull(connector);
    display("Dummy Connector", connector);
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    // Check connector schema
    IntegrationTestTools.assertConnectorSchemaSanity(connector, prismContext);
    IntegrationTestTools.assertNoSchema(resource);
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test)

Example 74 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class AbstractBasicDummyTest method test021Configuration.

@Test
public void test021Configuration() throws Exception {
    final String TEST_NAME = "test021Configuration";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
    // WHEN
    resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
    resourceType = resource.asObjectable();
    // THEN
    result.computeStatus();
    display("getObject result", result);
    TestUtil.assertSuccess(result);
    // There may be one parse. Previous test have changed the resource version
    // Schema for this version will not be re-parsed until getObject is tried
    assertResourceSchemaParseCountIncrement(1);
    assertResourceCacheMissesIncrement(1);
    PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
    assertNotNull("No configuration container", configurationContainer);
    PrismContainerDefinition confContDef = configurationContainer.getDefinition();
    assertNotNull("No configuration container definition", confContDef);
    PrismContainer confingurationPropertiesContainer = configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    assertNotNull("No configuration properties container", confingurationPropertiesContainer);
    PrismContainerDefinition confPropsDef = confingurationPropertiesContainer.getDefinition();
    assertNotNull("No configuration properties container definition", confPropsDef);
    List<PrismProperty<?>> configurationProperties = confingurationPropertiesContainer.getValue().getItems();
    assertFalse("No configuration properties", configurationProperties.isEmpty());
    for (PrismProperty<?> confProp : configurationProperties) {
        PrismPropertyDefinition confPropDef = confProp.getDefinition();
        assertNotNull("No definition for configuration property " + confProp, confPropDef);
        assertFalse("Configuration property " + confProp + " is raw", confProp.isRaw());
        assertConfigurationProperty(confProp);
    }
    // The useless configuration variables should be reflected to the resource now
    assertEquals("Wrong useless string", "Shiver me timbers!", dummyResource.getUselessString());
    assertEquals("Wrong guarded useless string", "Dead men tell no tales", dummyResource.getUselessGuardedString());
    resource.checkConsistence();
    rememberSchemaMetadata(resource);
    rememberConnectorInstance(resource);
    assertSteadyResource();
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Containerable(com.evolveum.midpoint.prism.Containerable) Test(org.testng.annotations.Test)

Example 75 with ResourceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.

the class TestSanityLegacy method test006reimportResourceDummy.

@Test
public void test006reimportResourceDummy() throws Exception {
    TestUtil.displayTestTile("test006reimportResourceDummy");
    //get object from repo (with version set and try to add it - it should be re-added, without error)
    OperationResult repoResult = new OperationResult("getObject");
    PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, repoResult);
    assertNotNull(resource);
    ModelExecuteOptionsType options = new ModelExecuteOptionsType();
    options.setOverwrite(Boolean.TRUE);
    options.setIsImport(Boolean.TRUE);
    addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), new Holder<OperationResultType>());
    //TODO: add some asserts
    //parse object from file again and try to add it - this should fail, becasue the same object already exists)
    resource = PrismTestUtil.parseObject(new File(RESOURCE_DUMMY_FILENAME));
    try {
        Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
        options = new ModelExecuteOptionsType();
        options.setIsImport(Boolean.TRUE);
        addObjectViaModelWS(resource.asObjectable(), options, new Holder<String>(), resultHolder);
        OperationResultType result = resultHolder.value;
        TestUtil.assertFailure(result);
        fail("Expected object already exists exception, but haven't got one.");
    } catch (FaultMessage ex) {
        LOGGER.info("fault {}", ex.getFaultInfo());
        LOGGER.info("fault {}", ex.getCause());
        if (ex.getFaultInfo() instanceof ObjectAlreadyExistsFaultType) {
        // this is OK, we expect this
        } else {
            fail("Expected object already exists exception, but haven't got one.");
        }
    }
//         ResourceType resourceType = uObject.asObjectable();
//         assertNotNull("Reference on the connector must not be null in resource.",resourceType.getConnectorRef());
//         assertNotNull("Missing oid reference on the connector",resourceType.getConnectorRef().getOid());
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectAlreadyExistsFaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType) File(java.io.File) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)252 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)199 Test (org.testng.annotations.Test)165 Task (com.evolveum.midpoint.task.api.Task)115 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)58 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)54 PrismObject (com.evolveum.midpoint.prism.PrismObject)50 QName (javax.xml.namespace.QName)45 ArrayList (java.util.ArrayList)37 Element (org.w3c.dom.Element)34 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)33 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)30 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)27 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)25 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)24 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)23 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)23