Search in sources :

Example 1 with BucketContentFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory in project midpoint by Evolveum.

the class TestBucketingStatic method test110FilterExplicitBuckets.

/**
 * Tests the get-complete cycle (4x) with explicit, filter-based segmentation providing 3 buckets.
 */
@Test
public void test110FilterExplicitBuckets() throws Exception {
    OperationResult result = createOperationResult();
    taskAdd(TASK_110, result);
    Task task = taskManager.getTaskPlain(TASK_110.oid, result);
    BucketContentFactory contentFactory = createContentFactory(getDistributionDefinition(task));
    when("1st get");
    WorkBucketType bucket = getWorkBucket(task, result);
    Integer numberOfBuckets = contentFactory.estimateNumberOfBuckets();
    then("1st get");
    assertBucket(bucket, null, 1);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(ShadowType.class).item(ShadowType.F_NAME).lt(new PolyString("a", "a")).build());
    Task taskAfter = refreshTaskAndAssertOptimizedBuckets(task, result);
    assertEquals("Wrong # of estimated buckets (task)", Integer.valueOf(3), getNumberOfBuckets(taskAfter));
    assertEquals("Wrong # of estimated buckets (API)", Integer.valueOf(3), numberOfBuckets);
    when("complete and 2nd get");
    bucketingManager.completeWorkBucket(task.getOid(), null, ActivityPath.empty(), 1, null, null, result);
    bucket = getWorkBucket(task, result);
    then("complete and 2nd get");
    assertBucket(bucket, null, 2);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(ShadowType.class).item(ShadowType.F_NAME).ge(new PolyString("a", "a")).and().item(ShadowType.F_NAME).lt(new PolyString("m", "m")).build());
    refreshTaskAndAssertOptimizedBuckets(task, result);
    when("complete and 3rd get");
    bucketingManager.completeWorkBucket(task.getOid(), null, ActivityPath.empty(), 2, null, null, result);
    bucket = getWorkBucket(task, result);
    then("complete and 3rd get");
    assertBucket(bucket, null, 3);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(ShadowType.class).item(ShadowType.F_NAME).ge(new PolyString("m", "m")).build());
    refreshTaskAndAssertOptimizedBuckets(task, result);
    when("complete and 4th get");
    bucketingManager.completeWorkBucket(task.getOid(), null, ActivityPath.empty(), 3, null, null, result);
    bucket = getWorkBucket(task, result);
    then("complete and 4th get");
    assertNull("Non-null bucket obtained", bucket);
    refreshTaskAndAssertOptimizedBuckets(task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Example 2 with BucketContentFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory in project midpoint by Evolveum.

the class TestBucketingStatic method test010StringPrefixBucketsLegacy.

/**
 * Tests obtaining buckets with prefix-based string segmentation using legacy specification of boundary characters.
 */
@Test
public void test010StringPrefixBucketsLegacy() throws Exception {
    OperationResult result = createOperationResult();
    taskAdd(TASK_010, result);
    Task task = taskManager.getTaskPlain(TASK_010.oid, result);
    ActivityStateType workState = new ActivityStateType(prismContext);
    when();
    BucketFactory allocator = BucketFactory.create(getDistributionDefinition(task), null, beans);
    BucketContentFactory contentFactory = allocator.getContentFactory();
    then();
    assertBoundariesAndBucketCount(contentFactory, Arrays.asList("a", "01abc", "01abc"), 25);
    WorkBucketType bucket = assumeNextPrefix(allocator, workState, "a00", 1);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(UserType.class).item(UserType.F_NAME).startsWith("a00").matchingNorm().build());
    assumeNextPrefix(allocator, workState, "a01", 2);
    assumeNextPrefix(allocator, workState, "a0a", 3);
    assumeNextPrefix(allocator, workState, "a0b", 4);
    assumeNextPrefix(allocator, workState, "a0c", 5);
    assumeNextPrefix(allocator, workState, "a10", 6);
    assumeNextPrefix(allocator, workState, "a11", 7);
    assumeNextPrefix(allocator, workState, "a1a", 8);
    assumeNextPrefix(allocator, workState, "a1b", 9);
    assumeNextPrefix(allocator, workState, "a1c", 10);
    assumeNextPrefix(allocator, workState, "aa0", 11);
    assumeNextPrefix(allocator, workState, "aa1", 12);
    assumeNextPrefix(allocator, workState, "aaa", 13);
    assumeNextPrefix(allocator, workState, "aab", 14);
    assumeNextPrefix(allocator, workState, "aac", 15);
    assumeNextPrefix(allocator, workState, "ab0", 16);
    assumeNextPrefix(allocator, workState, "ab1", 17);
    assumeNextPrefix(allocator, workState, "aba", 18);
    assumeNextPrefix(allocator, workState, "abb", 19);
    assumeNextPrefix(allocator, workState, "abc", 20);
    assumeNextPrefix(allocator, workState, "ac0", 21);
    assumeNextPrefix(allocator, workState, "ac1", 22);
    assumeNextPrefix(allocator, workState, "aca", 23);
    assumeNextPrefix(allocator, workState, "acb", 24);
    assumeNextPrefix(allocator, workState, "acc", 25);
    assumeNoNextBucket(allocator, workState);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) BucketFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Example 3 with BucketContentFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory in project midpoint by Evolveum.

the class TestBucketingStatic method test050OidDepth2.

/**
 * Tests the OID depth 2 buckets strategy. Checks that it provides the correct bucket boundaries.
 */
@Test
public void test050OidDepth2() throws Exception {
    OperationResult result = createOperationResult();
    taskAdd(TASK_050, result);
    Task task = taskManager.getTaskPlain(TASK_050.oid, result);
    when();
    BucketContentFactory contentFactory = createContentFactory(getDistributionDefinition(task));
    then();
    assertBoundaries(contentFactory, Arrays.asList("0123456789abcdef", "0123456789abcdef"));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Example 4 with BucketContentFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory in project midpoint by Evolveum.

the class TestBucketingStatic method test020StringExactValueBuckets.

/**
 * Tests obtaining buckets with exact-match-based string segmentation using new specification of boundary characters.
 */
@Test
public void test020StringExactValueBuckets() throws Exception {
    OperationResult result = createOperationResult();
    taskAdd(TASK_020, result);
    Task task = taskManager.getTaskPlain(TASK_020.oid, result);
    ActivityStateType workState = new ActivityStateType(prismContext);
    when();
    BucketFactory bucketFactory = BucketFactory.create(getDistributionDefinition(task), null, beans);
    BucketContentFactory contentFactory = bucketFactory.getContentFactory();
    then();
    assertBoundariesAndBucketCount(contentFactory, Arrays.asList("a", "01abc", "01abc"), 25);
    WorkBucketType bucket = assumeNextValue(bucketFactory, workState, "a00", 1);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(UserType.class).item(UserType.F_NAME).eq("a00").matchingNorm().build());
    assumeNextValue(bucketFactory, workState, "a01", 2);
    assumeNextValue(bucketFactory, workState, "a0a", 3);
    assumeNextValue(bucketFactory, workState, "a0b", 4);
    assumeNextValue(bucketFactory, workState, "a0c", 5);
    assumeNextValue(bucketFactory, workState, "a10", 6);
    assumeNextValue(bucketFactory, workState, "a11", 7);
    assumeNextValue(bucketFactory, workState, "a1a", 8);
    assumeNextValue(bucketFactory, workState, "a1b", 9);
    assumeNextValue(bucketFactory, workState, "a1c", 10);
    assumeNextValue(bucketFactory, workState, "aa0", 11);
    assumeNextValue(bucketFactory, workState, "aa1", 12);
    assumeNextValue(bucketFactory, workState, "aaa", 13);
    assumeNextValue(bucketFactory, workState, "aab", 14);
    assumeNextValue(bucketFactory, workState, "aac", 15);
    assumeNextValue(bucketFactory, workState, "ab0", 16);
    assumeNextValue(bucketFactory, workState, "ab1", 17);
    assumeNextValue(bucketFactory, workState, "aba", 18);
    assumeNextValue(bucketFactory, workState, "abb", 19);
    assumeNextValue(bucketFactory, workState, "abc", 20);
    assumeNextValue(bucketFactory, workState, "ac0", 21);
    assumeNextValue(bucketFactory, workState, "ac1", 22);
    assumeNextValue(bucketFactory, workState, "aca", 23);
    assumeNextValue(bucketFactory, workState, "acb", 24);
    assumeNextValue(bucketFactory, workState, "acc", 25);
    assumeNoNextBucket(bucketFactory, workState);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) BucketFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Example 5 with BucketContentFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory in project midpoint by Evolveum.

the class TestBucketingStatic method test030StringIntervalBuckets.

/**
 * Tests obtaining buckets with interval-based string segmentation using new specification of boundary characters.
 */
@Test
public void test030StringIntervalBuckets() throws Exception {
    OperationResult result = createOperationResult();
    taskAdd(TASK_030, result);
    Task task = taskManager.getTaskPlain(TASK_030.oid, result);
    ActivityStateType workState = new ActivityStateType(prismContext);
    when();
    BucketFactory allocator = BucketFactory.create(getDistributionDefinition(task), null, beans);
    BucketContentFactory contentFactory = allocator.getContentFactory();
    then();
    assertBoundariesAndBucketCount(contentFactory, Arrays.asList("05am", "0am"), 13);
    WorkBucketType bucket = assumeNextInterval(allocator, workState, null, "00", 1);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(UserType.class).item(UserType.F_NAME).lt("00").matchingNorm().build());
    bucket = assumeNextInterval(allocator, workState, "00", "0a", 2);
    assertNarrowedQuery(task, bucket, prismContext.queryFor(UserType.class).item(UserType.F_NAME).ge("00").matchingNorm().and().item(UserType.F_NAME).lt("0a").matchingNorm().build());
    assumeNextInterval(allocator, workState, "0a", "0m", 3);
    assumeNextInterval(allocator, workState, "0m", "50", 4);
    assumeNextInterval(allocator, workState, "50", "5a", 5);
    assumeNextInterval(allocator, workState, "5a", "5m", 6);
    assumeNextInterval(allocator, workState, "5m", "a0", 7);
    assumeNextInterval(allocator, workState, "a0", "aa", 8);
    assumeNextInterval(allocator, workState, "aa", "am", 9);
    assumeNextInterval(allocator, workState, "am", "m0", 10);
    assumeNextInterval(allocator, workState, "m0", "ma", 11);
    assumeNextInterval(allocator, workState, "ma", "mm", 12);
    assumeNextInterval(allocator, workState, "mm", null, 13);
    assumeNoNextBucket(allocator, workState);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) BucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory) StringBucketContentFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory) BucketFactory(com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractRepoCommonTest(com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)

Aggregations

AbstractRepoCommonTest (com.evolveum.midpoint.repo.common.AbstractRepoCommonTest)6 BucketContentFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory)6 StringBucketContentFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)6 Task (com.evolveum.midpoint.task.api.Task)6 Test (org.testng.annotations.Test)6 BucketFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1