Search in sources :

Example 6 with ResourceMetaProvider

use of io.crnk.meta.provider.resource.ResourceMetaProvider 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 7 with ResourceMetaProvider

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

the class MetaModuleTest method setup.

@Before
public void setup() {
    metaModuleConfig = new MetaModuleConfig();
    metaModuleConfig.addMetaProvider(new ResourceMetaProvider());
    metaModule = MetaModule.createServerModule(metaModuleConfig);
    setupBoot();
}
Also used : ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) Before(org.junit.Before)

Example 8 with ResourceMetaProvider

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

the class AbstractJpaJerseyTest method setup.

@Before
public void setup() {
    client = new CrnkClient(getBaseUri().toString());
    client.setPushAlways(false);
    JpaModule module = JpaModule.newClientModule();
    setupModule(module, false);
    client.addModule(module);
    MetaModule clientMetaModule = MetaModule.create();
    clientMetaModule.addMetaProvider(new ResourceMetaProvider());
    client.addModule(clientMetaModule);
    metaModule.getLookup().initialize();
    setNetworkTimeout(client, 10000, TimeUnit.SECONDS);
}
Also used : CrnkClient(io.crnk.client.CrnkClient) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) MetaModule(io.crnk.meta.MetaModule) Before(org.junit.Before)

Example 9 with ResourceMetaProvider

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

the class ValidationMetaProviderTest method setup.

private void setup(boolean addValidationProvider) {
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(new JaxrsModule(null));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock", new SampleJsonServiceLocator()));
    boot.boot();
    resourceMetaProvider = new ResourceMetaProvider();
    lookup = new MetaLookup();
    lookup.setModuleContext(boot.getModuleRegistry().getContext());
    lookup.addProvider(resourceMetaProvider);
    if (addValidationProvider) {
        lookup.addProvider(new ValidationMetaProvider());
    }
    lookup.initialize();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) MetaLookup(io.crnk.meta.MetaLookup) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) JaxrsModule(io.crnk.rs.internal.JaxrsModule) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery)

Example 10 with ResourceMetaProvider

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

the class GeneratorExecutor method run.

public void run(File outputDir) {
    TSGeneratorConfig config = new TSGeneratorConfig();
    config.setGenerateExpressions(true);
    config.getNpm().setPackagingEnabled(false);
    config.getNpm().setPackageName("@crnk/angular-ngrx");
    config.getNpm().getPackageMapping().put(MetaElement.class.getPackage().getName(), "@crnk/angular-ngrx/meta");
    MetaModule metaModule = MetaModule.create();
    metaModule.addMetaProvider(new ResourceMetaProvider());
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new EmptyServiceDiscovery());
    boot.addModule(metaModule);
    boot.boot();
    TSGenerator generator = new TSGenerator(outputDir, metaModule.getLookup(), config);
    try {
        generator.run();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) TSGenerator(io.crnk.gen.typescript.internal.TSGenerator) TSGeneratorConfig(io.crnk.gen.typescript.TSGeneratorConfig) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) IOException(java.io.IOException) MetaModule(io.crnk.meta.MetaModule) EmptyServiceDiscovery(io.crnk.core.module.discovery.EmptyServiceDiscovery)

Aggregations

ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)16 Before (org.junit.Before)11 MetaModule (io.crnk.meta.MetaModule)8 CrnkBoot (io.crnk.core.boot.CrnkBoot)7 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)5 MetaModuleConfig (io.crnk.meta.MetaModuleConfig)4 TestModule (io.crnk.test.mock.TestModule)4 MetaElement (io.crnk.meta.model.MetaElement)3 CrnkClient (io.crnk.client.CrnkClient)2 EmptyServiceDiscovery (io.crnk.core.module.discovery.EmptyServiceDiscovery)2 Supplier (io.crnk.core.utils.Supplier)2 JaxrsModule (io.crnk.rs.internal.JaxrsModule)2 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)1 TSGeneratorConfig (io.crnk.gen.typescript.TSGeneratorConfig)1 TSGeneratorExtension (io.crnk.gen.typescript.TSGeneratorExtension)1 TSGenerator (io.crnk.gen.typescript.internal.TSGenerator)1 JpaModule (io.crnk.jpa.JpaModule)1 SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)1 MetaLookup (io.crnk.meta.MetaLookup)1 MetaRelationshipRepositoryImpl (io.crnk.meta.internal.MetaRelationshipRepositoryImpl)1