@Override public ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId, @RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies) { LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); final List<Target> assignedTarget = this.targetManagement .assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId); return ResponseEntity.ok(MgmtTargetMapper.toResponse(assignedTarget)); }
@Test @Description("Handles the GET request of retrieving all assigned targets by the given") public void getAssignedTargets() throws Exception { final TargetTag tag = createTargetTagEntitiy(); final Target target = createTargetByGivenNameWithAttributes("Target1", distributionSet); targetManagement.assignTag(Arrays.asList(target.getControllerId()), tag.getId()); arrayPrefix = "content[]."; this.mockMvc .perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, tag.getId()) .contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), getResponseFieldTarget(true, fieldWithPath("size").type(JsonFieldType.NUMBER) .description(ApiModelPropertiesGeneric.SIZE), fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("content").description(MgmtApiModelProperties.TARGET_LIST)))); }