Search in sources :

Example 1 with SchemaService

use of org.hisp.dhis.schema.SchemaService in project dhis2-core by dhis2.

the class GeoJsonAttributesCheckTest method setUpTest.

@BeforeEach
public void setUpTest() {
    organisationUnit = new OrganisationUnit();
    organisationUnit.setName("A");
    attribute = new Attribute();
    attribute.setUid("geoJson");
    attribute.setName("geoJson");
    validationContext = Mockito.mock(ValidationContext.class);
    Schema schema = new Schema(OrganisationUnit.class, "organisationUnit", "organisationUnits");
    Property property = new Property();
    property.setPersisted(true);
    schema.getPropertyMap().put("attributeValues", property);
    SchemaService schemaService = Mockito.mock(SchemaService.class);
    when(schemaService.getDynamicSchema(OrganisationUnit.class)).thenReturn(schema);
    when(validationContext.getSchemaService()).thenReturn(schemaService);
    Preheat preheat = Mockito.mock(Preheat.class);
    when(preheat.getAttributeIdsByValueType(OrganisationUnit.class, ValueType.GEOJSON)).thenReturn(Sets.newSet("geoJson"));
    objectBundle = Mockito.mock(ObjectBundle.class);
    when(objectBundle.getPreheat()).thenReturn(preheat);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ObjectBundle(org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle) Attribute(org.hisp.dhis.attribute.Attribute) SchemaService(org.hisp.dhis.schema.SchemaService) Schema(org.hisp.dhis.schema.Schema) Preheat(org.hisp.dhis.preheat.Preheat) Property(org.hisp.dhis.schema.Property) ValidationContext(org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SchemaService

use of org.hisp.dhis.schema.SchemaService in project dhis2-core by dhis2.

the class DefaultFieldFilterServiceTest method setUp.

@BeforeEach
public void setUp() {
    final Set<NodeTransformer> nodeTransformers = new HashSet<>();
    nodeTransformers.add(new PluckNodeTransformer());
    final SchemaService schemaService = new DefaultSchemaService(new DefaultPropertyIntrospectorService(new JacksonPropertyIntrospector()), sessionFactory);
    CacheProvider cacheProvider = mock(CacheProvider.class);
    when(cacheProvider.createPropertyTransformerCache()).thenReturn(new NoOpCache<>());
    service = new DefaultFieldFilterService(new DefaultFieldParser(), schemaService, aclService, currentUserService, attributeService, cacheProvider, userGroupService, userService, nodeTransformers);
    service.init();
}
Also used : NodeTransformer(org.hisp.dhis.node.NodeTransformer) PluckNodeTransformer(org.hisp.dhis.node.transformers.PluckNodeTransformer) DefaultSchemaService(org.hisp.dhis.schema.DefaultSchemaService) SchemaService(org.hisp.dhis.schema.SchemaService) PluckNodeTransformer(org.hisp.dhis.node.transformers.PluckNodeTransformer) DefaultSchemaService(org.hisp.dhis.schema.DefaultSchemaService) CacheProvider(org.hisp.dhis.cache.CacheProvider) JacksonPropertyIntrospector(org.hisp.dhis.schema.introspection.JacksonPropertyIntrospector) HashSet(java.util.HashSet) DefaultPropertyIntrospectorService(org.hisp.dhis.schema.DefaultPropertyIntrospectorService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SchemaService (org.hisp.dhis.schema.SchemaService)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 HashSet (java.util.HashSet)1 Attribute (org.hisp.dhis.attribute.Attribute)1 CacheProvider (org.hisp.dhis.cache.CacheProvider)1 ObjectBundle (org.hisp.dhis.dxf2.metadata.objectbundle.ObjectBundle)1 ValidationContext (org.hisp.dhis.dxf2.metadata.objectbundle.validation.ValidationContext)1 NodeTransformer (org.hisp.dhis.node.NodeTransformer)1 PluckNodeTransformer (org.hisp.dhis.node.transformers.PluckNodeTransformer)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Preheat (org.hisp.dhis.preheat.Preheat)1 DefaultPropertyIntrospectorService (org.hisp.dhis.schema.DefaultPropertyIntrospectorService)1 DefaultSchemaService (org.hisp.dhis.schema.DefaultSchemaService)1 Property (org.hisp.dhis.schema.Property)1 Schema (org.hisp.dhis.schema.Schema)1 JacksonPropertyIntrospector (org.hisp.dhis.schema.introspection.JacksonPropertyIntrospector)1