### Question:
JwtTokenAnnotationHandler { protected boolean handleProtectedWithClaims(String issuer, String[] requiredClaims, boolean combineWithOr) { if (Objects.nonNull(issuer) && issuer.length() > 0) { JwtToken jwtToken = getJwtToken(issuer, tokenValidationContextHolder) .orElseThrow(() -> new JwtTokenMissingException("no valid token found in validation context")); if (!containsRequiredClaims(jwtToken, combineWithOr, requiredClaims)) { throw new JwtTokenInvalidClaimException("required claims not present in token." + Arrays.asList(requiredClaims)); } } return true; } JwtTokenAnnotationHandler(TokenValidationContextHolder tokenValidationContextHolder); boolean assertValidAnnotation(Method method);  }### Answer:
@Test public void checkThatAlternativeClaimsWithSameKeyWorks() { final String[] protectedWithAnyClaim = new String[] {"acr=Level3", "acr=Level4"}; assertTrue(annotationHandler.handleProtectedWithClaims("issuer1", protectedWithAnyClaim, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer2", protectedWithAnyClaim, true)); assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer3", protectedWithAnyClaim, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer4", protectedWithAnyClaim, true)); }
@Test public void checkThatMultipleRequiredClaimsWorks() { final String[] protectedWithAllClaims = new String[] {"acr=Level3", "foo=bar"}; assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer1", protectedWithAllClaims, false)); assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer2", protectedWithAllClaims, false)); assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer3", protectedWithAllClaims, false)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer4", protectedWithAllClaims, false)); }
@Test public void checkThatClaimWithUnknownValueIsRejected() { final String[] protectedWithClaims = new String[] {"acr=Level3", "acr=Level4"}; assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer3", protectedWithClaims, true)); assertThrows(JwtTokenInvalidClaimException.class, () -> annotationHandler.handleProtectedWithClaims("issuer3", protectedWithClaims, false)); }
@Test public void chechThatNoReqiredClaimsWorks() { final String[] protectedWithClaims = new String[0]; assertTrue(annotationHandler.handleProtectedWithClaims("issuer1", protectedWithClaims, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer2", protectedWithClaims, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer3", protectedWithClaims, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer4", protectedWithClaims, true)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer1", protectedWithClaims, false)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer2", protectedWithClaims, false)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer3", protectedWithClaims, false)); assertTrue(annotationHandler.handleProtectedWithClaims("issuer4", protectedWithClaims, false)); }