@Test void testCreateEntityType() throws URISyntaxException { CreateEntityTypeRequest createEntityTypeRequest = mock(CreateEntityTypeRequest.class); String entityTypeId = "MyEntityTypeId"; EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock(); when(entityTypeRequestMapper.toEntityType(createEntityTypeRequest)).thenReturn(entityType); ResponseEntity<?> responseEntity = ResponseEntity.created(new URI("http: assertEquals(responseEntity, metadataApiController.createEntityType(createEntityTypeRequest)); verify(metadataApiService).createEntityType(entityType); }
@Transactional @PostMapping public ResponseEntity<Void> createEntityType( @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest) { EntityType entityType = entityTypeRequestMapper.toEntityType(createEntityTypeRequest); metadataApiService.createEntityType(entityType); URI location = ServletUriComponentsBuilder.fromCurrentRequestUri() .replacePath(API_META_PATH) .pathSegment(entityType.getId()) .build() .toUri(); return ResponseEntity.created(location).build(); }
MetadataApiController extends ApiController { @Transactional @PostMapping public ResponseEntity<Void> createEntityType( @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest) { EntityType entityType = entityTypeRequestMapper.toEntityType(createEntityTypeRequest); metadataApiService.createEntityType(entityType); URI location = ServletUriComponentsBuilder.fromCurrentRequestUri() .replacePath(API_META_PATH) .pathSegment(entityType.getId()) .build() .toUri(); return ResponseEntity.created(location).build(); } }
MetadataApiController extends ApiController { @Transactional @PostMapping public ResponseEntity<Void> createEntityType( @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest) { EntityType entityType = entityTypeRequestMapper.toEntityType(createEntityTypeRequest); metadataApiService.createEntityType(entityType); URI location = ServletUriComponentsBuilder.fromCurrentRequestUri() .replacePath(API_META_PATH) .pathSegment(entityType.getId()) .build() .toUri(); return ResponseEntity.created(location).build(); } MetadataApiController(
      MetadataApiService metadataApiService,
      EntityTypeResponseMapper entityTypeResponseMapper,
      EntityTypeRequestMapper entityTypeRequestMapper,
      AttributeResponseMapper attributeResponseMapper,
      AttributeRequestMapper attributeRequestMapper); }
MetadataApiController extends ApiController { @Transactional @PostMapping public ResponseEntity<Void> createEntityType( @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest) { EntityType entityType = entityTypeRequestMapper.toEntityType(createEntityTypeRequest); metadataApiService.createEntityType(entityType); URI location = ServletUriComponentsBuilder.fromCurrentRequestUri() .replacePath(API_META_PATH) .pathSegment(entityType.getId()) .build() .toUri(); return ResponseEntity.created(location).build(); } MetadataApiController(
      MetadataApiService metadataApiService,
      EntityTypeResponseMapper entityTypeResponseMapper,
      EntityTypeRequestMapper entityTypeRequestMapper,
      AttributeResponseMapper attributeResponseMapper,
      AttributeRequestMapper attributeRequestMapper); @Transactional(readOnly = true) @GetMapping EntityTypesResponse getEntityTypes(@Valid ReadEntityTypesRequest entitiesRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}") EntityTypeResponse getEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid ReadEntityTypeRequest readEntityTypeRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes/{attributeId}") AttributeResponse getAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId); @Transactional @PostMapping ResponseEntity<Void> createEntityType(
      @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") AttributesResponse getAttributes(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid ReadAttributesRequest readAttributesRequest); @Transactional @PostMapping("/{entityTypeId}/attributes") ResponseEntity<Void> createAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody CreateAttributeRequest createAttributeRequest); @Transactional @DeleteMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> deleteAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId); @Transactional @DeleteMapping("/{entityTypeId}/attributes") ResponseEntity<Void> deleteAttributes(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid DeleteAttributesRequest deleteAttributesRequest); @Transactional @PutMapping("/{entityTypeId}") ResponseEntity<Void> updateEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest); @Transactional @PutMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> updateAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId,
      @Valid @RequestBody CreateAttributeRequest createAttributeRequest); @Transactional @PatchMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> updatePartialAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId,
      @RequestBody Map<String, Object> attributeValues); @Transactional @PatchMapping("/{entityTypeId}") ResponseEntity<Void> updatePartialEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityTypeValues); @Transactional @DeleteMapping("/{entityTypeId}") ResponseEntity<Void> deleteEntityType(@PathVariable("entityTypeId") String entityTypeId); @Transactional @DeleteMapping ResponseEntity<Void> deleteEntityTypes(
      @Valid DeleteEntityTypesRequest deleteEntityTypesRequest); }
MetadataApiController extends ApiController { @Transactional @PostMapping public ResponseEntity<Void> createEntityType( @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest) { EntityType entityType = entityTypeRequestMapper.toEntityType(createEntityTypeRequest); metadataApiService.createEntityType(entityType); URI location = ServletUriComponentsBuilder.fromCurrentRequestUri() .replacePath(API_META_PATH) .pathSegment(entityType.getId()) .build() .toUri(); return ResponseEntity.created(location).build(); } MetadataApiController(
      MetadataApiService metadataApiService,
      EntityTypeResponseMapper entityTypeResponseMapper,
      EntityTypeRequestMapper entityTypeRequestMapper,
      AttributeResponseMapper attributeResponseMapper,
      AttributeRequestMapper attributeRequestMapper); @Transactional(readOnly = true) @GetMapping EntityTypesResponse getEntityTypes(@Valid ReadEntityTypesRequest entitiesRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}") EntityTypeResponse getEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid ReadEntityTypeRequest readEntityTypeRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes/{attributeId}") AttributeResponse getAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId); @Transactional @PostMapping ResponseEntity<Void> createEntityType(
      @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest); @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") AttributesResponse getAttributes(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid ReadAttributesRequest readAttributesRequest); @Transactional @PostMapping("/{entityTypeId}/attributes") ResponseEntity<Void> createAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody CreateAttributeRequest createAttributeRequest); @Transactional @DeleteMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> deleteAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId); @Transactional @DeleteMapping("/{entityTypeId}/attributes") ResponseEntity<Void> deleteAttributes(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid DeleteAttributesRequest deleteAttributesRequest); @Transactional @PutMapping("/{entityTypeId}") ResponseEntity<Void> updateEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody CreateEntityTypeRequest createEntityTypeRequest); @Transactional @PutMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> updateAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId,
      @Valid @RequestBody CreateAttributeRequest createAttributeRequest); @Transactional @PatchMapping("/{entityTypeId}/attributes/{attributeId}") ResponseEntity<Void> updatePartialAttribute(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("attributeId") String attributeId,
      @RequestBody Map<String, Object> attributeValues); @Transactional @PatchMapping("/{entityTypeId}") ResponseEntity<Void> updatePartialEntityType(
      @PathVariable("entityTypeId") String entityTypeId,
      @RequestBody Map<String, Object> entityTypeValues); @Transactional @DeleteMapping("/{entityTypeId}") ResponseEntity<Void> deleteEntityType(@PathVariable("entityTypeId") String entityTypeId); @Transactional @DeleteMapping ResponseEntity<Void> deleteEntityTypes(
      @Valid DeleteEntityTypesRequest deleteEntityTypesRequest);  }