use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.
the class MetaDefaultLimitIntTest method limitShouldNotAffectRelationshipsWithMetaElement.
@Test
public void limitShouldNotAffectRelationshipsWithMetaElement() {
ResourceRepositoryV2<MetaElement, Serializable> elementRepository = client.getRepositoryForType(MetaElement.class);
QuerySpec querySpec = new QuerySpec(MetaElement.class);
querySpec.includeRelation(Arrays.asList("attributes"));
querySpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.EQ, "resources.tasks"));
ResourceList<MetaElement> list = elementRepository.findAll(querySpec);
Assert.assertEquals(1, list.size());
MetaResource taskMeta = (MetaResource) list.get(0);
List<? extends MetaAttribute> attributes = taskMeta.getAttributes();
Assert.assertTrue(attributes.size() > 5);
}
use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImplTest method findManyTargetReturnsResult.
@Test
public void findManyTargetReturnsResult() {
MetaResource resource = resourceProvider.getMeta(Task.class);
ResourceList<MetaElement> children = repo.findManyTargets(resource.getId(), "children", new QuerySpec(MetaElement.class));
Assert.assertNotEquals(0, children.size());
}
use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImpl method getSource.
private MetaElement getSource(String sourceId) {
MetaLookup lookup = lookupSupplier.get();
MetaElement source = lookup.getMetaById().get(sourceId);
if (source == null) {
throw new ResourceNotFoundException(sourceId);
}
return source;
}
use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.
the class MetaDataObjectProvider method onInitialized.
@Override
public void onInitialized(MetaElement element) {
if (element instanceof MetaAttribute && element.getParent().getClass() == getMetaClass()) {
MetaAttribute attr = (MetaAttribute) element;
MetaDataObject parent = attr.getParent();
Type implementationType = PropertyUtils.getPropertyType(parent.getImplementationClass(), attr.getName());
MetaElement metaType = context.allocate(implementationType);
attr.setType(metaType.asType());
}
}
use of io.crnk.meta.model.MetaElement 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));
}
Aggregations