use of org.molgenis.api.metadata.v3.job.MetadataUpsertJobExecution in project molgenis by molgenis.
the class MetadataApiControllerTest method testDeleteAttributes.
@Test
void testDeleteAttributes() {
String entityTypeId = "MyEntityTypeId";
Query query = Query.create("name", IN, asList("name1", "name2"));
DeleteAttributesRequest deleteAttributesRequest = new DeleteAttributesRequest();
deleteAttributesRequest.setQ(query);
MetadataUpsertJobExecution jobExecution = mockUpsertJobExecution();
when(metadataApiService.deleteAttributesAsync(entityTypeId, query)).thenReturn(jobExecution);
metadataApiController.deleteAttributes(entityTypeId, deleteAttributesRequest);
verify(metadataApiService).deleteAttributesAsync(entityTypeId, query);
}
use of org.molgenis.api.metadata.v3.job.MetadataUpsertJobExecution in project molgenis by molgenis.
the class MetadataApiControllerTest method testUpdateEntityType.
@Test
void testUpdateEntityType() throws URISyntaxException {
String entityTypeId = "MyEntityTypeId";
CreateEntityTypeRequest createEntityTypeRequest = mock(CreateEntityTypeRequest.class);
EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock();
when(entityTypeRequestMapper.toEntityType(createEntityTypeRequest)).thenReturn(entityType);
MetadataUpsertJobExecution metadataUpsertJobExecution = mock(MetadataUpsertJobExecution.class);
when(metadataUpsertJobExecution.getEntityType()).thenReturn(entityType);
when(metadataApiService.updateEntityTypeAsync(entityType)).thenReturn(metadataUpsertJobExecution);
ResponseEntity<?> responseEntity = ResponseEntity.accepted().location(new URI("http://localhost/api/data/MyEntityTypeId")).build();
assertEquals(responseEntity, metadataApiController.updateEntityType(entityTypeId, createEntityTypeRequest));
}
use of org.molgenis.api.metadata.v3.job.MetadataUpsertJobExecution in project molgenis by molgenis.
the class MetadataApiControllerTest method testDeleteAttribute.
@Test
void testDeleteAttribute() {
String entityTypeId = "MyEntityTypeId";
String attributeId = "attrId";
MetadataUpsertJobExecution jobExecution = mockUpsertJobExecution();
when(metadataApiService.deleteAttributeAsync(entityTypeId, attributeId)).thenReturn(jobExecution);
metadataApiController.deleteAttribute(entityTypeId, attributeId);
verify(metadataApiService).deleteAttributeAsync(entityTypeId, attributeId);
}
use of org.molgenis.api.metadata.v3.job.MetadataUpsertJobExecution in project molgenis by molgenis.
the class MetadataApiControllerTest method mockUpsertJobExecution.
private static MetadataUpsertJobExecution mockUpsertJobExecution() {
EntityType entityType = mock(EntityType.class);
MetadataUpsertJobExecution jobExecution = mock(MetadataUpsertJobExecution.class);
when(jobExecution.getEntityType()).thenReturn(entityType);
return jobExecution;
}
use of org.molgenis.api.metadata.v3.job.MetadataUpsertJobExecution in project molgenis by molgenis.
the class MetadataApiControllerTest method testCreateAttribute.
@Test
void testCreateAttribute() throws URISyntaxException {
String entityTypeId = "MyEntityTypeId";
String attibuteId = "myAttributeId";
CreateAttributeRequest createAttributeRequest = CreateAttributeRequest.builder().setId(attibuteId).setName("updatedMyAttribute").build();
EntityType entityType = mock(EntityType.class);
when(metadataApiService.findEntityType(entityTypeId)).thenReturn(entityType);
Attribute newAttribute = mock(Attribute.class);
when(attributeRequestMapper.toAttribute(createAttributeRequest, entityType)).thenReturn(newAttribute);
EntityType jobEntityType = mock(EntityType.class);
when(jobEntityType.getId()).thenReturn("MyJobEntityTypeId");
MetadataUpsertJobExecution metadataUpsertJobExecution = mock(MetadataUpsertJobExecution.class);
when(metadataUpsertJobExecution.getEntityType()).thenReturn(jobEntityType);
when(metadataUpsertJobExecution.getIdentifier()).thenReturn("MyJobEntityId");
when(metadataApiService.updateEntityTypeAsync(entityType)).thenReturn(metadataUpsertJobExecution);
ResponseEntity<?> responseEntity = ResponseEntity.accepted().location(new URI("http://localhost/api/data/MyJobEntityTypeId/MyJobEntityId")).build();
assertEquals(responseEntity, metadataApiController.createAttribute(entityTypeId, createAttributeRequest));
verify(entityType).addAttribute(newAttribute);
}
Aggregations