@Test void testGetAttributes() { String entityTypeId = "MyEntityTypeId"; Query query = mock(Query.class); Sort sort = mock(Sort.class); int size = 1; int page = 2; ReadAttributesRequest readAttributesRequest = new ReadAttributesRequest(); readAttributesRequest.setQ(query); readAttributesRequest.setSort(sort); readAttributesRequest.setSize(size); readAttributesRequest.setPage(page); Attributes attributes = mock(Attributes.class); when(metadataApiService.findAttributes(entityTypeId, query, sort, size, page)) .thenReturn(attributes); AttributesResponse attributesResponse = mock(AttributesResponse.class); when(attributeResponseMapper.toAttributesResponse(attributes, size, page)) .thenReturn(attributesResponse); assertEquals( attributesResponse, metadataApiController.getAttributes(entityTypeId, readAttributesRequest)); }
@Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") public AttributesResponse getAttributes( @PathVariable("entityTypeId") String entityTypeId, @Valid ReadAttributesRequest readAttributesRequest) { int size = readAttributesRequest.getSize(); int page = readAttributesRequest.getPage(); Sort sort = readAttributesRequest.getSort(); Attributes attributes = metadataApiService.findAttributes( entityTypeId, readAttributesRequest.getQ().orElse(null), sort, size, page); return attributeResponseMapper.toAttributesResponse(attributes, size, page); }
MetadataApiController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") public AttributesResponse getAttributes( @PathVariable("entityTypeId") String entityTypeId, @Valid ReadAttributesRequest readAttributesRequest) { int size = readAttributesRequest.getSize(); int page = readAttributesRequest.getPage(); Sort sort = readAttributesRequest.getSort(); Attributes attributes = metadataApiService.findAttributes( entityTypeId, readAttributesRequest.getQ().orElse(null), sort, size, page); return attributeResponseMapper.toAttributesResponse(attributes, size, page); } }
MetadataApiController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") public AttributesResponse getAttributes( @PathVariable("entityTypeId") String entityTypeId, @Valid ReadAttributesRequest readAttributesRequest) { int size = readAttributesRequest.getSize(); int page = readAttributesRequest.getPage(); Sort sort = readAttributesRequest.getSort(); Attributes attributes = metadataApiService.findAttributes( entityTypeId, readAttributesRequest.getQ().orElse(null), sort, size, page); return attributeResponseMapper.toAttributesResponse(attributes, size, page); } MetadataApiController(
      MetadataApiService metadataApiService,
      EntityTypeResponseMapper entityTypeResponseMapper,
      EntityTypeRequestMapper entityTypeRequestMapper,
      AttributeResponseMapper attributeResponseMapper,
      AttributeRequestMapper attributeRequestMapper); }
MetadataApiController extends ApiController { @Transactional(readOnly = true) @GetMapping("/{entityTypeId}/attributes") public AttributesResponse getAttributes( @PathVariable("entityTypeId") String entityTypeId, @Valid ReadAttributesRequest readAttributesRequest) { int size = readAttributesRequest.getSize(); int page = readAttributesRequest.getPage(); Sort sort = readAttributesRequest.getSort(); Attributes attributes = metadataApiService.findAttributes( entityTypeId, readAttributesRequest.getQ().orElse(null), sort, size, page); return attributeResponseMapper.toAttributesResponse(attributes, size, page); } 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(readOnly = true) @GetMapping("/{entityTypeId}/attributes") public AttributesResponse getAttributes( @PathVariable("entityTypeId") String entityTypeId, @Valid ReadAttributesRequest readAttributesRequest) { int size = readAttributesRequest.getSize(); int page = readAttributesRequest.getPage(); Sort sort = readAttributesRequest.getSort(); Attributes attributes = metadataApiService.findAttributes( entityTypeId, readAttributesRequest.getQ().orElse(null), sort, size, page); return attributeResponseMapper.toAttributesResponse(attributes, size, page); } 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);  }