-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DT-1206: Bug fixes for support requests (#2455)
- Loading branch information
Showing
7 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/org/broadinstitute/consent/http/exceptions/UnprocessableEntityException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.broadinstitute.consent.http.exceptions; | ||
|
||
import com.google.api.client.http.HttpStatusCodes; | ||
import jakarta.ws.rs.ClientErrorException; | ||
|
||
public class UnprocessableEntityException extends ClientErrorException { | ||
|
||
public UnprocessableEntityException(String message) { | ||
super(message, HttpStatusCodes.STATUS_CODE_UNPROCESSABLE_ENTITY); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.doThrow; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.google.api.client.http.HttpStatusCodes; | ||
|
@@ -10,6 +11,7 @@ | |
import jakarta.ws.rs.core.Response; | ||
import java.util.stream.Stream; | ||
import org.broadinstitute.consent.http.enumeration.SupportRequestType; | ||
import org.broadinstitute.consent.http.exceptions.UnprocessableEntityException; | ||
import org.broadinstitute.consent.http.service.SupportRequestService; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
@@ -131,6 +133,25 @@ void testPostRequestInvalidFields(String body) { | |
} | ||
} | ||
|
||
@Test | ||
void testUnprocessableTicket() throws Exception { | ||
doThrow(new UnprocessableEntityException("Unprocessable")).when(supportRequestService) | ||
.postTicketToSupport(any()); | ||
try (Response response = supportResource.postRequest(""" | ||
{ | ||
"name": "Test User", | ||
"email": "[email protected]", | ||
"subject": "Test Subject", | ||
"description": "Test Description", | ||
"type": "QUESTION", | ||
"url": "https://example.com", | ||
"uploads": ["token1", "token2"] | ||
} | ||
""")) { | ||
assertEquals(HttpStatusCodes.STATUS_CODE_UNPROCESSABLE_ENTITY, response.getStatus()); | ||
} | ||
} | ||
|
||
@Test | ||
void testPostUpload() throws Exception { | ||
JsonObject obj = new JsonObject(); | ||
|
@@ -141,4 +162,13 @@ void testPostUpload() throws Exception { | |
} | ||
} | ||
|
||
@Test | ||
void testUnprocessableUpload() throws Exception { | ||
doThrow(new UnprocessableEntityException("Unprocessable")).when(supportRequestService) | ||
.postAttachmentToSupport(any()); | ||
try (Response response = supportResource.postUpload("test".getBytes())) { | ||
assertEquals(HttpStatusCodes.STATUS_CODE_UNPROCESSABLE_ENTITY, response.getStatus()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters