Search in sources :

Example 1 with MetadataDeleteJobExecution

use of org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution in project molgenis by molgenis.

the class MetadataApiControllerTest method testDeleteEntityTypes.

@Test
void testDeleteEntityTypes() {
    Query query = Query.create("id", IN, asList("MyEntityTypeId0", "MyEntityTypeId1"));
    DeleteEntityTypesRequest deleteEntityTypesRequest = new DeleteEntityTypesRequest();
    deleteEntityTypesRequest.setQ(query);
    MetadataDeleteJobExecution jobExecution = mockDeleteJobExecution();
    when(metadataApiService.deleteEntityTypesAsync(query)).thenReturn(jobExecution);
    metadataApiController.deleteEntityTypes(deleteEntityTypesRequest);
    verify(metadataApiService).deleteEntityTypesAsync(query);
}
Also used : Query(org.molgenis.api.model.Query) DeleteEntityTypesRequest(org.molgenis.api.metadata.v3.model.DeleteEntityTypesRequest) MetadataDeleteJobExecution(org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 2 with MetadataDeleteJobExecution

use of org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution in project molgenis by molgenis.

the class MetadataApiControllerTest method mockDeleteJobExecution.

private static MetadataDeleteJobExecution mockDeleteJobExecution() {
    EntityType entityType = mock(EntityType.class);
    MetadataDeleteJobExecution jobExecution = mock(MetadataDeleteJobExecution.class);
    when(jobExecution.getEntityType()).thenReturn(entityType);
    return jobExecution;
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) MetadataDeleteJobExecution(org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution)

Example 3 with MetadataDeleteJobExecution

use of org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution in project molgenis by molgenis.

the class MetadataApiJobServiceImplTest method testScheduleDelete.

@Test
void testScheduleDelete() {
    EntityType entityType = mock(EntityType.class);
    when(entityType.getId()).thenReturn("entity1");
    MetadataDeleteJobExecution jobExecution = mock(MetadataDeleteJobExecution.class);
    when(metadataDeleteJobExecutionFactory.create()).thenReturn(jobExecution);
    MetadataDeleteJobExecution actualJobExecution = metadataApiJobService.scheduleDelete(entityType);
    assertAll(() -> assertEquals(jobExecution, actualJobExecution), () -> verify(jobExecution).setIds(singletonList("entity1")), () -> verify(jobExecutor).submit(jobExecution));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) MetadataDeleteJobExecution(org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with MetadataDeleteJobExecution

use of org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution in project molgenis by molgenis.

the class MetadataApiControllerTest method testDeleteEntityType.

@Test
void testDeleteEntityType() {
    String entityTypeId = "MyEntityTypeId";
    MetadataDeleteJobExecution jobExecution = mockDeleteJobExecution();
    when(metadataApiService.deleteEntityTypeAsync(entityTypeId)).thenReturn(jobExecution);
    metadataApiController.deleteEntityType(entityTypeId);
    verify(metadataApiService).deleteEntityTypeAsync(entityTypeId);
}
Also used : MetadataDeleteJobExecution(org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 5 with MetadataDeleteJobExecution

use of org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution in project molgenis by molgenis.

the class MetadataApiJobServiceImplTest method testScheduleDeleteCollection.

@Test
void testScheduleDeleteCollection() {
    EntityType entityType1 = mock(EntityType.class);
    when(entityType1.getId()).thenReturn("entity1");
    EntityType entityType2 = mock(EntityType.class);
    when(entityType2.getId()).thenReturn("entity2");
    MetadataDeleteJobExecution jobExecution = mock(MetadataDeleteJobExecution.class);
    when(metadataDeleteJobExecutionFactory.create()).thenReturn(jobExecution);
    MetadataDeleteJobExecution actualJobExecution = metadataApiJobService.scheduleDelete(asList(entityType1, entityType2));
    assertAll(() -> assertEquals(jobExecution, actualJobExecution), () -> verify(jobExecution).setIds(asList("entity1", "entity2")), () -> verify(jobExecutor).submit(jobExecution));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) MetadataDeleteJobExecution(org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

MetadataDeleteJobExecution (org.molgenis.api.metadata.v3.job.MetadataDeleteJobExecution)6 Test (org.junit.jupiter.api.Test)4 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)4 EntityType (org.molgenis.data.meta.model.EntityType)3 DeleteEntityTypesRequest (org.molgenis.api.metadata.v3.model.DeleteEntityTypesRequest)1 Query (org.molgenis.api.model.Query)1