Search in sources :

Example 6 with ArchetypeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType in project midpoint by Evolveum.

the class AssignmentObjectRelation method addArchetypeRef.

public void addArchetypeRef(PrismObject<ArchetypeType> archetype) {
    if (archetypeRefs == null) {
        archetypeRefs = new ArrayList<>();
    }
    ObjectReferenceType ref = MiscSchemaUtil.createObjectReference(archetype, ArchetypeType.class);
    archetypeRefs.add(ref);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 7 with ArchetypeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType in project midpoint by Evolveum.

the class TestRepositoryCache method test310AddInIterativeSearch.

/**
 * MID-6250
 */
@Test
public void test310AddInIterativeSearch() throws SchemaException, ObjectAlreadyExistsException {
    given();
    PrismContext prismContext = getPrismContext();
    OperationResult result = createOperationResult();
    clearStatistics();
    clearCaches();
    String costCenter = "cc_" + getTestNameShort();
    String name1 = getTestNameShort() + ".1";
    String name2 = getTestNameShort() + ".2";
    PrismObject<ArchetypeType> archetype1 = new ArchetypeType(prismContext).name(name1).costCenter(costCenter).asPrismObject();
    repositoryCache.addObject(archetype1, null, result);
    when();
    ObjectQuery query = prismContext.queryFor(ArchetypeType.class).item(ArchetypeType.F_COST_CENTER).eq(costCenter).build();
    AtomicInteger found = new AtomicInteger(0);
    ResultHandler<ArchetypeType> handler = (object, result1) -> {
        try {
            PrismObject<ArchetypeType> archetype2 = new ArchetypeType(prismContext).name(name2).costCenter(costCenter).asPrismObject();
            repositoryCache.addObject(archetype2, null, result);
        } catch (SchemaException | ObjectAlreadyExistsException e) {
            throw new AssertionError(e);
        }
        found.incrementAndGet();
        return true;
    };
    repositoryCache.searchObjectsIterative(ArchetypeType.class, query, handler, null, false, result);
    dumpStatistics();
    assertThat(found.get()).as("objects found").isEqualTo(1);
    List<PrismObject<ArchetypeType>> listAfter = repositoryCache.searchObjects(ArchetypeType.class, query, null, result);
    then();
    assertThat(listAfter.size()).as("objects found after").isEqualTo(2);
}
Also used : BeforeSuite(org.testng.annotations.BeforeSuite) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) java.util(java.util) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) QueryKey(com.evolveum.midpoint.repo.cache.local.QueryKey) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Autowired(org.springframework.beans.factory.annotation.Autowired) OperationPerformanceInformation(com.evolveum.midpoint.repo.api.perf.OperationPerformanceInformation) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) PerformanceInformation(com.evolveum.midpoint.repo.api.perf.PerformanceInformation) PrettyPrinter(com.evolveum.midpoint.util.PrettyPrinter) StringUtils(org.apache.commons.lang3.StringUtils) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) GlobalObjectCache(com.evolveum.midpoint.repo.cache.global.GlobalObjectCache) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) REPOSITORY_IMPL_NAME(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService.REPOSITORY_IMPL_NAME) PrismContext(com.evolveum.midpoint.prism.PrismContext) CachePerformanceInformationUtil(com.evolveum.midpoint.schema.statistics.CachePerformanceInformationUtil) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) GlobalQueryCache(com.evolveum.midpoint.repo.cache.global.GlobalQueryCache) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) RepositoryPerformanceInformationUtil(com.evolveum.midpoint.schema.statistics.RepositoryPerformanceInformationUtil) AbstractSpringTest(com.evolveum.midpoint.test.util.AbstractSpringTest) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) CachePerformanceCollector(com.evolveum.midpoint.util.caching.CachePerformanceCollector) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ArchetypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType) PrismObject(com.evolveum.midpoint.prism.PrismObject) AssertJUnit.fail(org.testng.AssertJUnit.fail) InfraTestMixin(com.evolveum.midpoint.test.util.InfraTestMixin) AtomicLong(java.util.concurrent.atomic.AtomicLong) GlobalVersionCache(com.evolveum.midpoint.repo.cache.global.GlobalVersionCache) MidPointConstants(com.evolveum.midpoint.schema.constants.MidPointConstants) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PostConstruct(javax.annotation.PostConstruct) PrismTestUtil.displayCollection(com.evolveum.midpoint.prism.util.PrismTestUtil.displayCollection) GlobalCacheObjectValue(com.evolveum.midpoint.repo.cache.global.GlobalCacheObjectValue) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) NotNull(org.jetbrains.annotations.NotNull) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) PrismObject(com.evolveum.midpoint.prism.PrismObject) ArchetypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PrismContext(com.evolveum.midpoint.prism.PrismContext) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) AbstractSpringTest(com.evolveum.midpoint.test.util.AbstractSpringTest)

Aggregations

ArchetypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)4 SqaleRepositoryService (com.evolveum.midpoint.repo.sqale.SqaleRepositoryService)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 PrismTestUtil (com.evolveum.midpoint.prism.util.PrismTestUtil)3 PrismTestUtil.displayCollection (com.evolveum.midpoint.prism.util.PrismTestUtil.displayCollection)3 PrismTestUtil.getPrismContext (com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext)3 OperationPerformanceInformation (com.evolveum.midpoint.repo.api.perf.OperationPerformanceInformation)3 PerformanceInformation (com.evolveum.midpoint.repo.api.perf.PerformanceInformation)3 GlobalCacheObjectValue (com.evolveum.midpoint.repo.cache.global.GlobalCacheObjectValue)3 GlobalObjectCache (com.evolveum.midpoint.repo.cache.global.GlobalObjectCache)3 GlobalQueryCache (com.evolveum.midpoint.repo.cache.global.GlobalQueryCache)3