Skip to content

Commit

Permalink
Updated the test in ControllerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
RuiChen12 committed Oct 26, 2024
1 parent 4a7f736 commit 1b1f690
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public ResponseEntity<String> updateDescription(
* This allows an owner of a Grouping to enable/disable that a Grouping connected to a given sync
* destination.
*/
@PostMapping(value = "/groupings/{path}/syncDests/{syncDestId}/{status:true|false}")
@PostMapping(value = "/groupings/{path}/syncDests/{syncDestId}/{status}")
public ResponseEntity<String> updateSyncDest(
@PathVariable String path,
@PathVariable String syncDestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@
/**
* Toggle the given sync destination.
*/
updateSyncDest(path, syncDestId, turnOn, onSuccess, onError) {
let endpoint = `${BASE_URL}groupings/${path}/syncDests/${syncDestId}/${turnOn}`;
updateSyncDest(path, syncDestId, status, onSuccess, onError) {
let endpoint = `${BASE_URL}groupings/${path}/syncDests/${syncDestId}/${status}`;
dataProvider.updateData(endpoint, onSuccess, onError);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,36 +669,30 @@ public void updateDescriptionTest() throws Exception {

@Test
@WithMockUhUser
public void enableSyncDestTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "groupings/" + GROUPING + "/syncDests/listserv/enable";
public void updateSyncDestTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "groupings/" + GROUPING + "/syncDests/listserv/";

String enableUri = uri + "true";
given(httpRequestService.makeApiRequest(eq(UID), anyString(), eq(HttpMethod.PUT)))
.willReturn(new ResponseEntity(HttpStatus.OK));
.willReturn(new ResponseEntity<>(HttpStatus.OK));

assertNotNull(mockMvc.perform(post(uri).with(csrf()))
assertNotNull(mockMvc.perform(post(enableUri).with(csrf()))
.andExpect(status().isOk())
.andReturn());

verify(httpRequestService, times(1))
.makeApiRequest(eq(UID), anyString(), eq(HttpMethod.PUT));
}

@Test
@WithMockUhUser
public void disableSyncDestTest() throws Exception {
String uri = REST_CONTROLLER_BASE + "groupings/" + GROUPING + "/syncDests/listserv/disable";

String disableUri = uri + "false";
given(httpRequestService.makeApiRequest(eq(UID), anyString(), eq(HttpMethod.PUT)))
.willReturn(new ResponseEntity(HttpStatus.OK));
.willReturn(new ResponseEntity<>(HttpStatus.OK));

assertNotNull(mockMvc.perform(post(uri).with(csrf()))
assertNotNull(mockMvc.perform(post(disableUri).with(csrf()))
.andExpect(status().isOk())
.andReturn());

verify(httpRequestService, times(1))
verify(httpRequestService, times(2))
.makeApiRequest(eq(UID), anyString(), eq(HttpMethod.PUT));
}

@Test
@WithMockUhUser
public void setOptInTrueTest() throws Exception {
Expand Down

0 comments on commit 1b1f690

Please sign in to comment.