use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityIfInSystemSubPackage.
@Test
public void isSystemEntityIfInSystemSubPackage() {
EntityType entity = mock(EntityType.class);
Package entityPackage = mock(Package.class);
when(entity.getPackage()).thenReturn(entityPackage);
when(entityPackage.getId()).thenReturn("not-system");
when(entity.getId()).thenReturn("sys_foo_bar_Entity");
assertTrue(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityIfInSystemPackage.
@Test
public void isSystemEntityIfInSystemPackage() {
EntityType entity = mock(EntityType.class);
Package entityPackage = mock(Package.class);
when(entity.getPackage()).thenReturn(entityPackage);
when(entityPackage.getId()).thenReturn("sys");
assertTrue(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageMapperTest method testToPackageReference.
@Test
public void testToPackageReference() {
String id = "id0";
EditorPackageIdentifier packageIdentifier = EditorPackageIdentifier.create(id, "label");
Package package_ = packageMapper.toPackageReference(packageIdentifier);
assertEquals(package_.getIdValue(), id);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class OptionsWizardPage method validateInput.
private String validateInput(File file, ImportWizard wizard, BindingResult result) {
// decide what importer to use...
RepositoryCollection source = fileRepositoryCollectionFactory.createFileRepositoryCollection(file);
ImportService importService = importServiceFactory.getImportService(file, source);
EntitiesValidationReport validationReport = importService.validateImport(file, source);
wizard.setEntitiesImportable(validationReport.getSheetsImportable());
wizard.setFieldsDetected(validationReport.getFieldsImportable());
wizard.setFieldsRequired(validationReport.getFieldsRequired());
wizard.setFieldsAvailable(validationReport.getFieldsAvailable());
wizard.setFieldsUnknown(validationReport.getFieldsUnknown());
Set<String> allPackages = new HashSet<>(validationReport.getPackages());
for (Package p : dataService.getMeta().getPackages()) {
allPackages.add(p.getId());
}
List<String> entitiesInDefaultPackage = new ArrayList<>();
for (String entityTypeId : validationReport.getSheetsImportable().keySet()) {
if (validationReport.getSheetsImportable().get(entityTypeId)) {
if (isInDefaultPackage(entityTypeId, allPackages))
entitiesInDefaultPackage.add(entityTypeId);
}
}
wizard.setEntitiesInDefaultPackage(entitiesInDefaultPackage);
List<String> packages = new ArrayList<>(validationReport.getPackages());
packages.add(0, PACKAGE_DEFAULT);
wizard.setPackages(packages);
String msg = null;
if (validationReport.valid()) {
wizard.setFile(file);
msg = "File is validated and can be imported.";
} else {
wizard.setValidationMessage("File did not pass validation see results below. Please resolve the errors and try again.");
}
return msg;
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testAdd1.
@Test
public void testAdd1() {
Package package1 = mock(Package.class);
Package package2 = mock(Package.class);
when(package1.getId()).thenReturn("1");
when(package2.getId()).thenReturn("2");
Stream<Package> packages = Stream.of(package1, package2);
repo.add(packages);
ArgumentCaptor<Stream<Package>> captor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).add(captor.capture());
assertEquals(captor.getValue().collect(toList()), asList(package1, package2));
}
Aggregations