### Question:
UmaTokenStore { public RequestingPartyToken readRPT(String id) throws NotFoundException { return (RequestingPartyToken) readToken(id, rptAdapter); } @Inject  UmaTokenStore(@Assisted String realm, JavaBeanAdapter<RequestingPartyToken> rptAdapter,
            JavaBeanAdapter<PermissionTicket> permissionTicketAdapter, CTSPersistentStore cts,
            UmaProviderSettingsFactory settingsFactory); RequestingPartyToken readRPT(String id); PermissionTicket readPermissionTicket(String id); UmaToken readToken(String ticketId, JavaBeanAdapter<? extends UmaToken> adapter); void deleteRPT(String id); void deletePermissionTicket(String id); void updatePermissionTicket(PermissionTicket permissionTicket);  }### Answer:
@Test public void testReadRPT() throws Exception { final RequestingPartyToken rpt = new RequestingPartyToken(); rpt.setRealm("REALM"); when(rptAdapter.fromToken(RPT_TOKEN)).thenAnswer(new Answer<RequestingPartyToken>() { @Override public RequestingPartyToken answer(InvocationOnMock invocation) throws Throwable { return rpt; } }); when(cts.read("123")).thenReturn(RPT_TOKEN); RequestingPartyToken answer = store.readRPT("123"); assertThat(answer).isSameAs(rpt); }
@Test(expectedExceptions = NotFoundException.class) public void testReadRPTFailure() throws Exception { when(cts.read("123")).thenThrow(CoreTokenException.class); store.readRPT("123"); }
@Test(expectedExceptions = NotFoundException.class) public void shouldNotReadRPTInDifferentRealm() throws Exception { final RequestingPartyToken rpt = new RequestingPartyToken(); rpt.setRealm("OTHER_REALM"); when(rptAdapter.fromToken(RPT_TOKEN)).thenAnswer(new Answer<RequestingPartyToken>() { @Override public RequestingPartyToken answer(InvocationOnMock invocation) throws Throwable { return rpt; } }); when(cts.read("123")).thenReturn(RPT_TOKEN); store.readRPT("123"); }