ContainerTypeResolver { static String resolveContainerType(ValidationConclusion validationConclusion) { return isPades(validationConclusion.getSignatures()) ? PADES_CONTAINER_TYPE : resolveContainerTypeFromSignatureForm(validationConclusion.getSignatureForm()); }    }
@Test public void noSignatureFormAndNoSignaturesReturnsNa() { assertEquals(NA, resolveContainerType(new ValidationConclusion())); }
@Test public void noSignatureFormAndSignatureWithPadesPrefixReturnsPades() { assertEquals(PADES_CONTAINER_TYPE, resolveContainerType(reportWithSignatureFormat(PADES_SIGNATURE_FORMAT_PREFIX + "some suffix"))); }
@Test public void determiningPadesUsesFirstSignature() { ValidationConclusion report = new ValidationConclusionBuilder() .addSignatureWithFormat("RANDOM") .addSignatureWithFormat(PADES_SIGNATURE_FORMAT_PREFIX + "some suffix") .build(); assertEquals(NA, resolveContainerType(report)); }
@Test public void signatureFormatWithPadesPrefixNotInTheBeginningReturnsNa() { assertEquals(NA, resolveContainerType(reportWithSignatureFormat("b" + PADES_SIGNATURE_FORMAT_PREFIX))); assertEquals(NA, resolveContainerType(reportWithSignatureFormat("b" + PADES_SIGNATURE_FORMAT_PREFIX + "s"))); }
@Test public void nonSupportedSignatureFormReturnsNa() { assertEquals(NA, resolveContainerType(reportWithSignatureForm("SOMETHING"))); }
@Test public void emptySignatureFormReturnsNa() { assertEquals(NA, resolveContainerType(reportWithSignatureForm(""))); }
@Test public void asiceSignatureFormReturnsAsiceContainerType() { assertEquals(ASIC_E_CONTAINER_TYPE, resolveContainerType(reportWithSignatureForm(ASIC_E_SIGNATURE_FORM))); }
@Test public void xRoadSignatureFormReturnsAsiceContainerType() { assertEquals(ASIC_E_CONTAINER_TYPE, resolveContainerType(reportWithSignatureForm(XROAD_SIGNATURE_FORM))); }
@Test public void asicsSignatureFormReturnsAsicsContainerType(){ assertEquals(ASIC_S_CONTAINER_TYPE, resolveContainerType(reportWithSignatureForm(ASIC_S_SIGNATURE_FORM))); }
@Test public void signatureFormWithDDOCPrefixReturnsDDOCContainerType() { assertEquals(DDOC_CONTAINER_TYPE, resolveContainerType(reportWithSignatureForm(DDOC_SIGNATURE_FORM_PREFIX + "some suffix"))); }
@Test public void signatureFormWithDDOCPrefixNotInTheBeginningReturnsNa() { assertEquals(NA, resolveContainerType(reportWithSignatureForm("b" + DDOC_SIGNATURE_FORM_PREFIX))); assertEquals(NA, resolveContainerType(reportWithSignatureForm("b" + DDOC_SIGNATURE_FORM_PREFIX + "s"))); }
@Test public void signatureFormThatContainsButNotEqualsAValidSignatureFormReturnsNa() { assertEquals(NA, resolveContainerType(reportWithSignatureForm("b" + ASIC_E_SIGNATURE_FORM))); assertEquals(NA, resolveContainerType(reportWithSignatureForm("b" + XROAD_SIGNATURE_FORM))); assertEquals(NA, resolveContainerType(reportWithSignatureForm("b" + ASIC_S_SIGNATURE_FORM))); }