Skip to content
Snippets Groups Projects
Commit 1645e716 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2566 OZG-2684 tiny cleanup on kommentar; adjust FIELD_PATH_PREFIX in...

OZG-2566 OZG-2684 tiny cleanup on kommentar; adjust FIELD_PATH_PREFIX in client for validation messages
parent 697719ec
Branches
Tags
No related merge requests found
...@@ -8,7 +8,8 @@ import { Observable } from "rxjs"; ...@@ -8,7 +8,8 @@ import { Observable } from "rxjs";
export class KommentarFormService extends AbstractFormService { export class KommentarFormService extends AbstractFormService {
static readonly TEXT = 'text'; static readonly TEXT = 'text';
static readonly FIELD_PATH_PREFIX = 'command.body';
static readonly FIELD_PATH_PREFIX = 'kommentar';
constructor(formBuilder: FormBuilder, private kommentarService: KommentarService) { constructor(formBuilder: FormBuilder, private kommentarService: KommentarService) {
super(formBuilder); super(formBuilder);
......
...@@ -12,7 +12,7 @@ export class WiedervorlageFormService extends AbstractFormService { ...@@ -12,7 +12,7 @@ export class WiedervorlageFormService extends AbstractFormService {
static readonly FIELD_FRIST = 'frist'; static readonly FIELD_FRIST = 'frist';
static readonly FIELD_ATTACHMENTS = 'attachments'; static readonly FIELD_ATTACHMENTS = 'attachments';
static readonly FIELD_PATH_PREFIX = 'command.body'; static readonly FIELD_PATH_PREFIX = 'wiedervorlage';
constructor( constructor(
formBuilder: FormBuilder, formBuilder: FormBuilder,
......
...@@ -25,7 +25,7 @@ public class KommentarCommandController { ...@@ -25,7 +25,7 @@ public class KommentarCommandController {
@PostMapping @PostMapping
public ResponseEntity<Void> editKommentar(@RequestBody KommentarCommand kommentarCommand, @PathVariable String kommentarId, public ResponseEntity<Void> editKommentar(@RequestBody KommentarCommand kommentarCommand, @PathVariable String kommentarId,
@PathVariable long kommentarVersion) { @PathVariable long kommentarVersion) {
var createdCommand = service.editKommentar(kommentarCommand, kommentarId, kommentarVersion); var createdCommand = service.editKommentar(kommentarCommand.getKommentar(), kommentarId, kommentarVersion);
return buildResponseLink(createdCommand); return buildResponseLink(createdCommand);
} }
...@@ -45,7 +45,7 @@ public class KommentarCommandController { ...@@ -45,7 +45,7 @@ public class KommentarCommandController {
@PostMapping @PostMapping
public ResponseEntity<Void> createKommentar(@RequestBody KommentarCommand command, @PathVariable String vorgangId) { public ResponseEntity<Void> createKommentar(@RequestBody KommentarCommand command, @PathVariable String vorgangId) {
var createdCommand = service.createKommentar(command, vorgangId); var createdCommand = service.createKommentar(command.getKommentar(), vorgangId);
return ResponseEntity.created(linkTo(CommandController.class).slash(createdCommand.getId()).toUri()).build(); return ResponseEntity.created(linkTo(CommandController.class).slash(createdCommand.getId()).toUri()).build();
} }
......
...@@ -24,8 +24,8 @@ class KommentarService { ...@@ -24,8 +24,8 @@ class KommentarService {
@Autowired @Autowired
private VorgangAttachedItemService vorgangAttachedItemService; private VorgangAttachedItemService vorgangAttachedItemService;
public Command createKommentar(@Valid KommentarCommand kommentarCommand, String vorgangId) { public Command createKommentar(@Valid Kommentar kommentar, String vorgangId) {
return vorgangAttachedItemService.createNewKommentar(addCreated(kommentarCommand.getKommentar()), vorgangId); return vorgangAttachedItemService.createNewKommentar(addCreated(kommentar), vorgangId);
} }
Kommentar addCreated(Kommentar kommentar) { Kommentar addCreated(Kommentar kommentar) {
...@@ -35,9 +35,9 @@ class KommentarService { ...@@ -35,9 +35,9 @@ class KommentarService {
.build(); .build();
} }
public Command editKommentar(@Valid KommentarCommand kommentarCommand, String kommentarId, long kommentarVersion) { public Command editKommentar(@Valid Kommentar kommentar, String kommentarId, long kommentarVersion) {
var loadedKommentar = getById(kommentarId); var loadedKommentar = getById(kommentarId);
var preparedKommentar = loadedKommentar.toBuilder().text(kommentarCommand.getKommentar().getText()).build(); var preparedKommentar = loadedKommentar.toBuilder().text(kommentar.getText()).build();
return vorgangAttachedItemService.editKommentar(preparedKommentar, kommentarId, kommentarVersion); return vorgangAttachedItemService.editKommentar(preparedKommentar, kommentarId, kommentarVersion);
} }
......
...@@ -53,7 +53,7 @@ class KommentarCommandControllerTest { ...@@ -53,7 +53,7 @@ class KommentarCommandControllerTest {
void shouldCallService() throws Exception { void shouldCallService() throws Exception {
doRequest(); doRequest();
verify(service).createKommentar(any(KommentarCommand.class), eq(VorgangHeaderTestFactory.ID)); verify(service).createKommentar(any(Kommentar.class), eq(VorgangHeaderTestFactory.ID));
} }
@Test @Test
...@@ -93,7 +93,7 @@ class KommentarCommandControllerTest { ...@@ -93,7 +93,7 @@ class KommentarCommandControllerTest {
void shouldCallService() throws Exception { void shouldCallService() throws Exception {
doRequest(); doRequest();
verify(service).editKommentar(any(KommentarCommand.class), eq(KommentarTestFactory.ID), eq(KommentarTestFactory.VERSION)); verify(service).editKommentar(any(Kommentar.class), eq(KommentarTestFactory.ID), eq(KommentarTestFactory.VERSION));
} }
@Test @Test
......
...@@ -61,8 +61,6 @@ class KommentarCommandITCase { ...@@ -61,8 +61,6 @@ class KommentarCommandITCase {
@Nested @Nested
class TestValidation { class TestValidation {
private static final String FIELD_PREFIX = "kommentarCommand.kommentar";
@DisplayName("for null Text") @DisplayName("for null Text")
@Test @Test
void createCommandWithInvalidText() throws Exception { void createCommandWithInvalidText() throws Exception {
...@@ -70,7 +68,7 @@ class KommentarCommandITCase { ...@@ -70,7 +68,7 @@ class KommentarCommandITCase {
doRequestByKommentarId(content).andExpect(status().isUnprocessableEntity()) doRequestByKommentarId(content).andExpect(status().isUnprocessableEntity())
.andExpect(jsonPath("$.issues.length()").value(1)) .andExpect(jsonPath("$.issues.length()").value(1))
.andExpect(jsonPath("$.issues.[0].field").value(FIELD_PREFIX + ".text")) .andExpect(jsonPath("$.issues.[0].field").value("kommentar.text"))
.andExpect(jsonPath("$.issues.[0].messageCode").value(ValidationMessageCodes.FIELD_IS_EMPTY)); .andExpect(jsonPath("$.issues.[0].messageCode").value(ValidationMessageCodes.FIELD_IS_EMPTY));
} }
...@@ -80,7 +78,7 @@ class KommentarCommandITCase { ...@@ -80,7 +78,7 @@ class KommentarCommandITCase {
String content = buildContentWithText(StringUtils.EMPTY); String content = buildContentWithText(StringUtils.EMPTY);
doRequestByKommentarId(content).andExpect(status().isUnprocessableEntity()) doRequestByKommentarId(content).andExpect(status().isUnprocessableEntity())
.andExpect(jsonPath("$.issues.[0].field").value(FIELD_PREFIX + ".text")); .andExpect(jsonPath("$.issues.[0].field").value("kommentar.text"));
} }
...@@ -132,8 +130,6 @@ class KommentarCommandITCase { ...@@ -132,8 +130,6 @@ class KommentarCommandITCase {
@Nested @Nested
class TestValidation { class TestValidation {
private static final String FIELD_PREFIX = "kommentarCommand.kommentar";
@DisplayName("for null Text") @DisplayName("for null Text")
@Test @Test
void createCommandWithInvalidText() throws Exception { void createCommandWithInvalidText() throws Exception {
...@@ -141,7 +137,7 @@ class KommentarCommandITCase { ...@@ -141,7 +137,7 @@ class KommentarCommandITCase {
doRequestByVorgangId(content).andExpect(status().isUnprocessableEntity()) doRequestByVorgangId(content).andExpect(status().isUnprocessableEntity())
.andExpect(jsonPath("$.issues.length()").value(1)) .andExpect(jsonPath("$.issues.length()").value(1))
.andExpect(jsonPath("$.issues.[0].field").value(FIELD_PREFIX + ".text")) .andExpect(jsonPath("$.issues.[0].field").value("kommentar.text"))
.andExpect(jsonPath("$.issues.[0].messageCode").value(ValidationMessageCodes.FIELD_IS_EMPTY)); .andExpect(jsonPath("$.issues.[0].messageCode").value(ValidationMessageCodes.FIELD_IS_EMPTY));
} }
...@@ -151,7 +147,7 @@ class KommentarCommandITCase { ...@@ -151,7 +147,7 @@ class KommentarCommandITCase {
String content = buildContentWithText(StringUtils.EMPTY); String content = buildContentWithText(StringUtils.EMPTY);
doRequestByVorgangId(content).andExpect(status().isUnprocessableEntity()) doRequestByVorgangId(content).andExpect(status().isUnprocessableEntity())
.andExpect(jsonPath("$.issues.[0].field").value(FIELD_PREFIX + ".text")); .andExpect(jsonPath("$.issues.[0].field").value("kommentar.text"));
} }
......
...@@ -97,7 +97,7 @@ class KommentarServiceTest { ...@@ -97,7 +97,7 @@ class KommentarServiceTest {
} }
private Command callCreateKommentar() { private Command callCreateKommentar() {
return service.createKommentar(KommentarCommandTestFactory.create(), VorgangHeaderTestFactory.ID); return service.createKommentar(KommentarTestFactory.create(), VorgangHeaderTestFactory.ID);
} }
} }
...@@ -137,7 +137,7 @@ class KommentarServiceTest { ...@@ -137,7 +137,7 @@ class KommentarServiceTest {
} }
private Command callEditKommentar() { private Command callEditKommentar() {
return service.editKommentar(KommentarCommandTestFactory.create(), KommentarTestFactory.ID, KommentarTestFactory.VERSION); return service.editKommentar(KommentarTestFactory.create(), KommentarTestFactory.ID, KommentarTestFactory.VERSION);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment