ImportValidationServiceImpl implements ImportValidationService { @Override public boolean validate(final String file) { boolean hasDatasetDir = false; boolean hasPage = false; boolean hasNavigation = false; try (final ZipInputStream zis = new ZipInputStream(new FileInputStream(file))) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { hasDatasetDir = hasDatasetDir || entryStartsWith(entry, DATASET_PREFIX); hasPage = hasPage || entryStartsWith(entry, PERSPECTIVE_PREFIX); hasNavigation = hasNavigation || entryStartsWith(entry, NAVIGATION_PREFIX); if (hasNavigation && hasDatasetDir && hasPage) { return true; } } } catch (Exception e) { throw new IllegalArgumentException("Error validating file: " + file, e); } return false; }  @Override boolean validate(final String file);  }
@Test public void validFileTest() { String file = this.getClass().getResource("/valid_import.zip").getFile(); assertTrue(importValidationService.validate(file)); }
@Test public void invalidFileTest() { String file = this.getClass().getResource("/not_valid.zip").getFile(); assertFalse(importValidationService.validate(file)); }