-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALS-4771] Add common area UUID to query
- When the GIC common area makes a federated query request to the institute nodes, it passes a UUID for the query - This UUID is to be used in later development as a unifying, interinstitutional identifier for stuff like data sharing - Add query UUID to QueryRequest - Make QueryRequest ignore unknown fields for backwards compatability - Add UUID to query meta in passthrough - Sanity test for missing UUID jackson stuff
- Loading branch information
1 parent
cc6c8a6
commit aefe63c
Showing
4 changed files
with
69 additions
and
2 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
45 changes: 45 additions & 0 deletions
45
...ic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/QueryRequestTest.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,45 @@ | ||
package edu.harvard.dbmi.avillach.domain; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import junit.framework.TestCase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
public class QueryRequestTest extends TestCase { | ||
|
||
public void testShouldIgnoreMissingQueryId() throws JsonProcessingException { | ||
QueryRequest expected = new QueryRequestWithEq(); | ||
expected.setQuery("{}"); | ||
expected.setResourceCredentials(new HashMap<>()); | ||
expected.setResourceUUID(UUID.fromString("364c958e-53bb-4be7-bd5b-44fcda1592bc")); | ||
expected.setCommonAreaUUID(null); | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
String jsonWithNoCUUID = | ||
"{\"resourceCredentials\":{},\"query\":\"{}\",\"resourceUUID\":\"364c958e-53bb-4be7-bd5b-44fcda1592bc\"}"; | ||
QueryRequest actual = mapper.readValue(jsonWithNoCUUID, QueryRequestWithEq.class); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
/** | ||
* This is just to get comparison to work for the test. | ||
*/ | ||
private static final class QueryRequestWithEq extends QueryRequest { | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof QueryRequestWithEq)) return false; | ||
QueryRequestWithEq that = (QueryRequestWithEq) o; | ||
return Objects.equals(getResourceCredentials(), that.getResourceCredentials()) && Objects.equals(getQuery(), that.getQuery()) && Objects.equals(getResourceUUID(), that.getResourceUUID()) && Objects.equals(getCommonAreaUUID(), that.getCommonAreaUUID()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getResourceCredentials(), getQuery(), getResourceUUID(), getCommonAreaUUID()); | ||
} | ||
} | ||
} |