@Test public void create() throws Exception { final boolean multiEntity = configService.isMultiEntity(); if (!multiEntity) { configService.setIsMultiEntity(true); } EOwnedEntity e = EntityUtil.getSampleEntity(random.nextString()); ConstrainedFields fields = new ConstrainedFields(EOwnedEntity.class); mvc.perform(post(apiPrefix + "/" + REQ_STRING) .contentType(MediaType.APPLICATION_JSON) .header(authHeader, tokenType + " " + accessToken) .content(objectMapper.writeValueAsString(e))) .andExpect(status().isCreated()) .andDo(restDocResHandler.document( requestFields( fields.withPath("name") .description("Natural name which is used commonly for referring to the entity"), fields.withPath("username") .description("A unique string representation of the {@LINK #name}. Useful " + "when there are other entities with the same {@LINK #name}"), fields.withPath("description") .description("A brief description of the entity") ) )); if (!multiEntity) { configService.setIsMultiEntity(false); } }
@PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity) throws GmsGeneralException { EOwnedEntity e = entityService.create(entity.getContent()); if (e != null) { return new ResponseEntity<>(HttpStatus.CREATED); } else { throw GmsGeneralException.builder().messageI18N("entity.add.error").finishedOK(false).build(); } }
RestOwnedEntityController { @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity) throws GmsGeneralException { EOwnedEntity e = entityService.create(entity.getContent()); if (e != null) { return new ResponseEntity<>(HttpStatus.CREATED); } else { throw GmsGeneralException.builder().messageI18N("entity.add.error").finishedOK(false).build(); } } }
RestOwnedEntityController { @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity) throws GmsGeneralException { EOwnedEntity e = entityService.create(entity.getContent()); if (e != null) { return new ResponseEntity<>(HttpStatus.CREATED); } else { throw GmsGeneralException.builder().messageI18N("entity.add.error").finishedOK(false).build(); } }  }
RestOwnedEntityController { @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity) throws GmsGeneralException { EOwnedEntity e = entityService.create(entity.getContent()); if (e != null) { return new ResponseEntity<>(HttpStatus.CREATED); } else { throw GmsGeneralException.builder().messageI18N("entity.add.error").finishedOK(false).build(); } }  @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity); }
RestOwnedEntityController { @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) public ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity) throws GmsGeneralException { EOwnedEntity e = entityService.create(entity.getContent()); if (e != null) { return new ResponseEntity<>(HttpStatus.CREATED); } else { throw GmsGeneralException.builder().messageI18N("entity.add.error").finishedOK(false).build(); } }  @PostMapping(path = ResourcePath.OWNED_ENTITY, produces = "application/hal+json") @ResponseStatus(HttpStatus.CREATED) ResponseEntity<EOwnedEntity> create(@Valid @RequestBody final Resource<EOwnedEntity> entity);  }