Search in sources :

Example 1 with IndexJobExecution

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);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) QueryImpl(org.molgenis.data.support.QueryImpl) Attribute(org.molgenis.data.meta.model.Attribute) IndexJobExecution(org.molgenis.data.index.job.IndexJobExecution) IndexAction(org.molgenis.data.index.meta.IndexAction) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 2 with IndexJobExecution

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);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) QueryImpl(org.molgenis.data.support.QueryImpl) Attribute(org.molgenis.data.meta.model.Attribute) IndexJobExecution(org.molgenis.data.index.job.IndexJobExecution) IndexAction(org.molgenis.data.index.meta.IndexAction) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)2 IndexJobExecution (org.molgenis.data.index.job.IndexJobExecution)2 IndexAction (org.molgenis.data.index.meta.IndexAction)2 Attribute (org.molgenis.data.meta.model.Attribute)2 EntityType (org.molgenis.data.meta.model.EntityType)2 QueryImpl (org.molgenis.data.support.QueryImpl)2 Test (org.testng.annotations.Test)2