Search in sources :

Example 1 with MetaProvider

use of io.crnk.meta.provider.MetaProvider in project crnk-framework by crnk-project.

the class MetaModuleTest method testTransitiveRegistrationOfProviderDependencies.

@Test
public void testTransitiveRegistrationOfProviderDependencies() {
    MetaProvider testProvider = Mockito.mock(MetaProvider.class);
    Mockito.when(testProvider.getDependencies()).thenReturn((Collection) Arrays.asList(new ResourceMetaProvider()));
    metaModuleConfig = new MetaModuleConfig();
    metaModuleConfig.addMetaProvider(testProvider);
    metaModule = MetaModule.createServerModule(metaModuleConfig);
    setupBoot();
    Set<Class<? extends MetaElement>> metaClasses = metaModule.collectMetaClasses();
    // meta classes out of testProvider dependency (resource meta provider)
    Assert.assertTrue(metaClasses.contains(MetaResource.class));
    Assert.assertTrue(metaClasses.contains(MetaResourceRepository.class));
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) MetaResourceRepository(io.crnk.meta.model.resource.MetaResourceRepository) MetaResource(io.crnk.meta.model.resource.MetaResource) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) MetaProvider(io.crnk.meta.provider.MetaProvider) Test(org.junit.Test)

Example 2 with MetaProvider

use of io.crnk.meta.provider.MetaProvider in project crnk-framework by crnk-project.

the class MetaModule method collectMetaClasses.

private void collectMetaClasses(Set<Class<? extends MetaElement>> metaClasses, Collection<MetaProvider> providers) {
    for (MetaProvider provider : providers) {
        metaClasses.addAll(provider.getMetaTypes());
        collectMetaClasses(metaClasses, provider.getDependencies());
    }
}
Also used : MetaProvider(io.crnk.meta.provider.MetaProvider)

Aggregations

MetaProvider (io.crnk.meta.provider.MetaProvider)2 MetaElement (io.crnk.meta.model.MetaElement)1 MetaResource (io.crnk.meta.model.resource.MetaResource)1 MetaResourceRepository (io.crnk.meta.model.resource.MetaResourceRepository)1 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)1 Test (org.junit.Test)1