Package org.apache.syncope.client.to

Examples of org.apache.syncope.client.to.ResourceTO


    }

    @Test
    public void createWithWrongMapping() {
        String resourceName = "ws-target-resource-create-wrong";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTO.setExtAttrName("email");
        // missing intAttrName ...
        resourceTO.addMapping(schemaMappingTO);

        Throwable t = null;

        try {
View Full Code Here


    }

    @Test(expected = SyncopeClientCompositeErrorException.class)
    public void createWithoutExtAttr() {
        String resourceName = "ws-target-resource-create-wrong";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTO.setIntAttrName("usernane");
        // missing extAttrName ...
        resourceTO.addMapping(schemaMappingTO);

        restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);
    }
View Full Code Here

    }

    @Test
    public void createWithPasswordPolicy() {
        String resourceName = "res-with-password-policy";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);
        resourceTO.setPasswordPolicy(4L);

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("uid");
        schemaMappingTO.setIntAttrName("userId");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);

        assertNotNull(actual);

        // check the existence

        actual = restTemplate.getForObject(BASE_URL + "resource/read/{resourceName}.json", ResourceTO.class,
                resourceName);

        assertNotNull(actual);
        assertNotNull(actual.getPasswordPolicy());
        assertEquals(4L, (long) actual.getPasswordPolicy());
    }
View Full Code Here

    }

    @Test
    public void updateWithException() {
        try {
            ResourceTO resourceTO = new ResourceTO();

            resourceTO.setName("resourcenotfound");

            restTemplate.postForObject(BASE_URL + "resource/update.json", resourceTO, ResourceTO.class);
        } catch (HttpStatusCodeException e) {
            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
        }
View Full Code Here

    }

    @Test
    public void update() {
        final String resourceName = "ws-target-resource-update";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(101L);

        List<SchemaMappingTO> schemaMappingTOs = new ArrayList<SchemaMappingTO>();

        // Update with an existing and already assigned mapping
        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setId(112L);
        schemaMappingTO.setExtAttrName("test3");
        schemaMappingTO.setIntAttrName("fullname");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTOs.add(schemaMappingTO);

        // Update defining new mappings
        for (int i = 4; i < 6; i++) {
            schemaMappingTO = new SchemaMappingTO();
            schemaMappingTO.setExtAttrName("test" + i);
            schemaMappingTO.setIntAttrName("fullname");
            schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
            schemaMappingTOs.add(schemaMappingTO);
        }
        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("username");
        schemaMappingTO.setIntAttrName("fullname");
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        schemaMappingTOs.add(schemaMappingTO);

        resourceTO.setMappings(schemaMappingTOs);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/update.json", resourceTO, ResourceTO.class);

        assertNotNull(actual);

        // check the existence

        List<SchemaMappingTO> mappings = actual.getMappings();

        assertNotNull(mappings);

        assertEquals(4, mappings.size());
    }
View Full Code Here

    @Test
    public void updateResetSyncToken() {
        // pre condition: sync token is set
        String resourceName = "ws-target-resource-update-resetsynctoken";
        ResourceTO pre = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class,
                resourceName);
        assertNotNull(pre.getSyncToken());

        pre.setSyncToken(null);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/update.json", pre, ResourceTO.class);

        // check that the synctoken has been reset
        assertNull(actual.getSyncToken());
    }
View Full Code Here

    @Test
    public void delete() {
        final String resourceName = "ws-target-resource-delete";

        ResourceTO deletedResource =
                restTemplate.getForObject(BASE_URL + "resource/delete/{resourceName}.json", ResourceTO.class,
                        resourceName);
        assertNotNull(deletedResource);

        try {
View Full Code Here

        assertNotNull(actuals.get(0));
    }

    @Test
    public void read() {
        ResourceTO actual = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json",
                ResourceTO.class, "resource-testdb");

        assertNotNull(actual);
    }
View Full Code Here

        UserTO userTO = getSampleTO("suspreactonresource@syncope.apache.org");

        userTO.getMemberships().clear();
        userTO.getResources().clear();

        ResourceTO dbTable = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json",
                ResourceTO.class, "resource-testdb");

        assertNotNull(dbTable);
        userTO.addResource(dbTable.getName());

        ResourceTO ldap = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class,
                "resource-ldap");

        assertNotNull(ldap);
        userTO.addResource(ldap.getName());

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);

        assertNotNull(userTO);
        assertEquals("active", userTO.getStatus());

        String query = "?resourceNames=" + dbTable.getName() + "&resourceNames=" + ldap.getName()
                + "&performLocally=true"; // check also performLocally

        userTO = restTemplate.getForObject(BASE_URL + "user/suspend/" + userTO.getId() + query, UserTO.class);

        assertNotNull(userTO);
        assertEquals("suspended", userTO.getStatus());

        String dbTableUID = userTO.getUsername();
        assertNotNull(dbTableUID);

        ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
                + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, dbTable.getName(), dbTableUID);

        assertFalse(Boolean.parseBoolean(connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME).getValues().
                get(0)));

        String ldapUID = userTO.getUsername();
        assertNotNull(ldapUID);

        connObjectTO = restTemplate.getForObject(BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
                ConnObjectTO.class, ldap.getName(), ldapUID);

        assertNotNull(connObjectTO);

        query = "?resourceNames=" + ldap.getName() + "&performLocally=false"; // check also performLocally

        userTO = restTemplate.getForObject(BASE_URL + "user/reactivate/" + userTO.getId() + query, UserTO.class);

        assertNotNull(userTO);
        assertEquals("suspended", userTO.getStatus());
View Full Code Here

                + "resource/list.json?connInstanceId=103", ResourceTO[].class));

        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");
        // ----------------------------------

        // ----------------------------------
        // Create a new connector instance.
        // ----------------------------------
        connInstanceTO =
                restTemplate.postForObject(BASE_URL + "connector/create.json", connInstanceTO, ConnInstanceTO.class);

        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.
        // ----------------------------------
        resourceTO = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);

        assertNotNull(resourceTO);

        resources = Arrays.asList(restTemplate.getForObject(BASE_URL + "resource/list.json?connInstanceId=" + connId,
                ResourceTO[].class));

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

        // ----------------------------------
        // Check for spring bean.
        // ----------------------------------
        ConnInstanceTO connInstanceBean = restTemplate.getForObject(
                BASE_URL + "connector/{resourceName}/connectorBean", ConnInstanceTO.class, resourceTO.getName());

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

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

        ConnInstanceTO actual = (ConnInstanceTO) restTemplate.postForObject(BASE_URL + "connector/update.json",
                connInstanceTO, ConnInstanceTO.class);

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

        // check for spring bean update
        connInstanceBean = restTemplate.getForObject(BASE_URL + "connector/{resourceName}/connectorBean",
                ConnInstanceTO.class, resourceTO.getName());

        assertFalse(connInstanceBean.getCapabilities().isEmpty());
        // ----------------------------------
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.to.ResourceTO

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.