Skip to content

Commit

Permalink
Merge pull request #843 from DataVault/DS-LUC070-148-20241119
Browse files Browse the repository at this point in the history
#LUC070-148 Proper fix for /admin/review (hopefully)
  • Loading branch information
dspeed2 authored Nov 19, 2024
2 parents 8a89020 + ef17243 commit a3eb1c7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public class VaultReview {
@Column(name = "comment", nullable = true, columnDefinition = "TEXT")
private String comment;

public VaultReview() {

}

public String getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,10 @@ public String getVault(ModelMap model, @PathVariable("vaultid") String vaultID,

VaultReview currentReview = restService.getVaultReview(reviewInfo.getVaultReviewId());
VaultReviewModel vaultReviewModel = new VaultReviewModel(currentReview);

List<DepositReviewModel> depositReviewModels = new ArrayList<>();
for (int i = 0; i < reviewInfo.getDepositIds().size(); i++) {
DepositInfo depositInfo = restService.getDeposit(reviewInfo.getDepositIds().get(i));
DepositReview depositReview = restService.getDepositReview(reviewInfo.getDepositReviewIds().get(i));
DepositReview depositReview = restService.getDepositReview(reviewInfo.getDepositIds().get(i));
DepositReviewModel drm = new DepositReviewModel();

// Set DepositReview stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ public String showReview(ModelMap model,
}



// Process the completed review page
@PostMapping("/admin/vaults/{vaultid}/reviews/{reviewid}")
public String processReview(@RequestBody VaultReviewModel vaultReviewModel,
@RequestMapping(value = "/admin/vaults/{vaultid}/reviews/{reviewid}", method = RequestMethod.POST)
public String processReview(@ModelAttribute VaultReviewModel vaultReviewModel,
ModelMap model,
RedirectAttributes redirectAttributes,
@PathVariable("vaultid") String vaultID,
@PathVariable("reviewid") String reviewID,
@RequestParam String action,
RedirectAttributes redirectAttributes ) {
@RequestParam String action) {

// Note - The ModelAttributes made available here are not the same objects as those passed to the View,
// they only contain the values entered on screen. With that in mind, fetch the original objects again and
Expand Down Expand Up @@ -175,7 +177,7 @@ public String processReview(@RequestBody VaultReviewModel vaultReviewModel,

if (vaultReviewModel.getDepositReviewModels() != null) {
for (DepositReviewModel drm : vaultReviewModel.getDepositReviewModels()) {
DepositReview originalDepositReview = restService.getDepositReview(drm.getDepositReviewId());
DepositReview originalDepositReview = restService.getDepositReview(drm.getDepositId());
originalDepositReview.setDeleteStatus(drm.getDeleteStatus());
originalDepositReview.setComment(drm.getComment());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ol class="breadcrumb">
<li><a th:href="@{/admin/}"><b>Administration</b></a></li>
<li><a th:href="@{/admin/vaults}"><b>Reviews</b></a></li>
<li><a th:href="@{/admin/reviews}"><b>Reviews</b></a></li>
<li class="active"><b>Vault:</b> [[${vault.name}]]</li>
</ol>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void testProcessReview_ActionCancel() throws Exception {

RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID)
.queryParam("action", "Cancel")
.content(toJson(mVaultReviewModel))
.flashAttr("VaultReviewModel", mVaultReviewModel)
.contentType(MediaType.APPLICATION_JSON)
.with(csrf());
// Act
Expand All @@ -368,12 +368,12 @@ void testProcessReview_ActionSave() throws Exception {

RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID)
.queryParam("action", "Save")
.content(toJson(mVaultReviewModel))
.flashAttr("vaultReviewModel", mVaultReviewModel)
.contentType(MediaType.APPLICATION_JSON)
.with(csrf());
// Act
MvcResult mvcResult = mockMvc.perform(requestBuilder).andReturn();
//Assert
// Assert
assertThat(mvcResult.getModelAndView().getViewName()).isEqualTo("redirect:/admin/reviews");

verify(mRestService).getVaultReview(TEST_VAULT_REVIEW_ID);
Expand All @@ -396,7 +396,7 @@ void testProcessReview_Submit_WithNoReviewDate_AndNoRetainedDeposits() throws Ex

RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID)
.queryParam("action", "Submit")
.content(toJson(mVaultReviewModel))
.flashAttr("vaultReviewModel", mVaultReviewModel)
.contentType(MediaType.APPLICATION_JSON)
.with(csrf());
// Act
Expand All @@ -421,7 +421,7 @@ void testProcessReview_Submit_WithNoRetainedDeposits_AndReviewDateNotNull() thro

RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID)
.queryParam("action", "Submit")
.content(toJson(mVaultReviewModel))
.flashAttr("vaultReviewModel", mVaultReviewModel)
.contentType(MediaType.APPLICATION_JSON)
.with(csrf());
// Act
Expand Down Expand Up @@ -451,7 +451,7 @@ void testProcessReview_Submit_WithNoReviewDate_AndRetainedDeposits_ThenError() t

RequestBuilder requestBuilder = MockMvcRequestBuilders.post("/admin/vaults/"+TEST_VAULT_ID_1+"/reviews/" + TEST_VAULT_REVIEW_ID)
.queryParam("action", "Submit")
.content(toJson(mVaultReviewModel))
.flashAttr("vaultReviewModel", mVaultReviewModel)
.contentType(MediaType.APPLICATION_JSON)
.with(csrf());
// Act
Expand Down

0 comments on commit a3eb1c7

Please sign in to comment.