mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
Give name to initialization
This commit is contained in:
@@ -4,17 +4,17 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
public class ScmPathInfoStore {
|
||||
|
||||
private UriInfo uriInfo;
|
||||
private ScmPathInfo pathInfo;
|
||||
|
||||
public ScmPathInfo get() {
|
||||
return () -> uriInfo.getBaseUri();
|
||||
return pathInfo;
|
||||
}
|
||||
|
||||
public void set(UriInfo uriInfo) {
|
||||
if (this.uriInfo != null) {
|
||||
public void setFromRestRequest(UriInfo uriInfo) {
|
||||
if (this.pathInfo != null) {
|
||||
throw new IllegalStateException("UriInfo already set");
|
||||
}
|
||||
this.uriInfo = uriInfo;
|
||||
this.pathInfo = uriInfo::getBaseUri;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ public class UriInfoFilter implements ContainerRequestFilter {
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext) {
|
||||
storeProvider.get().set(requestContext.getUriInfo());
|
||||
storeProvider.get().setFromRestRequest(requestContext.getUriInfo());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GroupCollectionToDtoMapperTest {
|
||||
|
||||
@Before
|
||||
public void init() throws URISyntaxException {
|
||||
scmPathInfoStore.set(uriInfo);
|
||||
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||
URI baseUri = new URI("http://example.com/base/");
|
||||
expectedBaseUri = baseUri.resolve(GroupRootResource.GROUPS_PATH_V2 + "/");
|
||||
when(uriInfo.getBaseUri()).thenReturn(baseUri);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ScmPathInfoStoreTest {
|
||||
|
||||
when(uriInfo.getBaseUri()).thenReturn(someUri);
|
||||
|
||||
scmPathInfoStore.set(uriInfo);
|
||||
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||
|
||||
assertSame(someUri, scmPathInfoStore.get().getApiRestUri());
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class ScmPathInfoStoreTest {
|
||||
UriInfo uriInfo = mock(UriInfo.class);
|
||||
ScmPathInfoStore scmPathInfoStore = new ScmPathInfoStore();
|
||||
|
||||
scmPathInfoStore.set(uriInfo);
|
||||
scmPathInfoStore.set(uriInfo);
|
||||
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user