use of org.molgenis.data.index.job.IndexJobExecution in project molgenis by molgenis.
the class IndexBootstrapperTest method testStartupFailedIndexJobsUnknownEntityType.
@Test
public void testStartupFailedIndexJobsUnknownEntityType() {
when(indexService.hasIndex(attributeMetadata)).thenReturn(true);
IndexJobExecution indexJobExecution = mock(IndexJobExecution.class);
when(indexJobExecution.getIndexActionJobID()).thenReturn("id");
IndexAction action = mock(IndexAction.class);
when(action.getEntityTypeId()).thenReturn("myEntityTypeName");
when(action.getEntityId()).thenReturn("1");
EntityType entityType = mock(EntityType.class);
when(dataService.findOneById(EntityTypeMetadata.ENTITY_TYPE_META_DATA, "myEntityTypeName", EntityType.class)).thenReturn(null);
Attribute idAttribute = mock(Attribute.class);
when(idAttribute.getDataType()).thenReturn(AttributeType.INT);
when(entityType.getIdAttribute()).thenReturn(idAttribute);
when(dataService.findAll(IndexJobExecutionMeta.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class)).thenReturn(Stream.of(indexJobExecution));
when(dataService.findAll(IndexActionMetaData.INDEX_ACTION, new QueryImpl<IndexAction>().eq(IndexActionMetaData.INDEX_ACTION_GROUP_ATTR, "id"), IndexAction.class)).thenReturn(Stream.of(action));
indexBootstrapper.bootstrap();
// verify that we are not passing through the "missing index" code
verify(metaDataService, never()).getRepositories();
// verify that a new job is registered for the failed one
verify(indexActionRegisterService, times(0)).register(entityType, 1);
}
use of org.molgenis.data.index.job.IndexJobExecution in project molgenis by molgenis.
the class IndexBootstrapperTest method testStartupFailedIndexJobs.
@Test
public void testStartupFailedIndexJobs() {
when(indexService.hasIndex(attributeMetadata)).thenReturn(true);
IndexJobExecution indexJobExecution = mock(IndexJobExecution.class);
when(indexJobExecution.getIndexActionJobID()).thenReturn("id");
IndexAction action = mock(IndexAction.class);
when(action.getEntityTypeId()).thenReturn("myEntityTypeName");
when(action.getEntityId()).thenReturn("1");
EntityType entityType = mock(EntityType.class);
when(dataService.findOneById(EntityTypeMetadata.ENTITY_TYPE_META_DATA, "myEntityTypeName", EntityType.class)).thenReturn(entityType);
Attribute idAttribute = mock(Attribute.class);
when(idAttribute.getDataType()).thenReturn(AttributeType.INT);
when(entityType.getIdAttribute()).thenReturn(idAttribute);
when(dataService.findAll(IndexJobExecutionMeta.INDEX_JOB_EXECUTION, new QueryImpl<IndexJobExecution>().eq(JobExecutionMetaData.STATUS, FAILED), IndexJobExecution.class)).thenReturn(Stream.of(indexJobExecution));
when(dataService.findAll(IndexActionMetaData.INDEX_ACTION, new QueryImpl<IndexAction>().eq(IndexActionMetaData.INDEX_ACTION_GROUP_ATTR, "id"), IndexAction.class)).thenReturn(Stream.of(action));
indexBootstrapper.bootstrap();
// verify that we are not passing through the "missing index" code
verify(metaDataService, never()).getRepositories();
// verify that a new job is registered for the failed one
verify(indexActionRegisterService).register(entityType, 1);
}
Aggregations