use of org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto in project entando-core by entando.
the class DataObjectModelControllerTest method should_load_the_list_of_dataModels_2.
@SuppressWarnings("unchecked")
@Test
public void should_load_the_list_of_dataModels_2() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(dataObjectModelService.getDataObjectModels(any(RestListRequest.class))).thenReturn(new PagedMetadata<DataModelDto>());
ResultActions result = mockMvc.perform(get("/dataModels").param("page", "1").param("pageSize", "4").param("filter[0].attribute", "code").param("filter[0].value", "1").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
restListReq.addFilter(new Filter("code", "1"));
Mockito.verify(dataObjectModelService, Mockito.times(1)).getDataObjectModels(restListReq);
}
use of org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto in project entando-core by entando.
the class DataObjectModelServiceTest method should_raise_exception_on_delete_referenced_dataModel.
@Test(expected = ValidationConflictException.class)
public void should_raise_exception_on_delete_referenced_dataModel() throws Throwable {
DataObjectModel mockDataModel = new DataObjectModel();
mockDataModel.setId(234l);
when(this.dataObjectModelManager.getDataObjectModel(any(Long.class))).thenReturn(mockDataModel);
DataModelDto dto = new DataModelDto(mockDataModel);
when(this.dtoBuilder.convert(mockDataModel)).thenReturn(dto);
Map<String, List<IPage>> utilizers = new HashMap<>();
List<IPage> pages = new ArrayList<>();
Page referencedPage = new Page();
referencedPage.setCode("referenced");
pages.add(referencedPage);
utilizers.put("ABC123", pages);
when(this.dataObjectModelManager.getReferencingPages(any(Long.class))).thenReturn(utilizers);
this.dataObjectModelService.removeDataObjectModel(34l);
}
use of org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto in project entando-core by entando.
the class DataObjectModelController method getDataObjectModel.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDataObjectModel(@PathVariable String dataModelId) {
logger.debug("Requested data object model -> {}", dataModelId);
MapBindingResult bindingResult = new MapBindingResult(new HashMap<>(), "dataModels");
int result = this.getDataObjectModelValidator().checkModelId(dataModelId, bindingResult);
if (bindingResult.hasErrors()) {
if (404 == result) {
throw new RestRourceNotFoundException(DataObjectModelValidator.ERRCODE_DATAOBJECTMODEL_DOES_NOT_EXIST, "dataObjectModel", dataModelId);
} else {
throw new ValidationGenericException(bindingResult);
}
}
DataModelDto dataModelDto = this.getDataObjectModelService().getDataObjectModel(Long.parseLong(dataModelId));
return new ResponseEntity<>(new RestResponse(dataModelDto), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto in project entando-core by entando.
the class DataObjectModelControllerTest method should_load_the_list_of_dataModels.
@SuppressWarnings("unchecked")
@Test
public void should_load_the_list_of_dataModels() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(dataObjectModelService.getDataObjectModels(any(RestListRequest.class))).thenReturn(new PagedMetadata<DataModelDto>());
ResultActions result = mockMvc.perform(get("/dataModels").param("page", "1").param("pageSize", "4").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
restListReq.setPage(1);
restListReq.setPageSize(4);
Mockito.verify(dataObjectModelService, Mockito.times(1)).getDataObjectModels(restListReq);
}
Aggregations