Skip to content

Commit

Permalink
move enqueueretry to POST
Browse files Browse the repository at this point in the history
  • Loading branch information
frabacche committed Mar 4, 2024
1 parent e65d766 commit 2326410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

/**
* Rest Controller for requesting the reprocessing of LDNMessageEntity
Expand All @@ -43,7 +40,7 @@
*/
@RestController
@RequestMapping("/api/" + LDNMessageEntityRest.CATEGORY + "/"
+ LDNMessageEntityRest.NAME_PLURALS + "/enqueueretry" + REGEX_REQUESTMAPPING_IDENTIFIER_AS_URN_UUID)
+ LDNMessageEntityRest.NAME_PLURALS + REGEX_REQUESTMAPPING_IDENTIFIER_AS_URN_UUID +"/enqueueretry")
public class LDNMessageRestController implements InitializingBean {

private static final Logger log = LogManager.getLogger(LDNMessageRestController.class);
Expand All @@ -64,11 +61,11 @@ public class LDNMessageRestController implements InitializingBean {
public void afterPropertiesSet() {
discoverableEndpointsService.register(this,
List.of(Link.of("/api/" + LDNMessageEntityRest.CATEGORY + "/"
+ LDNMessageEntityRest.NAME_PLURALS + "/enqueueretry/{id}",
+ LDNMessageEntityRest.NAME_PLURALS + "{id}/enqueueretry",
"enqueueretry")));
}

@GetMapping(produces = "application/json")
@PostMapping(produces = "application/json")
@PreAuthorize("hasAuthority('ADMIN')")
public ResponseEntity<String> findByItem(@PathVariable("id") String id)
throws SQLException, AuthorizeException, JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ public class LDNMessageRestControllerIT extends AbstractControllerIntegrationTes
@Test
public void findByItemUnAuthorizedTest() throws Exception {
getClient()
.perform(get("/api/ldn/messages/enqueueretry/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4"))
.perform(post("/api/ldn/messages/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4/enqueueretry"))
.andExpect(status().isUnauthorized());
}

@Test
public void findByItemIsForbiddenTest() throws Exception {
String authToken = getAuthToken(eperson.getEmail(), password);
getClient(authToken)
.perform(get("/api/ldn/messages/enqueueretry/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4"))
.perform(get("/api/ldn/messages/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4/enqueueretry"))
.andExpect(status().isForbidden());
}

@Test
public void findByItemNotFoundTest() throws Exception {
String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(get("/api/ldn/messages/enqueueretry/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4"))
.perform(get("/api/ldn/messages/urn:uuid:668f26e0-2c8d-4117-a0d2-ee713523bcb4/enqueueretry"))
.andExpect(status().isNotFound());
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public void findByItemTest() throws Exception {

String authToken = getAuthToken(admin.getEmail(), password);
getClient(authToken)
.perform(get("/api/ldn/messages/enqueueretry/" + notification.getId()))
.perform(get("/api/ldn/messages/" + notification.getId() + "/enqueueretry"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id", is(notification.getId())))
.andExpect(jsonPath("$.notificationId", is(notification.getId())))
Expand Down

0 comments on commit 2326410

Please sign in to comment.