TrustedServiceUsageConsistency implements TrustedServiceCondition { @Override public boolean isConsistent(TrustedServiceWrapper trustedService) { List<String> capturedQualifiers = trustedService.getCapturedQualifiers(); boolean qcForEsig = ServiceQualification.isQcForEsig(capturedQualifiers); boolean qcForEseal = ServiceQualification.isQcForEseal(capturedQualifiers); boolean qcForWSA = ServiceQualification.isQcForWSA(capturedQualifiers); boolean noneOfThem = !(qcForEsig || qcForEseal || qcForWSA); boolean onlyOneOfThem = qcForEsig ^ qcForEseal ^ qcForWSA; return noneOfThem || onlyOneOfThem; }  @Override boolean isConsistent(TrustedServiceWrapper trustedService);  }
@Test public void testNoUsage() { TrustedServiceWrapper service = new TrustedServiceWrapper(); assertTrue(condition.isConsistent(service)); }
@Test public void testForEsigUsage() { TrustedServiceWrapper service = new TrustedServiceWrapper(); service.setCapturedQualifiers(Arrays.asList(ServiceQualification.QC_FOR_ESIG)); assertTrue(condition.isConsistent(service)); }
@Test public void testForEsigAndEsealsUsage() { TrustedServiceWrapper service = new TrustedServiceWrapper(); service.setCapturedQualifiers(Arrays.asList(ServiceQualification.QC_FOR_ESIG, ServiceQualification.QC_FOR_ESEAL)); assertFalse(condition.isConsistent(service)); }