use of org.molgenis.data.Entity in project molgenis by molgenis.
the class EntityUtilsTest method getIsNullValueMockEntity.
private Entity getIsNullValueMockEntity() {
Entity entity = mock(Entity.class);
when(entity.toString()).thenReturn("entity");
return entity;
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class AnnotationJobFactory method createJob.
@RunAsSystem
public AnnotationJob createJob(AnnotationJobExecution metaData) {
dataService.add(ANNOTATION_JOB_EXECUTION, metaData);
String annotatorNames = metaData.getAnnotators();
String targetName = metaData.getTargetName();
String username = metaData.getUser();
// create an authentication to run as the user that is listed as the owner of the job
RunAsUserToken runAsAuthentication = new RunAsUserToken("Job Execution", username, null, userDetailsService.loadUserByUsername(username).getAuthorities(), null);
Repository<Entity> repository = dataService.getRepository(targetName);
List<RepositoryAnnotator> availableAnnotators = annotationService.getAllAnnotators().stream().filter(RepositoryAnnotator::annotationDataExists).collect(toList());
List<RepositoryAnnotator> requestedAnnotators = Arrays.stream(annotatorNames.split(",")).map(annotationService::getAnnotatorByName).collect(toList());
AnnotatorDependencyOrderResolver resolver = new AnnotatorDependencyOrderResolver();
List<RepositoryAnnotator> annotators = Lists.newArrayList(resolver.getAnnotatorSelectionDependencyList(availableAnnotators, requestedAnnotators, repository, entityTypeFactory));
return new AnnotationJob(crudRepositoryAnnotator, username, annotators, repository, new ProgressImpl(metaData, jobExecutionUpdater, mailSender), runAsAuthentication, new TransactionTemplate(transactionManager));
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class NegotiatorControllerTest method testValidateNegotiatorExport.
@Test
public void testValidateNegotiatorExport() {
NegotiatorRequest request = NegotiatorRequest.create("http://molgenis.org", "molgenis_id_1", "*=q=MOLGENIS", "a nice molgenis query", "Sjfg03Msmdp92Md82103FNskas9H735F");
Entity entity = mock(Entity.class);
String entityOneLabel = "Entity One";
when(entity.getLabelValue()).thenReturn(entityOneLabel);
when(entity.get("enabled")).thenReturn(true);
when(dataService.findAll("molgenis_id_1", molgenisQuery)).thenReturn(Stream.of(entity));
when(jsMagmaScriptEvaluator.eval("$(enabled).value()", entity)).thenReturn(TRUE);
ExportValidationResponse actual = negotiatorController.validateNegotiatorExport(request);
List<String> enabledCollections = Collections.singletonList(entityOneLabel);
ExportValidationResponse expected = ExportValidationResponse.create(true, "", enabledCollections, emptyList());
assertEquals(actual, expected);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class NegotiatorControllerTest method testValidateNegotiatorExportEmptyCollections.
@Test
public void testValidateNegotiatorExportEmptyCollections() {
NegotiatorRequest request = NegotiatorRequest.create("http://molgenis.org", "molgenis_id_1", "*=q=MOLGENIS", "a nice molgenis query", "Sjfg03Msmdp92Md82103FNskas9H735F");
Entity entity = mock(Entity.class);
when(entity.getLabelValue()).thenReturn("Entity One");
when(entity.get("enabled")).thenReturn(true);
when(dataService.findAll("molgenis_id_1", molgenisQuery)).thenReturn(Stream.empty());
ExportValidationResponse actual = negotiatorController.validateNegotiatorExport(request);
ExportValidationResponse expected = ExportValidationResponse.create(false, "Please make sure your selection contains at least 1 row that supports the negotiator.");
assertEquals(actual, expected);
}
use of org.molgenis.data.Entity in project molgenis by molgenis.
the class NegotiatorControllerTest method testValidateNegotiatorExportAllCollectionsAreDisabled.
@Test
public void testValidateNegotiatorExportAllCollectionsAreDisabled() {
NegotiatorRequest request = NegotiatorRequest.create("http://molgenis.org", "molgenis_id_1", "*=q=MOLGENIS", "a nice molgenis query", "Sjfg03Msmdp92Md82103FNskas9H735F");
Entity entityDisabled = mock(Entity.class);
String entityDisabledLabel = "Entity Disabled";
when(entityDisabled.getLabelValue()).thenReturn(entityDisabledLabel);
when(entityDisabled.get("enabled")).thenReturn(false);
when(dataService.findAll("molgenis_id_1", molgenisQuery)).thenReturn(Stream.of(entityDisabled));
when(jsMagmaScriptEvaluator.eval("$(enabled).value()", entityDisabled)).thenReturn(FALSE);
ExportValidationResponse actual = negotiatorController.validateNegotiatorExport(request);
List<String> disabledCollections = Collections.singletonList(entityDisabledLabel);
ExportValidationResponse expected = ExportValidationResponse.create(false, "Please make sure your selection contains at least 1 row that supports the negotiator.", emptyList(), disabledCollections);
assertEquals(actual, expected);
}
Aggregations