Package org.apache.syncope.client.to

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


    }

    @Test
    public void issueSYNCOPE230() {
        // 1. read SyncTask for resource-db-sync (table TESTSYNC on external H2)
        SyncTaskTO task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, 10);
        assertNotNull(task);

        int preSyncSize = task.getExecutions().size();

        // 2. execute the SyncTask for the first time
        TaskExecTO execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class,
                task.getId());
        assertEquals("JOB_FIRED", execution.getStatus());

        int i = 0;
        final int maxit = 20;
        do {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, task.getId());

            assertNotNull(task);
            assertNotNull(task.getExecutions());

            i++;
        } while (preSyncSize == task.getExecutions().size() && i < maxit);
        assertEquals(1, task.getExecutions().size());

        // 3. read e-mail address for user created by the SyncTask first execution
        UserTO userTO = restTemplate.getForObject(
                BASE_URL + "user/readByUsername/{username}.json", UserTO.class, "issuesyncope230");
        assertNotNull(userTO);
        String email = userTO.getAttributeMap().get("email").getValues().iterator().next();
        assertNotNull(email);

        // 4. update TESTSYNC on external H2 by changing e-mail address
        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
        jdbcTemplate.execute("UPDATE TESTSYNC SET email='updatedSYNCOPE230@syncope.apache.org'");

        // 5. re-execute the SyncTask
        execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class,
                task.getId());
        assertEquals("JOB_FIRED", execution.getStatus());

        preSyncSize = task.getExecutions().size();
        i = 0;
        do {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, task.getId());

            assertNotNull(task);
            assertNotNull(task.getExecutions());

            i++;
        } while (preSyncSize == task.getExecutions().size() && i < maxit);
        assertEquals(2, task.getExecutions().size());

        // 6. verify that the e-mail was updated
        userTO = restTemplate.getForObject(
                BASE_URL + "user/readByUsername/{username}.json", UserTO.class, "issuesyncope230");
        assertNotNull(userTO);
View Full Code Here


        assertNotNull(userTO);
        assertEquals(1, userTO.getPropagationTOs().size());
        assertTrue(userTO.getPropagationTOs().get(0).getStatus().isSuccessful());

        // Update sync task
        SyncTaskTO task = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, 7);
        task.setFullReconciliation(true);
        assertNotNull(task);

        //  add user template
        UserTO template = new UserTO();

        AttributeTO attrTO = new AttributeTO();
        attrTO.setSchema("firstname");
        attrTO.setValues(Collections.singletonList(""));
        template.addAttribute(attrTO);

        attrTO = new AttributeTO();
        attrTO.setSchema("userId");
        attrTO.addValue("'test'");
        template.addAttribute(attrTO);

        attrTO = new AttributeTO();
        attrTO.setSchema("'fullname");
        attrTO.addValue("'test'");
        template.addAttribute(attrTO);

        attrTO = new AttributeTO();
        attrTO.setSchema("surname");
        attrTO.addValue("'test'");
        template.addAttribute(attrTO);

        task.setUserTemplate(template);

        SyncTaskTO actual = restTemplate.postForObject(BASE_URL + "task/update/sync", task, SyncTaskTO.class);
        assertNotNull(actual);
        assertEquals(task.getId(), actual.getId());

        // read executions before sync (dryrun test could be executed before)
        int preSyncSize = actual.getExecutions().size();

        TaskExecTO execution = restTemplate.postForObject(BASE_URL + "task/execute/{taskId}", null, TaskExecTO.class,
                actual.getId());
        assertEquals("JOB_FIRED", execution.getStatus());

        int i = 0;
        int maxit = 20;

        // wait for sync completion (executions incremented)
        do {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            actual = restTemplate.getForObject(BASE_URL + "task/read/{taskId}", SyncTaskTO.class, actual.getId());

            assertNotNull(actual);
            assertNotNull(actual.getExecutions());

            i++;

        } while (preSyncSize == actual.getExecutions().size() && i < maxit);

        assertEquals(2, actual.getExecutions().size());

        final String status = actual.getExecutions().get(1).getStatus();

        assertNotNull(status);
        assertTrue(PropagationTaskExecStatus.valueOf(status).isSuccessful());

        final UserTO updateTO =
View Full Code Here

TOP

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

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.