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 {
|
public class ScmPathInfoStore {
|
||||||
|
|
||||||
private UriInfo uriInfo;
|
private ScmPathInfo pathInfo;
|
||||||
|
|
||||||
public ScmPathInfo get() {
|
public ScmPathInfo get() {
|
||||||
return () -> uriInfo.getBaseUri();
|
return pathInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(UriInfo uriInfo) {
|
public void setFromRestRequest(UriInfo uriInfo) {
|
||||||
if (this.uriInfo != null) {
|
if (this.pathInfo != null) {
|
||||||
throw new IllegalStateException("UriInfo already set");
|
throw new IllegalStateException("UriInfo already set");
|
||||||
}
|
}
|
||||||
this.uriInfo = uriInfo;
|
this.pathInfo = uriInfo::getBaseUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ public class UriInfoFilter implements ContainerRequestFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(ContainerRequestContext requestContext) {
|
public void filter(ContainerRequestContext requestContext) {
|
||||||
storeProvider.get().set(requestContext.getUriInfo());
|
storeProvider.get().setFromRestRequest(requestContext.getUriInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class GroupCollectionToDtoMapperTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws URISyntaxException {
|
public void init() throws URISyntaxException {
|
||||||
scmPathInfoStore.set(uriInfo);
|
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||||
URI baseUri = new URI("http://example.com/base/");
|
URI baseUri = new URI("http://example.com/base/");
|
||||||
expectedBaseUri = baseUri.resolve(GroupRootResource.GROUPS_PATH_V2 + "/");
|
expectedBaseUri = baseUri.resolve(GroupRootResource.GROUPS_PATH_V2 + "/");
|
||||||
when(uriInfo.getBaseUri()).thenReturn(baseUri);
|
when(uriInfo.getBaseUri()).thenReturn(baseUri);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class ScmPathInfoStoreTest {
|
|||||||
|
|
||||||
when(uriInfo.getBaseUri()).thenReturn(someUri);
|
when(uriInfo.getBaseUri()).thenReturn(someUri);
|
||||||
|
|
||||||
scmPathInfoStore.set(uriInfo);
|
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||||
|
|
||||||
assertSame(someUri, scmPathInfoStore.get().getApiRestUri());
|
assertSame(someUri, scmPathInfoStore.get().getApiRestUri());
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public class ScmPathInfoStoreTest {
|
|||||||
UriInfo uriInfo = mock(UriInfo.class);
|
UriInfo uriInfo = mock(UriInfo.class);
|
||||||
ScmPathInfoStore scmPathInfoStore = new ScmPathInfoStore();
|
ScmPathInfoStore scmPathInfoStore = new ScmPathInfoStore();
|
||||||
|
|
||||||
scmPathInfoStore.set(uriInfo);
|
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||||
scmPathInfoStore.set(uriInfo);
|
scmPathInfoStore.setFromRestRequest(uriInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user