@Test public void shouldNotAbandonChangesIfEntityNotExists() throws Exception { doThrow(new EntityNotFoundException(10000L)).when(entityService).abandonChanges(10000L); controller.perform(post("/entities/10000/abandon") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isConflict()) .andExpect(content().string(ENTITY_NOT_FOUND)); verify(entityService).abandonChanges(10000L); }
@RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) public void abandonChanges(@PathVariable Long entityId) { entityService.abandonChanges(entityId); }
EntityController extends MdsController { @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) public void abandonChanges(@PathVariable Long entityId) { entityService.abandonChanges(entityId); } }
EntityController extends MdsController { @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) public void abandonChanges(@PathVariable Long entityId) { entityService.abandonChanges(entityId); }  }
EntityController extends MdsController { @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) public void abandonChanges(@PathVariable Long entityId) { entityService.abandonChanges(entityId); }  @RequestMapping(value = "/entities/byModule", method = RequestMethod.GET) @ResponseBody Map<String, List<EntityDto>> getEntitiesByModule(); @RequestMapping(value = "/entities/getEntitiesByBundle", method = RequestMethod.GET) @ResponseBody List<EntityDto> getEntityByBundle(@RequestParam(value = "symbolicName", required = true) String bundleSymbolicName); @RequestMapping(value = "/entities/wip", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_ANY_MDS_ROLE) @ResponseBody List<EntityDto> getWorkInProgressEntities(); @RequestMapping(value = "/selectEntities", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody SelectResult<EntityDto> getEntities(SelectData data); @RequestMapping(value = "/entities/getEntity/{module}/{entityName}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityByModuleAndEntityName(@PathVariable String module, @PathVariable String entityName); @RequestMapping(value = "/entities/getEntityByClassName", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityByClassNameName(@RequestParam(value = "entityClassName", required = true) String entityClassName); @RequestMapping(value = "/entities", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_ANY_MDS_ROLE) @ResponseBody List<EntityDto> getAllEntities(); @RequestMapping(value = "/entities/getEntityById", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityById(@RequestParam(value = "entityId", required = true) Long entityId); @RequestMapping(value = "/entities/{entityId}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntity(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}", method = RequestMethod.DELETE) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody void deleteEntity(@PathVariable final Long entityId); @RequestMapping(value = "/entities", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody EntityDto saveEntity(@RequestBody EntityDto entity); @RequestMapping(value = "/entities/{entityId}/draft", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody DraftResult draft(@PathVariable Long entityId, @RequestBody DraftData data); @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) void abandonChanges(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/commit", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) void commitChanges(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/update", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody EntityDto updateDraft(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/fields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getFields(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/entityFields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getEntityFields(@PathVariable Long entityId); @RequestMapping(value = "/entities/entityFieldsByClassName", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getEntityFieldsByClassName(@RequestParam(value = "entityClassName", required = true) String entityClassName); @RequestMapping(value = "/entities/{entityId}/displayFields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getDisplayFields(@PathVariable Long entityId); @RequestMapping(value = "entities/{entityId}/fields/{name}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody FieldDto getFieldByName(@PathVariable Long entityId, @PathVariable String name); @RequestMapping(value = "/entities/{entityId}/advanced", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody AdvancedSettingsDto getAdvanced(@PathVariable final Long entityId); @RequestMapping(value = "/entities/{entityId}/advancedCommited", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody AdvancedSettingsDto getCommitedAdvanced(@PathVariable final Long entityId); @RequestMapping(value = "/entities/{entityId}/preferences/fields", method = RequestMethod.POST) @PreAuthorize(Roles.DATA_ACCESS) @ResponseStatus(HttpStatus.OK) void updateEntityDispleyableFieldsForUser(@RequestBody GridFieldSelectionUpdate fieldPreferences, @PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/preferences/gridSize", method = RequestMethod.POST) @PreAuthorize(Roles.DATA_ACCESS) @ResponseStatus(HttpStatus.OK) void updateEntityGridRowsNumberForUser(@RequestBody Integer pageSize, @PathVariable Long entityId); @Autowired void setEntityService(EntityService entityService); @Autowired void setMdsBundleRegenerationService(MdsBundleRegenerationService mdsBundleRegenerationService); @Autowired void setUserPreferencesService(UserPreferencesService userPreferencesService); }
EntityController extends MdsController { @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) public void abandonChanges(@PathVariable Long entityId) { entityService.abandonChanges(entityId); }  @RequestMapping(value = "/entities/byModule", method = RequestMethod.GET) @ResponseBody Map<String, List<EntityDto>> getEntitiesByModule(); @RequestMapping(value = "/entities/getEntitiesByBundle", method = RequestMethod.GET) @ResponseBody List<EntityDto> getEntityByBundle(@RequestParam(value = "symbolicName", required = true) String bundleSymbolicName); @RequestMapping(value = "/entities/wip", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_ANY_MDS_ROLE) @ResponseBody List<EntityDto> getWorkInProgressEntities(); @RequestMapping(value = "/selectEntities", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody SelectResult<EntityDto> getEntities(SelectData data); @RequestMapping(value = "/entities/getEntity/{module}/{entityName}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityByModuleAndEntityName(@PathVariable String module, @PathVariable String entityName); @RequestMapping(value = "/entities/getEntityByClassName", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityByClassNameName(@RequestParam(value = "entityClassName", required = true) String entityClassName); @RequestMapping(value = "/entities", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_ANY_MDS_ROLE) @ResponseBody List<EntityDto> getAllEntities(); @RequestMapping(value = "/entities/getEntityById", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntityById(@RequestParam(value = "entityId", required = true) Long entityId); @RequestMapping(value = "/entities/{entityId}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody EntityDto getEntity(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}", method = RequestMethod.DELETE) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody void deleteEntity(@PathVariable final Long entityId); @RequestMapping(value = "/entities", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody EntityDto saveEntity(@RequestBody EntityDto entity); @RequestMapping(value = "/entities/{entityId}/draft", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody DraftResult draft(@PathVariable Long entityId, @RequestBody DraftData data); @RequestMapping(value = "/entities/{entityId}/abandon", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) void abandonChanges(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/commit", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseStatus(HttpStatus.OK) void commitChanges(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/update", method = RequestMethod.POST) @PreAuthorize(Roles.HAS_SCHEMA_ACCESS) @ResponseBody EntityDto updateDraft(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/fields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getFields(@PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/entityFields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getEntityFields(@PathVariable Long entityId); @RequestMapping(value = "/entities/entityFieldsByClassName", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getEntityFieldsByClassName(@RequestParam(value = "entityClassName", required = true) String entityClassName); @RequestMapping(value = "/entities/{entityId}/displayFields", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody List<FieldDto> getDisplayFields(@PathVariable Long entityId); @RequestMapping(value = "entities/{entityId}/fields/{name}", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody FieldDto getFieldByName(@PathVariable Long entityId, @PathVariable String name); @RequestMapping(value = "/entities/{entityId}/advanced", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody AdvancedSettingsDto getAdvanced(@PathVariable final Long entityId); @RequestMapping(value = "/entities/{entityId}/advancedCommited", method = RequestMethod.GET) @PreAuthorize(Roles.HAS_DATA_OR_SCHEMA_ACCESS) @ResponseBody AdvancedSettingsDto getCommitedAdvanced(@PathVariable final Long entityId); @RequestMapping(value = "/entities/{entityId}/preferences/fields", method = RequestMethod.POST) @PreAuthorize(Roles.DATA_ACCESS) @ResponseStatus(HttpStatus.OK) void updateEntityDispleyableFieldsForUser(@RequestBody GridFieldSelectionUpdate fieldPreferences, @PathVariable Long entityId); @RequestMapping(value = "/entities/{entityId}/preferences/gridSize", method = RequestMethod.POST) @PreAuthorize(Roles.DATA_ACCESS) @ResponseStatus(HttpStatus.OK) void updateEntityGridRowsNumberForUser(@RequestBody Integer pageSize, @PathVariable Long entityId); @Autowired void setEntityService(EntityService entityService); @Autowired void setMdsBundleRegenerationService(MdsBundleRegenerationService mdsBundleRegenerationService); @Autowired void setUserPreferencesService(UserPreferencesService userPreferencesService);  }