Search in sources :

Example 1 with BucketFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory 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 2 with BucketFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory 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 3 with BucketFactory

use of com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory 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)3 BucketContentFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketContentFactory)3 BucketFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.BucketFactory)3 StringBucketContentFactory (com.evolveum.midpoint.repo.common.activity.run.buckets.segmentation.StringBucketContentFactory)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 Test (org.testng.annotations.Test)3