forked from GoogleCloudPlatform/appengine-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up job id handling in servlets
- Loading branch information
1 parent
b24fe0b
commit 7747143
Showing
5 changed files
with
62 additions
and
17 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
java/src/test/java/com/google/appengine/tools/mapreduce/impl/util/RequestUtilsTest.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,35 @@ | ||
package com.google.appengine.tools.mapreduce.impl.util; | ||
|
||
import com.google.cloud.datastore.Key; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import java.net.URLDecoder; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class RequestUtilsTest { | ||
|
||
public final String ENCODED_EXAMPLE = "partition_id+%7B%0A++project_id%3A+%22worklytics-dev%22%0A%7D%0Apath+%7B%0A++kind%3A+%22pipeline-job%22%0A++name%3A+%22c6fa877b-81a6-4e17-a8f7-62268036db97%22%0A%7D%0A"; | ||
|
||
@Test | ||
void getJobId() { | ||
|
||
Key example = | ||
Key.fromUrlSafe(ENCODED_EXAMPLE); | ||
|
||
RequestUtils requestUtils = new RequestUtils(); | ||
HttpServletRequest request = mock(HttpServletRequest.class); | ||
|
||
// HttpServletRequest *decodes* url params | ||
when(request.getParameter("root_pipeline_id")) | ||
.thenReturn(URLDecoder.decode(example.toUrlSafe())); | ||
|
||
//in effect, ensure round-trip encode and decode works | ||
assertEquals(ENCODED_EXAMPLE, | ||
requestUtils.getJobId(request, "root_pipeline_id").get()); | ||
} | ||
} |