@Test public void withSelfIdResolverTest() throws UnableToResolveIdException, ScimException { String internalId = "test-user-resolved"; Principal principal = mock(Principal.class); SessionContext sessionContext = mock(SessionContext.class); @SuppressWarnings("unchecked") Instance<SelfIdResolver> selfIdResolverInstance = mock(Instance.class); SelfIdResolver selfIdResolver = mock(SelfIdResolver.class); UserResource userResource = mock(UserResource.class); Response mockResponse = mock(Response.class); when(sessionContext.getCallerPrincipal()).thenReturn(principal); when(principal.getName()).thenReturn("test-user"); when(selfIdResolverInstance.isUnsatisfied()).thenReturn(false); when(selfIdResolverInstance.get()).thenReturn(selfIdResolver); when(selfIdResolver.resolveToInternalId(principal)).thenReturn(internalId); when(userResource.getById(internalId, null, null)).thenReturn(mockResponse); SelfResourceImpl selfResource = new SelfResourceImpl(); selfResource.selfIdResolver = selfIdResolverInstance; selfResource.sessionContext = sessionContext; selfResource.userResource = userResource; assertThat(selfResource.getSelf(null, null), sameInstance(mockResponse)); }
@Override public Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) { try { String internalId = getInternalId(); return userResource.getById(internalId, attributes, excludedAttributes); } catch (UnableToResolveIdException e) { return createErrorResponse(e); } catch (ScimException e) { return createErrorResponse(e); } }
SelfResourceImpl implements SelfResource { @Override public Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) { try { String internalId = getInternalId(); return userResource.getById(internalId, attributes, excludedAttributes); } catch (UnableToResolveIdException e) { return createErrorResponse(e); } catch (ScimException e) { return createErrorResponse(e); } } }
SelfResourceImpl implements SelfResource { @Override public Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) { try { String internalId = getInternalId(); return userResource.getById(internalId, attributes, excludedAttributes); } catch (UnableToResolveIdException e) { return createErrorResponse(e); } catch (ScimException e) { return createErrorResponse(e); } }  }
SelfResourceImpl implements SelfResource { @Override public Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) { try { String internalId = getInternalId(); return userResource.getById(internalId, attributes, excludedAttributes); } catch (UnableToResolveIdException e) { return createErrorResponse(e); } catch (ScimException e) { return createErrorResponse(e); } }  @Override Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response update(ScimUser resource, AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response patch(PatchRequest patchRequest, AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response delete(); }
SelfResourceImpl implements SelfResource { @Override public Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes) { try { String internalId = getInternalId(); return userResource.getById(internalId, attributes, excludedAttributes); } catch (UnableToResolveIdException e) { return createErrorResponse(e); } catch (ScimException e) { return createErrorResponse(e); } }  @Override Response getSelf(AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response update(ScimUser resource, AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response patch(PatchRequest patchRequest, AttributeReferenceListWrapper attributes, AttributeReferenceListWrapper excludedAttributes); @Override Response delete();  }