@Test public void testGetIdentifier_newEqual() { String pairwise1 = service.getIdentifier(userInfoRegular, pairwiseClient1); Mockito.verify(pairwiseIdentifierRepository, Mockito.atLeast(1)) .save(Matchers.any(PairwiseIdentifier.class)); PairwiseIdentifier pairwiseId = new PairwiseIdentifier(); pairwiseId.setUserSub(regularSub); pairwiseId.setIdentifier(pairwise1); pairwiseId.setSectorIdentifier(sectorHost12); Mockito.when(pairwiseIdentifierRepository.getBySectorIdentifier(regularSub, sectorHost12)) .thenReturn(pairwiseId); String pairwise2 = service.getIdentifier(userInfoRegular, pairwiseClient2); assertNotSame(pairwiseSub, pairwise1); assertNotSame(pairwiseSub, pairwise2); assertEquals(pairwise1, pairwise2); // see if the pairwise id's are actual UUIDs UUID uudi1 = UUID.fromString(pairwise1); UUID uuid2 = UUID.fromString(pairwise2); }
/** * Test method for {@link * org.mitre.openid.connect.service.impl.UUIDPairwiseIdentiferService#getIdentifier(org.mitre.openid.connect.model.UserInfo, * org.mitre.oauth2.model.ClientDetailsEntity)}. */ @Test public void testGetIdentifier_existingEqual() { Mockito.when(pairwiseIdentifierRepository.getBySectorIdentifier(regularSub, sectorHost12)) .thenReturn(savedPairwiseIdentifier); String pairwise1 = service.getIdentifier(userInfoRegular, pairwiseClient1); String pairwise2 = service.getIdentifier(userInfoRegular, pairwiseClient2); assertEquals(pairwiseSub, pairwise1); assertEquals(pairwiseSub, pairwise2); }