### Question:
UmaTokenStore { public PermissionTicket readPermissionTicket(String id) throws NotFoundException { return (PermissionTicket) readToken(id, permissionTicketAdapter); } @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 testReadPermissionTicket() throws Exception { final PermissionTicket ticket = new PermissionTicket("123", "abc", new HashSet<String>(asList("a")), null); ticket.setRealm("REALM"); when(permissionTicketAdapter.fromToken(TICKET_TOKEN)).thenAnswer(new Answer<PermissionTicket>() { @Override public PermissionTicket answer(InvocationOnMock invocation) throws Throwable { return ticket; } }); when(cts.read("123")).thenReturn(TICKET_TOKEN); PermissionTicket answer = store.readPermissionTicket("123"); assertThat(answer).isSameAs(ticket); }
@Test(expectedExceptions = NotFoundException.class) public void testReadPermissionTicketFailure() throws Exception { when(cts.read("123")).thenThrow(CoreTokenException.class); store.readPermissionTicket("123"); }
@Test(expectedExceptions = NotFoundException.class) public void shouldNotReadPermissionTicketInDifferentRealm() throws Exception { final PermissionTicket ticket = new PermissionTicket("123", "abc", new HashSet<String>(asList("a")), null); ticket.setRealm("OTHER_REALM"); when(permissionTicketAdapter.fromToken(TICKET_TOKEN)).thenAnswer(new Answer<PermissionTicket>() { @Override public PermissionTicket answer(InvocationOnMock invocation) throws Throwable { return ticket; } }); when(cts.read("123")).thenReturn(TICKET_TOKEN); store.readPermissionTicket("123"); }