Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.ConnInstanceTO


        assertNotNull(connidDbTableVersion);
    }

    @Test(expected = SyncopeClientCompositeErrorException.class)
    public void createWithException() {
        ConnInstanceTO connectorTO = new ConnInstanceTO();

        Response response = connectorService.create(connectorTO);
        if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
            throw (RuntimeException) clientExceptionMapper.fromResponse(response);
        }
View Full Code Here


        }
    }

    @Test
    public void create() {
        ConnInstanceTO connectorTO = new ConnInstanceTO();

        connectorTO.setLocation(connectorService.read(100L).getLocation());

        // set connector version
        connectorTO.setVersion(connidSoapVersion);

        // set connector name
        connectorTO.setConnectorName("org.connid.bundles.soap.WebServiceConnector");

        // set bundle name
        connectorTO.setBundleName("org.connid.bundles.soap");

        connectorTO.setDisplayName("Display name");

        connectorTO.setConnRequestTimeout(15);

        // set the connector configuration using PropertyTO
        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();

        ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
        endpointSchema.setName("endpoint");
        endpointSchema.setType(String.class.getName());
        endpointSchema.setRequired(true);
        ConnConfProperty endpoint = new ConnConfProperty();
        endpoint.setSchema(endpointSchema);
        endpoint.setValues(Collections.singletonList("http://localhost:8888/wssample/services"));

        ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
        servicenameSchema.setName("servicename");
        servicenameSchema.setType(String.class.getName());
        servicenameSchema.setRequired(true);
        ConnConfProperty servicename = new ConnConfProperty();
        servicename.setSchema(servicenameSchema);
        servicename.setValues(Collections.singletonList("Provisioning"));

        conf.add(endpoint);
        conf.add(servicename);

        // set connector configuration
        connectorTO.setConfiguration(conf);

        // set connector capabilities
        connectorTO.addCapability(ConnectorCapability.TWO_PHASES_CREATE);
        connectorTO.addCapability(ConnectorCapability.ONE_PHASE_CREATE);
        connectorTO.addCapability(ConnectorCapability.TWO_PHASES_UPDATE);

        Response response = connectorService.create(connectorTO);
        if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
            throw (RuntimeException) clientExceptionMapper.fromResponse(response);
        }

        ConnInstanceTO actual = getObject(response, ConnInstanceTO.class, connectorService);

        assertNotNull(actual);

        assertEquals(actual.getBundleName(), connectorTO.getBundleName());
        assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
        assertEquals(actual.getVersion(), connectorTO.getVersion());
        assertEquals("Display name", actual.getDisplayName());
        assertEquals(Integer.valueOf(15), actual.getConnRequestTimeout());
        assertEquals(connectorTO.getCapabilities(), actual.getCapabilities());

        Throwable t = null;

        // check for the updating
        connectorTO.setId(actual.getId());

        connectorTO.removeCapability(ConnectorCapability.TWO_PHASES_UPDATE);
        actual = null;
        try {
            connectorService.update(connectorTO.getId(), connectorTO);
            actual = connectorService.read(connectorTO.getId());
        } catch (HttpStatusCodeException e) {
            LOG.error("update failed", e);
            t = e;
        }

        assertNull(t);
        assertNotNull(actual);
        assertEquals(connectorTO.getCapabilities(), actual.getCapabilities());

        // check also for the deletion of the created object
        try {
            connectorService.delete(actual.getId());
        } catch (HttpStatusCodeException e) {
            LOG.error("delete failed", e);
            t = e;
        }

        assertNull(t);

        // check the non existence
        try {
            connectorService.read(actual.getId());
        } catch (HttpStatusCodeException e) {
            assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
        }
    }
View Full Code Here

        }
    }

    @Test
    public void update() {
        ConnInstanceTO connectorTO = new ConnInstanceTO();

        // set connector instance id
        connectorTO.setId(103L);

        // set connector version
        connectorTO.setVersion(connidSoapVersion);

        // set connector name
        connectorTO.setConnectorName("org.connid.bundles.soap.WebServiceConnector");

        // set bundle name
        connectorTO.setBundleName("org.connid.bundles.soap");

        connectorTO.setConnRequestTimeout(20);

        // set the connector configuration using PropertyTO
        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();

        ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
        endpointSchema.setName("endpoint");
        endpointSchema.setType(String.class.getName());
        endpointSchema.setRequired(true);
        ConnConfProperty endpoint = new ConnConfProperty();
        endpoint.setSchema(endpointSchema);
        endpoint.setValues(Collections.singletonList("http://localhost:8888/wssample/services"));

        ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
        servicenameSchema.setName("servicename");
        servicenameSchema.setType(String.class.getName());
        servicenameSchema.setRequired(true);
        ConnConfProperty servicename = new ConnConfProperty();
        servicename.setSchema(servicenameSchema);
        servicename.setValues(Collections.singletonList("Provisioning"));

        conf.add(endpoint);
        conf.add(servicename);

        // set connector configuration
        connectorTO.setConfiguration(conf);

        connectorService.update(connectorTO.getId(), connectorTO);
        ConnInstanceTO actual = connectorService.read(connectorTO.getId());

        assertNotNull(actual);

        actual = connectorService.read(actual.getId());

        assertNotNull(actual);
        assertEquals(actual.getBundleName(), connectorTO.getBundleName());
        assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
        assertEquals(actual.getVersion(), connectorTO.getVersion());
        assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
    }
View Full Code Here

    public void issueSYNCOPE10() {
        // ----------------------------------
        // Copy resource and connector in order to create new objects.
        // ----------------------------------
        // Retrieve a connector instance template.
        ConnInstanceTO connInstanceTO = connectorService.read(103L);

        assertNotNull(connInstanceTO);

        // check for resource
        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));

        assertEquals(4, resources.size());

        // Retrieve a resource TO template.
        ResourceTO resourceTO = resources.get(0);

        // Make it new.
        resourceTO.setName("newAbout103");

        // Make it new.
        connInstanceTO.setId(0);
        connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
        // ----------------------------------

        // ----------------------------------
        // Create a new connector instance.
        // ----------------------------------
        Response response = connectorService.create(connInstanceTO);
        if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
            throw (RuntimeException) clientExceptionMapper.fromResponse(response);
        }

        connInstanceTO = getObject(response, ConnInstanceTO.class, connectorService);

        assertNotNull(connInstanceTO);
        assertTrue(connInstanceTO.getCapabilities().isEmpty());

        long connId = connInstanceTO.getId();

        // Link resourceTO to the new connector instance.
        resourceTO.setConnectorId(connId);
        // ----------------------------------

        // ----------------------------------
        // Check for connector instance update after resource creation.
        // ----------------------------------
        response = resourceService.create(resourceTO);
        resourceTO = getObject(response, ResourceTO.class, resourceService);

        assertNotNull(resourceTO);

        resources = resourceService.list(connId);

        assertEquals(1, resources.size());
        // ----------------------------------

        // ----------------------------------
        // Check for spring bean.
        // ----------------------------------
        ConnInstanceTO connInstanceBean = connectorService.readByResource(resourceTO.getName());

        assertNotNull(connInstanceBean);
        assertTrue(connInstanceBean.getCapabilities().isEmpty());
        // ----------------------------------

        // ----------------------------------
        // Check for spring bean update after connector instance update.
        // ----------------------------------
        connInstanceTO.addCapability(ConnectorCapability.SEARCH);

        connectorService.update(connInstanceTO.getId(), connInstanceTO);
        ConnInstanceTO actual = connectorService.read(connInstanceTO.getId());

        assertNotNull(actual);
        assertFalse(connInstanceTO.getCapabilities().isEmpty());

        // check for spring bean update
View Full Code Here

        }
    }

    @Test
    public void read() {
        ConnInstanceTO connectorInstanceTO = connectorService.read(100L);
        assertNotNull(connectorInstanceTO);
    }
View Full Code Here

        assertFalse(props.isEmpty());
    }

    @Test
    public void checkHiddenProperty() {
        ConnInstanceTO connInstanceTO = connectorService.read(100L);

        boolean check = false;

        for (ConnConfProperty prop : connInstanceTO.getConfiguration()) {
            if ("receiveTimeout".equals(prop.getSchema().getName())) {
                check = true;
            }
        }
        assertTrue(check);
View Full Code Here

        }
    }

    @Test
    public void validate() {
        ConnInstanceTO connectorTO = new ConnInstanceTO();

        for (URI location : ConnIdBundleManager.getConnManagers().keySet()) {
            if (!location.getScheme().equals("file")) {
                connectorTO.setLocation(location.toString());
            }
        }

        // set connector version
        connectorTO.setVersion(connidDbTableVersion);

        // set connector name
        connectorTO.setConnectorName("org.connid.bundles.db.table.DatabaseTableConnector");

        // set bundle name
        connectorTO.setBundleName("org.connid.bundles.db.table");

        connectorTO.setDisplayName("H2Test");

        // set the connector configuration using PropertyTO
        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();

        ConnConfPropSchema userSchema = new ConnConfPropSchema();
        userSchema.setName("user");
        userSchema.setType(String.class.getName());
        userSchema.setRequired(false);
        ConnConfProperty user = new ConnConfProperty();
        user.setSchema(userSchema);
        user.setValues(Collections.singletonList("sa"));

        ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
        keyColumnSchema.setName("keyColumn");
        keyColumnSchema.setType(String.class.getName());
        keyColumnSchema.setRequired(true);
        ConnConfProperty keyColumn = new ConnConfProperty();
        keyColumn.setSchema(keyColumnSchema);
        keyColumn.setValues(Collections.singletonList("id"));

        ConnConfPropSchema jdbcUrlTemplateSchema = new ConnConfPropSchema();
        jdbcUrlTemplateSchema.setName("jdbcUrlTemplate");
        jdbcUrlTemplateSchema.setType(String.class.getName());
        jdbcUrlTemplateSchema.setRequired(true);
        ConnConfProperty jdbcUrlTemplate = new ConnConfProperty();
        jdbcUrlTemplate.setSchema(jdbcUrlTemplateSchema);
        jdbcUrlTemplate.setValues(Collections.singletonList("jdbc:h2:tcp://localhost:9092/testdb"));

        ConnConfPropSchema passwordColumnSchema = new ConnConfPropSchema();
        passwordColumnSchema.setName("passwordColumn");
        passwordColumnSchema.setType(String.class.getName());
        passwordColumnSchema.setRequired(true);
        ConnConfProperty passwordColumn = new ConnConfProperty();
        passwordColumn.setSchema(passwordColumnSchema);
        passwordColumn.setValues(Collections.singletonList("password"));

        ConnConfPropSchema tableSchema = new ConnConfPropSchema();
        tableSchema.setName("table");
        tableSchema.setType(String.class.getName());
        tableSchema.setRequired(true);
        ConnConfProperty table = new ConnConfProperty();
        table.setSchema(tableSchema);
        table.setValues(Collections.singletonList("test"));

        ConnConfPropSchema passwordSchema = new ConnConfPropSchema();
        passwordSchema.setName("password");
        passwordSchema.setType(GuardedString.class.getName());
        passwordSchema.setRequired(true);
        ConnConfProperty password = new ConnConfProperty();
        password.setSchema(passwordSchema);
        password.setValues(Collections.singletonList("sa"));

        ConnConfPropSchema jdbcDriverSchema = new ConnConfPropSchema();
        jdbcDriverSchema.setName("jdbcDriver");
        jdbcDriverSchema.setType(String.class.getName());
        jdbcDriverSchema.setRequired(true);
        ConnConfProperty jdbcDriver = new ConnConfProperty();
        jdbcDriver.setSchema(jdbcDriverSchema);
        jdbcDriver.setValues(Collections.singletonList("org.h2.Driver"));

        conf.add(user);
        conf.add(keyColumn);
        conf.add(jdbcUrlTemplate);
        conf.add(passwordColumn);
        conf.add(table);
        conf.add(password);
        conf.add(jdbcDriver);

        // set connector configuration
        connectorTO.setConfiguration(conf);

        Boolean verify = connectorService.check(connectorTO);

        assertTrue(verify);
View Full Code Here

        assertFalse(verify);
    }

    @Test
    public void getSchemaNames() {
        ConnInstanceTO conn = connectorService.read(101L);

        List<SchemaTO> schemaNames = connectorService.getSchemaNames(conn.getId(), conn, true);
        assertNotNull(schemaNames);
        assertFalse(schemaNames.isEmpty());
        assertNotNull(schemaNames.get(0).getName());
        assertNull(schemaNames.get(0).getEnumerationValues());

        schemaNames = connectorService.getSchemaNames(conn.getId(), conn, false);

        assertNotNull(schemaNames);
        assertEquals(0, schemaNames.size());

        conn = connectorService.read(104L);

        // to be used with overridden properties
        conn.getConfiguration().clear();

        schemaNames = connectorService.getSchemaNames(conn.getId(), conn, true);
        assertNotNull(schemaNames);
        assertFalse(schemaNames.isEmpty());
    }
View Full Code Here

    @Test
    public void issueSYNCOPE112() {
        // ----------------------------------------
        // Create a new connector
        // ----------------------------------------
        ConnInstanceTO connectorTO = new ConnInstanceTO();

        connectorTO.setLocation(connectorService.read(100L).getLocation());

        // set connector version
        connectorTO.setVersion(connidSoapVersion);

        // set connector name
        connectorTO.setConnectorName("org.connid.bundles.soap.WebServiceConnector");

        // set bundle name
        connectorTO.setBundleName("org.connid.bundles.soap");

        // set display name
        connectorTO.setDisplayName("WSSoap");

        // set the connector configuration using PropertyTO
        Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();

        ConnConfPropSchema userSchema = new ConnConfPropSchema();
        userSchema.setName("endpoint");
        userSchema.setType(String.class.getName());
        userSchema.setRequired(true);
        ConnConfProperty endpoint = new ConnConfProperty();
        endpoint.setSchema(userSchema);
        endpoint.setValues(Collections.singletonList("http://localhost:9080/does_not_work"));
        endpoint.setOverridable(true);

        ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
        keyColumnSchema.setName("servicename");
        keyColumnSchema.setType(String.class.getName());
        keyColumnSchema.setRequired(true);
        ConnConfProperty servicename = new ConnConfProperty();
        servicename.setSchema(keyColumnSchema);
        servicename.setValues(
                Collections.singletonList("org.connid.bundles.soap.provisioning.interfaces.Provisioning"));
        servicename.setOverridable(false);

        conf.add(endpoint);
        conf.add(servicename);

        // set connector configuration
        connectorTO.setConfiguration(conf);

        try {
            assertFalse(connectorService.check(connectorTO));

            Response response = connectorService.create(connectorTO);
            if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
                throw (RuntimeException) clientExceptionMapper.fromResponse(response);
            }

            connectorTO = getObject(response, ConnInstanceTO.class, configurationService);
            assertNotNull(connectorTO);
            // ----------------------------------------

            // ----------------------------------------
            // create a resourceTO
            // ----------------------------------------
            String resourceName = "checkForPropOverriding";
            ResourceTO resourceTO = new ResourceTO();

            resourceTO.setName(resourceName);
            resourceTO.setConnectorId(connectorTO.getId());

            conf = new HashSet<ConnConfProperty>();
            endpoint.setValues(Collections.singletonList("http://localhost:9080/wssample/services/provisioning"));
            conf.add(endpoint);

            resourceTO.setConnectorConfigurationProperties(conf);

            MappingTO mapping = new MappingTO();
            resourceTO.setUmapping(mapping);

            MappingItemTO mapItem = new MappingItemTO();
            mapItem.setExtAttrName("uid");
            mapItem.setIntAttrName("userId");
            mapItem.setIntMappingType(IntMappingType.UserSchema);
            mapItem.setAccountid(true);
            mapping.setAccountIdItem(mapItem);
            // ----------------------------------------

            // ----------------------------------------
            // Check connection without saving the resource ....
            // ----------------------------------------
            assertTrue(resourceService.check(resourceTO));
            // ----------------------------------------
        } finally {
            // Remove connector from db to make test re-runnable
            connectorService.delete(connectorTO.getId());
        }
    }
View Full Code Here

    @Test
    public void bulkAction() {
        final BulkAction bulkAction = new BulkAction();
        bulkAction.setOperation(BulkAction.Type.DELETE);

        ConnInstanceTO conn = connectorService.read(101L);

        conn.setId(0);
        conn.setDisplayName("forBulk1");

        bulkAction.addTarget(String.valueOf(
                getObject(connectorService.create(conn), ConnInstanceTO.class, connectorService).getId()));

        conn.setDisplayName("forBulk2");

        bulkAction.addTarget(String.valueOf(
                getObject(connectorService.create(conn), ConnInstanceTO.class, connectorService).getId()));

View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.ConnInstanceTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.