### Question:
UmaTokenStore { RequestingPartyToken createRPT(PermissionTicket permissionTicket) throws ServerException, NotFoundException { UmaProviderSettings settings = settingsFactory.get(realm); Permission permission = new Permission(permissionTicket.getResourceSetId(), permissionTicket.getScopes()); RequestingPartyToken rpt = new RequestingPartyToken(null, permissionTicket.getResourceServerClientId(), asSet(permission), currentTimeMillis() + (settings.getRPTLifetime() * 1000), permissionTicket.getId(), permissionTicket.getClientClientId()); rpt.setRealm(realm); try { cts.create(rptAdapter.toToken(rpt)); } catch (CoreTokenException e) { throw new ServerException(e); } return rpt; } @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 testCreateRPT() throws Exception { ArgumentCaptor<RequestingPartyToken> rptCapture = ArgumentCaptor.forClass(RequestingPartyToken.class); when(rptAdapter.toToken(rptCapture.capture())).thenAnswer(new Answer<Token>() { @Override public Token answer(InvocationOnMock invocation) throws Throwable { return RPT_TOKEN; } }); when(providerSettings.getRPTLifetime()).thenReturn(1000L); RequestingPartyToken rpt = store.createRPT(new PermissionTicket("123", "abc", new HashSet<String>(asList("a")), null)); verify(cts).create(RPT_TOKEN); assertThat(rpt).isSameAs(rptCapture.getValue()); }
@Test(expectedExceptions = ServerException.class) public void testCreateRPTFailed() throws Exception { ArgumentCaptor<RequestingPartyToken> rptCapture = ArgumentCaptor.forClass(RequestingPartyToken.class); when(rptAdapter.toToken(rptCapture.capture())).thenAnswer(new Answer<Token>() { @Override public Token answer(InvocationOnMock invocation) throws Throwable { return RPT_TOKEN; } }); when(providerSettings.getRPTLifetime()).thenReturn(1000L); doThrow(CoreTokenException.class).when(cts).create(RPT_TOKEN); store.createRPT(new PermissionTicket("123", "abc", new HashSet<String>(asList("a")), null)); }