MgmtTargetTagResource implements MgmtTargetTagRestApi { @Override public ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags) { LOG.debug("creating {} target tags", tags.size()); final List<TargetTag> createdTargetTags = this.tagManagement .create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED); } MgmtTargetTagResource(final TargetTagManagement tagManagement, final TargetManagement targetManagement,
            final EntityFactory entityFactory); @Override ResponseEntity<PagedList<MgmtTag>> getTargetTags(
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); @Override ResponseEntity<MgmtTag> getTargetTag(@PathVariable("targetTagId") final Long targetTagId); @Override ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags); @Override ResponseEntity<MgmtTag> updateTargetTag(@PathVariable("targetTagId") final Long targetTagId,
            @RequestBody final MgmtTagRequestBodyPut restTargetTagRest); @Override ResponseEntity<Void> deleteTargetTag(@PathVariable("targetTagId") final Long targetTagId); @Override ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId); @Override ResponseEntity<PagedList<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
            @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam); @Override ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignment(
            @PathVariable("targetTagId") final Long targetTagId,
            @RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); @Override ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
            @RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); @Override ResponseEntity<Void> unassignTarget(@PathVariable("targetTagId") final Long targetTagId,
            @PathVariable("controllerId") final String controllerId); @Override ResponseEntity<MgmtTargetTagAssigmentResult> toggleTagAssignmentUnpaged(
            @PathVariable("targetTagId") final Long targetTagId,
            @RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); @Override ResponseEntity<List<MgmtTarget>> assignTargetsUnpaged(@PathVariable("targetTagId") final Long targetTagId,
            @RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies); @Override ResponseEntity<Void> unassignTargetUnpaged(@PathVariable("targetTagId") final Long targetTagId,
            @PathVariable("controllerId") final String controllerId);  }
@Test @Description("Verifies that created target tags are stored in the repository as send to the API.") @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) public void createTargetTags() throws Exception { final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") .build(); final Tag tagTwo = entityFactory.tag().create().colour("testcol2").description("its a test2").name("thetest2") .build(); final ResultActions result = mvc .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) .content(JsonBuilder.tags(Arrays.asList(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); assertThat(createdOne.getName()).isEqualTo(tagOne.getName()); assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription()); assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour()); final Tag createdTwo = targetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0); assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName()); assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription()); assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour()); result.andExpect(applyTagMatcherOnArrayResult(createdOne)).andExpect(applyTagMatcherOnArrayResult(createdTwo)); }