ValidationRequestUtils { static boolean isXroadAsiceContainer(UploadedFile validationRequest) throws IOException { String document = validationRequest.getEncodedFile(); if (document == null) { return false; } try (InputStream stream = new ByteArrayInputStream(Base64.decodeBase64(document.getBytes()))) { byte[] fileContents = ZipUtil.unpackEntry(stream, UNIQUE_XROAD_ASICE_FILE); if (fileContents == null) { return false; } String messageFile = new String(fileContents); return messageFile.contains(XROAD_XSD); } } private  ValidationRequestUtils();   }
@Test public void givenXroadContainerValidationRequestWillReturnTrue() throws Exception { UploadedFile request = createXroadValidationRequest( loadBase64EncodedFile("/xroad-container.asice"), "xroad.asice" ); assertThat(ValidationRequestUtils.isXroadAsiceContainer(request)).isTrue(); }
@Test public void givenInvalidXroadContainerWillReturnFalse() throws Exception { UploadedFile request = createXroadValidationRequest(null, "xroad.asice"); assertThat(ValidationRequestUtils.isXroadAsiceContainer(request)).isFalse(); }