@Test void testGetEntity() { String entityTypeId = "MyEntityTypeId"; String entityId = "MyId"; Selection filter = Selection.FULL_SELECTION; Selection expand = Selection.FULL_SELECTION; ReadEntityRequest entityRequest = new ReadEntityRequest(); entityRequest.setEntityTypeId(entityTypeId); entityRequest.setEntityId(entityId); entityRequest.setFilter(filter); entityRequest.setExpand(expand); Entity entity = mock(Entity.class); when(dataServiceV3.find(entityTypeId, entityId, filter, expand)).thenReturn(entity); EntityResponse entityResponse = mock(EntityResponse.class); when(entityMapper.map(entity, filter, expand)).thenReturn(entityResponse); assertEquals(entityResponse, entityController.getEntity(entityRequest)); }
@Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") public EntityResponse getEntity(@Valid ReadEntityRequest entityRequest) { Selection filter = entityRequest.getFilter(); Selection expand = entityRequest.getExpand(); Entity entity = dataServiceV3.find( entityRequest.getEntityTypeId(), entityRequest.getEntityId(), filter, expand); return entityMapper.map(entity, filter, expand); }
EntityController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") public EntityResponse getEntity(@Valid ReadEntityRequest entityRequest) { Selection filter = entityRequest.getFilter(); Selection expand = entityRequest.getExpand(); Entity entity = dataServiceV3.find( entityRequest.getEntityTypeId(), entityRequest.getEntityId(), filter, expand); return entityMapper.map(entity, filter, expand); } }
EntityController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") public EntityResponse getEntity(@Valid ReadEntityRequest entityRequest) { Selection filter = entityRequest.getFilter(); Selection expand = entityRequest.getExpand(); Entity entity = dataServiceV3.find( entityRequest.getEntityTypeId(), entityRequest.getEntityId(), filter, expand); return entityMapper.map(entity, filter, expand); } EntityController(DataServiceV3 dataServiceV3, EntityMapper entityMapper); }
EntityController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") public EntityResponse getEntity(@Valid ReadEntityRequest entityRequest) { Selection filter = entityRequest.getFilter(); Selection expand = entityRequest.getExpand(); Entity entity = dataServiceV3.find( entityRequest.getEntityTypeId(), entityRequest.getEntityId(), filter, expand); return entityMapper.map(entity, filter, expand); } EntityController(DataServiceV3 dataServiceV3, EntityMapper entityMapper); @Transactional @PostMapping("/{entityTypeId}") ResponseEntity createEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityMap); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") EntityResponse getEntity(@Valid ReadEntityRequest entityRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}/{fieldId}") EntitiesResponse getReferencedEntities(@Valid ReadSubresourceRequest entitiesRequest); @Transactional @PutMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void updateEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("entityId") String entityId,
      @RequestBody Map<String, Object> entityMap); @Transactional @PatchMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void updatePartialEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("entityId") String entityId,
      @RequestBody Map<String, Object> entityMap); @Transactional @DeleteMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteEntity(@Valid DeleteEntityRequest deleteRequest); @DeleteMapping("/{entityTypeId}") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteEntities(@Valid DeleteEntitiesRequest deleteRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}") EntitiesResponse getEntities(@Valid ReadEntitiesRequest entitiesRequest); }
EntityController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") public EntityResponse getEntity(@Valid ReadEntityRequest entityRequest) { Selection filter = entityRequest.getFilter(); Selection expand = entityRequest.getExpand(); Entity entity = dataServiceV3.find( entityRequest.getEntityTypeId(), entityRequest.getEntityId(), filter, expand); return entityMapper.map(entity, filter, expand); } EntityController(DataServiceV3 dataServiceV3, EntityMapper entityMapper); @Transactional @PostMapping("/{entityTypeId}") ResponseEntity createEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityMap); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}") EntityResponse getEntity(@Valid ReadEntityRequest entityRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/{entityId}/{fieldId}") EntitiesResponse getReferencedEntities(@Valid ReadSubresourceRequest entitiesRequest); @Transactional @PutMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void updateEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("entityId") String entityId,
      @RequestBody Map<String, Object> entityMap); @Transactional @PatchMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void updatePartialEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("entityId") String entityId,
      @RequestBody Map<String, Object> entityMap); @Transactional @DeleteMapping("/{entityTypeId}/{entityId}") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteEntity(@Valid DeleteEntityRequest deleteRequest); @DeleteMapping("/{entityTypeId}") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteEntities(@Valid DeleteEntitiesRequest deleteRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}") EntitiesResponse getEntities(@Valid ReadEntitiesRequest entitiesRequest); static final String API_ENTITY_PATH; }