### Question:
UmaTokenStore { PermissionTicket createPermissionTicket(String resourceSetId, Set<String> scopes, String clientId) throws ServerException, NotFoundException { UmaProviderSettings settings = settingsFactory.get(realm); PermissionTicket permissionTicket = new PermissionTicket(null, resourceSetId, scopes, clientId); permissionTicket.setRealm(realm); permissionTicket.setExpiryTime(currentTimeMillis() + (settings.getPermissionTicketLifetime() * 1000)); try { cts.create(permissionTicketAdapter.toToken(permissionTicket)); } catch (CoreTokenException e) { throw new ServerException(e); } return permissionTicket; } @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 testCreatePermissionTicket() throws Exception { ArgumentCaptor<PermissionTicket> ticketCapture = ArgumentCaptor.forClass(PermissionTicket.class); when(permissionTicketAdapter.toToken(ticketCapture.capture())).thenAnswer(new Answer<Token>() { @Override public Token answer(InvocationOnMock invocation) throws Throwable { return TICKET_TOKEN; } }); when(providerSettings.getPermissionTicketLifetime()).thenReturn(1000L); PermissionTicket ticket = store.createPermissionTicket("123", new HashSet<String>(asList("a", "b")), null); verify(cts).create(TICKET_TOKEN); assertThat(ticket).isSameAs(ticketCapture.getValue()); assertThat(ticket.getResourceSetId()).isEqualTo("123"); assertThat(ticket.getScopes()).contains("a", "b"); }
@Test(expectedExceptions = ServerException.class) public void testCreatePermissionTicketFailure() throws Exception { ArgumentCaptor<PermissionTicket> ticketCapture = ArgumentCaptor.forClass(PermissionTicket.class); when(permissionTicketAdapter.toToken(ticketCapture.capture())).thenAnswer(new Answer<Token>() { @Override public Token answer(InvocationOnMock invocation) throws Throwable { return TICKET_TOKEN; } }); when(providerSettings.getPermissionTicketLifetime()).thenReturn(1000L); doThrow(CoreTokenException.class).when(cts).create(TICKET_TOKEN); store.createPermissionTicket("123", new HashSet<String>(asList("a", "b")), null); }