List of usage examples for org.springframework.data.rest.core.mapping ResourceMetadata getPath
Path getPath();
From source file:org.moserp.common.structure.factories.AssociationPropertyFactoryTest.java
@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); }
From source file:org.moserp.common.structure.factories.AssociationPropertyFactory.java
private String calculateUri(PropertyFactoryContext context) { ResourceMetadata mapping = mappings.getMetadataFor(context.getPersistentProperty().getType()); final BaseUri baseUri = new BaseUri("http://" + moduleRegistry.getModuleForResource(mapping.getRel())); UriComponentsBuilder builder = baseUri.getUriComponentsBuilder(); return builder.path(mapping.getPath().toString()).build().toUriString(); }