org.springframework.data.rest.core.mapping.ResourceMappings Java Examples

The following examples show how to use org.springframework.data.rest.core.mapping.ResourceMappings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AssociationPropertyFactoryTest.java    From moserp with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    when(persistentProperty.isAssociation()).thenReturn(true);
    when(persistentProperty.getActualType()).thenReturn((Class) OtherRepositoryClass.class);
    when(persistentProperty.getType()).thenReturn((Class) OtherRepositoryClass.class);

    ResourceMappings mappings = mock(ResourceMappings.class);
    ResourceMetadata metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("otherRepositoryClasses"));
    when(metaData.isExported()).thenReturn(true);
    when(mappings.getMetadataFor(eq(OtherRepositoryClass.class))).thenReturn(metaData);

    ModuleRegistry moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getModuleForResource(anyString())).thenReturn("environment-module");

    propertyFactory = new AssociationPropertyFactory(createConfiguration(), mappings, moduleRegistry);
}
 
Example #2
Source File: ApplicationStructureController.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Autowired
public ApplicationStructureController(ApplicationStructureBuilder applicationStructureBuilder, RepositoryRestConfiguration configuration, Repositories repositories, ResourceMappings mappings) {
    Assert.notNull(applicationStructureBuilder, "ApplicationStructureBuilder must not be null!");
    Assert.notNull(configuration, "RepositoryRestConfiguration must not be null!");
    Assert.notNull(repositories, "Repositories must not be null!");
    Assert.notNull(mappings, "ResourceMappings must not be null!");

    this.applicationStructureBuilder = applicationStructureBuilder;
    this.configuration = configuration;
    this.repositories = repositories;
    this.mappings = mappings;
}
 
Example #3
Source File: ApplicationStructureBuilderTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
public void setupMocks() throws URISyntaxException {
    configuration = mock(RepositoryRestConfiguration.class);
    when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    mappings = mock(ResourceMappings.class);
    metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("valueLists"));
    PersistentEntity persistentEntity = mock(PersistentEntity.class);
    when(persistentEntities.getPersistentEntity(any())).thenReturn(persistentEntity);
    PersistentProperty persistentProperty = mock(PersistentProperty.class);
    when(persistentEntity.getPersistentProperty(any(String.class))).thenReturn(persistentProperty);
    when(entityLinks.linkFor(any())).thenReturn(BaseUriLinkBuilder.create(new URI("http://localhost:8080/")));
    moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getBaseUriForResource(anyString())).thenReturn(new RestUri("http://localhost:8080/valueLists"));
}
 
Example #4
Source File: JsonSchemaBuilderTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
public void setupMocks() throws URISyntaxException {
    configuration = mock(RepositoryRestConfiguration.class);
    when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    mappings = mock(ResourceMappings.class);
    metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("valueLists"));
    PersistentEntity persistentEntity = mock(PersistentEntity.class);
    when(persistentEntities.getPersistentEntity(any())).thenReturn(persistentEntity);
    PersistentProperty persistentProperty = mock(PersistentProperty.class);
    when(persistentEntity.getPersistentProperty(any(String.class))).thenReturn(persistentProperty);
    when(entityLinks.linkFor(any())).thenReturn(BaseUriLinkBuilder.create(new URI("http://localhost:8080/")));
    moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getBaseUriForResource(anyString())).thenReturn(new RestUri("http://localhost:8080/valueLists"));
}
 
Example #5
Source File: AssociationPropertyFactory.java    From moserp with Apache License 2.0 4 votes vote down vote up
@Autowired
public AssociationPropertyFactory(RepositoryRestConfiguration configuration, ResourceMappings mappings, ModuleRegistry moduleRegistry) {
    this.configuration = configuration;
    this.mappings = mappings;
    this.moduleRegistry = moduleRegistry;
}
 
Example #6
Source File: DemoRepositoryEntityLinks.java    From spring-data-dynamodb-demo with Apache License 2.0 4 votes vote down vote up
public DemoRepositoryEntityLinks(Repositories repositories,
		ResourceMappings mappings, RepositoryRestConfiguration config, HateoasPageableHandlerMethodArgumentResolver resolver,org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> idConverters) {
	super(repositories, mappings, config, resolver,idConverters);
	this.resourceMappings = mappings;
	this.config = config;
}
 
Example #7
Source File: SpringRepositoryRestResourceProvider.java    From springdoc-openapi with Apache License 2.0 3 votes vote down vote up
/**
 * Instantiates a new Spring repository rest resource provider.
 *
 * @param mappings the mappings
 * @param repositories the repositories
 * @param associations the associations
 * @param delegatingHandlerMapping the delegating handler mapping
 * @param dataRestRouterOperationBuilder the data rest router operation builder
 */
public SpringRepositoryRestResourceProvider(ResourceMappings mappings, Repositories repositories, Associations associations,
		DelegatingHandlerMapping delegatingHandlerMapping, DataRestRouterOperationBuilder dataRestRouterOperationBuilder) {
	this.mappings = mappings;
	this.repositories = repositories;
	this.associations = associations;
	this.delegatingHandlerMapping = delegatingHandlerMapping;
	this.dataRestRouterOperationBuilder = dataRestRouterOperationBuilder;
}
 
Example #8
Source File: SpringDocDataRestConfiguration.java    From springdoc-openapi with Apache License 2.0 3 votes vote down vote up
/**
 * Spring repository rest resource provider spring repository rest resource provider.
 *
 * @param mappings the mappings 
 * @param repositories the repositories 
 * @param associations the associations 
 * @param delegatingHandlerMapping the delegating handler mapping 
 * @param dataRestRouterOperationBuilder the data rest router operation builder 
 * @return the spring repository rest resource provider
 */
@Bean
@ConditionalOnMissingBean
SpringRepositoryRestResourceProvider springRepositoryRestResourceProvider(ResourceMappings mappings,
		Repositories repositories, Associations associations, DelegatingHandlerMapping delegatingHandlerMapping,
		DataRestRouterOperationBuilder dataRestRouterOperationBuilder) {
	return new SpringRepositoryRestResourceProvider(mappings, repositories, associations,
			delegatingHandlerMapping, dataRestRouterOperationBuilder);
}