MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRestApi { @Override public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes( @RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) { final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement .create(MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes)); return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); } MgmtSoftwareModuleTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement,
            final EntityFactory entityFactory); @Override ResponseEntity<PagedList<MgmtSoftwareModuleType>> getTypes(
            @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<MgmtSoftwareModuleType> getSoftwareModuleType(
            @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); @Override ResponseEntity<Void> deleteSoftwareModuleType(
            @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId); @Override ResponseEntity<MgmtSoftwareModuleType> updateSoftwareModuleType(
            @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId,
            @RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); @Override ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
            @RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes);  }
@Test @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes POST requests.") public void createSoftwareModuleTypes() throws Exception { final List<SoftwareModuleType> types = Arrays.asList( entityFactory.softwareModuleType().create().key("test1").name("TestName1").description("Desc1") .colour("col1‚").maxAssignments(1).build(), entityFactory.softwareModuleType().create().key("test2").name("TestName2").description("Desc2") .colour("col2‚").maxAssignments(2).build(), entityFactory.softwareModuleType().create().key("test3").name("TestName3").description("Desc3") .colour("col3‚").maxAssignments(3).build()); final MvcResult mvcResult = mvc .perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("[0].name", equalTo("TestName1"))).andExpect(jsonPath("[0].key", equalTo("test1"))) .andExpect(jsonPath("[0].description", equalTo("Desc1"))) .andExpect(jsonPath("[0].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[0].maxAssignments", equalTo(1))) .andExpect(jsonPath("[1].name", equalTo("TestName2"))).andExpect(jsonPath("[1].key", equalTo("test2"))) .andExpect(jsonPath("[1].description", equalTo("Desc2"))) .andExpect(jsonPath("[1].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[1].maxAssignments", equalTo(2))) .andExpect(jsonPath("[2].name", equalTo("TestName3"))).andExpect(jsonPath("[2].key", equalTo("test3"))) .andExpect(jsonPath("[2].description", equalTo("Desc3"))) .andExpect(jsonPath("[2].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))) .andExpect(jsonPath("[2].maxAssignments", equalTo(3))).andReturn(); final SoftwareModuleType created1 = softwareModuleTypeManagement.getByKey("test1").get(); final SoftwareModuleType created2 = softwareModuleTypeManagement.getByKey("test2").get(); final SoftwareModuleType created3 = softwareModuleTypeManagement.getByKey("test3").get(); assertThat( JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) .isEqualTo("http: assertThat( JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) .isEqualTo("http: assertThat( JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) .isEqualTo("http: assertThat(softwareModuleTypeManagement.count()).isEqualTo(6); }