Skip to content

Commit 6296e23

Browse files
author
Aaron Klish
committed
Finished rebase
1 parent ba5c153 commit 6296e23

File tree

19 files changed

+72
-45
lines changed

19 files changed

+72
-45
lines changed

elide-async/src/main/java/com/yahoo/elide/async/service/AsyncQueryThread.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,16 @@ protected AsyncQueryResult processQuery() throws URISyntaxException, NoHttpRespo
7878
if (queryObj.getQueryType().equals(QueryType.JSONAPI_V1_0)) {
7979
MultivaluedMap<String, String> queryParams = getQueryParams(queryObj.getQuery());
8080
log.debug("Extracted QueryParams from AsyncQuery Object: {}", queryParams);
81-
response = elide.get(getPath(queryObj.getQuery()), queryParams, user, apiVersion, requestId);
81+
82+
//TODO - we need to add the baseUrlEndpoint to the queryObject.
83+
response = elide.get("", getPath(queryObj.getQuery()), queryParams, user, apiVersion, requestId);
8284
log.debug("JSONAPI_V1_0 getResponseCode: {}, JSONAPI_V1_0 getBody: {}",
8385
response.getResponseCode(), response.getBody());
8486
}
8587
else if (queryObj.getQueryType().equals(QueryType.GRAPHQL_V1_0)) {
86-
response = runner.run(queryObj.getQuery(), user, requestId);
88+
//TODO - we need to add the baseUrlEndpoint to the queryObject.
89+
90+
response = runner.run("", queryObj.getQuery(), user, requestId);
8791
log.debug("GRAPHQL_V1_0 getResponseCode: {}, GRAPHQL_V1_0 getBody: {}",
8892
response.getResponseCode(), response.getBody());
8993
}

elide-async/src/main/java/com/yahoo/elide/async/service/DefaultAsyncQueryDAO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected Object executeInTransaction(DataStore dataStore, Transactional action)
184184
try (DataStoreTransaction tx = dataStore.beginTransaction()) {
185185
JsonApiDocument jsonApiDoc = new JsonApiDocument();
186186
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
187-
RequestScope scope = new RequestScope("query", NO_VERSION, jsonApiDoc,
187+
RequestScope scope = new RequestScope("", "query", NO_VERSION, jsonApiDoc,
188188
tx, null, queryParams, UUID.randomUUID(), elide.getElideSettings());
189189
result = action.execute(tx, scope);
190190
tx.flush(scope);

elide-async/src/test/java/com/yahoo/elide/async/service/AsyncQueryThreadTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testProcessQueryJsonApi() throws NoHttpResponseException, URISyntaxE
5353
queryObj.setId(id);
5454
queryObj.setQuery(query);
5555
queryObj.setQueryType(QueryType.JSONAPI_V1_0);
56-
when(elide.get(anyString(), any(), any(), anyString(), any())).thenReturn(response);
56+
when(elide.get(anyString(), anyString(), any(), any(), anyString(), any())).thenReturn(response);
5757
AsyncQueryThread queryThread = new AsyncQueryThread(queryObj, user, elide, runner, asyncQueryDao, "v1");
5858
queryResultObj = queryThread.processQuery();
5959
assertEquals(queryResultObj.getResponseBody(), "ResponseBody");
@@ -69,7 +69,7 @@ public void testProcessQueryGraphQl() throws NoHttpResponseException, URISyntaxE
6969
queryObj.setId(id);
7070
queryObj.setQuery(query);
7171
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
72-
when(runner.run(eq(query), eq(user), any())).thenReturn(response);
72+
when(runner.run(anyString(), eq(query), eq(user), any())).thenReturn(response);
7373
AsyncQueryThread queryThread = new AsyncQueryThread(queryObj, user, elide, runner, asyncQueryDao, "v1");
7474
queryResultObj = queryThread.processQuery();
7575
assertEquals(queryResultObj.getResponseBody(), "ResponseBody");

elide-core/src/main/java/com/yahoo/elide/Elide.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public ElideResponse get(String baseUrlEndPoint, String path, MultivaluedMap<Str
204204
* @param apiVersion the API version
205205
* @return Elide response object
206206
*/
207-
public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDocument,
207+
public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDocument,
208208
User opaqueUser, String apiVersion) {
209209
return post(baseUrlEndPoint, path, jsonApiDocument, null, opaqueUser, apiVersion, UUID.randomUUID());
210210
}
@@ -222,7 +222,8 @@ public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDoc
222222
* @param requestId the request ID
223223
* @return Elide response object
224224
*/
225-
public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDocument, MultivaluedMap<String, String> queryParams,
225+
public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDocument,
226+
MultivaluedMap<String, String> queryParams,
226227
User opaqueUser, String apiVersion, UUID requestId) {
227228
return handleRequest(false, opaqueUser, dataStore::beginTransaction, requestId, (tx, user) -> {
228229
JsonApiDocument jsonApiDoc = mapper.readJsonApiDocument(jsonApiDocument);
@@ -250,7 +251,7 @@ public ElideResponse post(String baseUrlEndPoint, String path, String jsonApiDoc
250251
public ElideResponse patch(String baseUrlEndPoint, String contentType, String accept,
251252
String path, String jsonApiDocument,
252253
User opaqueUser, String apiVersion) {
253-
return patch(baseUrlEndPoint, contentType, accept, path, jsonApiDocument,
254+
return patch(baseUrlEndPoint, contentType, accept, path, jsonApiDocument,
254255
null, opaqueUser, apiVersion, UUID.randomUUID());
255256
}
256257

@@ -328,7 +329,7 @@ public ElideResponse delete(String baseUrlEndPoint, String path, String jsonApiD
328329
* @param requestId the request ID
329330
* @return Elide response object
330331
*/
331-
public ElideResponse delete(String baseUrlEndPoint, String path, String jsonApiDocument,
332+
public ElideResponse delete(String baseUrlEndPoint, String path, String jsonApiDocument,
332333
MultivaluedMap<String, String> queryParams,
333334
User opaqueUser, String apiVersion, UUID requestId) {
334335
return handleRequest(false, opaqueUser, dataStore::beginTransaction, requestId, (tx, user) -> {

elide-core/src/main/java/com/yahoo/elide/ElideSettingsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public ElideSettings build() {
9494
defaultMaxPageSize,
9595
defaultPageSize,
9696
updateStatusCode,
97-
serdes,
97+
serdes,
9898
enableJsonLinks);
9999
}
100100

elide-core/src/main/java/com/yahoo/elide/resources/JsonApiEndpoint.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Response post(
6868
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
6969
String safeApiVersion = apiVersion == null ? NO_VERSION : apiVersion;
7070
User user = new SecurityContextUser(securityContext);
71-
return build(elide.post(uriInfo.getBaseUri().toString(), path, jsonapiDocument,
71+
return build(elide.post(uriInfo.getBaseUri().toString(), path, jsonapiDocument,
7272
queryParams, user, safeApiVersion, UUID.randomUUID()));
7373
}
7474

@@ -121,7 +121,7 @@ public Response patch(
121121

122122
String safeApiVersion = apiVersion == null ? NO_VERSION : apiVersion;
123123
User user = new SecurityContextUser(securityContext);
124-
return build(elide.patch(uriInfo.getBaseUri().toString(), contentType, accept, path,
124+
return build(elide.patch(uriInfo.getBaseUri().toString(), contentType, accept, path,
125125
jsonapiDocument, queryParams, user, safeApiVersion, UUID.randomUUID()));
126126
}
127127

@@ -147,7 +147,8 @@ public Response delete(
147147
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
148148
String safeApiVersion = apiVersion == null ? NO_VERSION : apiVersion;
149149
User user = new SecurityContextUser(securityContext);
150-
return build(elide.delete(uriInfo.getBaseUri(), path, jsonApiDocument, queryParams, user, safeApiVersion, UUID.randomUUID()));
150+
return build(elide.delete(uriInfo.getBaseUri().toString(), path, jsonApiDocument, queryParams,
151+
user, safeApiVersion, UUID.randomUUID()));
151152
}
152153

153154
private static Response build(ElideResponse response) {

elide-core/src/test/java/com/yahoo/elide/core/LifeCycleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public void execute(LifeCycleHookBinding.Operation operation,
131131
}
132132
}
133133

134-
private final String baseUrl = "http://localhost:8080/api/v1";
135134
static class ClassPreCommitHook implements LifeCycleHook<FieldTestModel> {
136135
@Override
137136
public void execute(LifeCycleHookBinding.Operation operation,
@@ -298,6 +297,7 @@ public void relationCallback(LifeCycleHookBinding.Operation operation,
298297
*/
299298
public class LifeCycleTest {
300299

300+
private final String baseUrl = "http://localhost:8080/api/v1";
301301
private static final AuditLogger MOCK_AUDIT_LOGGER = mock(AuditLogger.class);
302302
private EntityDictionary dictionary;
303303

@@ -492,7 +492,7 @@ public void testElideGetRelationship() throws Exception {
492492
when(tx.loadObject(isA(EntityProjection.class), any(), isA(RequestScope.class))).thenReturn(mockModel);
493493

494494
MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
495-
ElideResponse response = elide.get("/testModel/1/relationships/models", headers, null, NO_VERSION);
495+
ElideResponse response = elide.get(baseUrl, "/testModel/1/relationships/models", headers, null, NO_VERSION);
496496
assertEquals(HttpStatus.SC_OK, response.getResponseCode());
497497

498498
verify(mockModel, never()).classAllFieldsCallback(any(), any());

elide-core/src/test/java/com/yahoo/elide/core/TestRequestScope.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@ public class TestRequestScope extends RequestScope {
2222

2323
private MultivaluedMap queryParamOverrides = null;
2424

25+
public TestRequestScope(String baseURL,
26+
DataStoreTransaction transaction,
27+
User user,
28+
EntityDictionary dictionary) {
29+
super(baseURL, null, NO_VERSION, new JsonApiDocument(), transaction, user, null, UUID.randomUUID(),
30+
new ElideSettingsBuilder(null)
31+
.withEntityDictionary(dictionary)
32+
.withJSONApiLinks(new DefaultJSONApiLinks())
33+
.build());
34+
}
35+
2536
public TestRequestScope(DataStoreTransaction transaction,
2637
User user,
2738
EntityDictionary dictionary) {
28-
super(null, NO_VERSION, new JsonApiDocument(), transaction, user, null, UUID.randomUUID(),
39+
super(null, null, NO_VERSION, new JsonApiDocument(), transaction, user, null, UUID.randomUUID(),
2940
new ElideSettingsBuilder(null)
3041
.withEntityDictionary(dictionary)
3142
.build());
@@ -34,7 +45,7 @@ public TestRequestScope(DataStoreTransaction transaction,
3445
public TestRequestScope(EntityDictionary dictionary,
3546
String path,
3647
MultivaluedMap<String, String> queryParams) {
37-
super(path, NO_VERSION, new JsonApiDocument(), null, null, queryParams, UUID.randomUUID(),
48+
super(null, path, NO_VERSION, new JsonApiDocument(), null, null, queryParams, UUID.randomUUID(),
3849
new ElideSettingsBuilder(null)
3950
.withEntityDictionary(dictionary)
4051
.build());

elide-core/src/test/java/com/yahoo/elide/jsonapi/JsonApiTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import static org.mockito.Mockito.mock;
1111

1212
import com.yahoo.elide.core.DataStoreTransaction;
13-
import com.yahoo.elide.core.DefaultJSONApiLinks;
1413
import com.yahoo.elide.core.EntityDictionary;
1514
import com.yahoo.elide.core.PersistentResource;
1615
import com.yahoo.elide.core.RequestScope;
@@ -50,6 +49,7 @@
5049
public class JsonApiTest {
5150
private JsonApiMapper mapper;
5251
private User user = new TestUser("0");
52+
private static String BASE_URL = "http://localhost:8080/json/";
5353

5454
private EntityDictionary dictionary;
5555
private DataStoreTransaction tx = mock(DataStoreTransaction.class, Answers.CALLS_REAL_METHODS);
@@ -67,7 +67,7 @@ public void writeSingleNoAttributesNoRel() throws JsonProcessingException {
6767
Parent parent = new Parent();
6868
parent.setId(123L);
6969

70-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
70+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
7171

7272
JsonApiDocument jsonApiDocument = new JsonApiDocument();
7373
jsonApiDocument.setData(new Data<>(new PersistentResource<>(parent, null, userScope.getUUIDFor(parent), userScope).toResource()));
@@ -104,7 +104,7 @@ public void writeSingle() throws JsonProcessingException {
104104
child.setParents(Collections.singleton(parent));
105105
child.setFriends(new HashSet<>());
106106

107-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
107+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
108108

109109
JsonApiDocument jsonApiDocument = new JsonApiDocument();
110110
jsonApiDocument.setData(new Data<>(new PersistentResource<>(parent, null, userScope.getUUIDFor(parent), userScope).toResource()));
@@ -141,7 +141,7 @@ public void writeSingleIncluded() throws JsonProcessingException {
141141
child.setParents(Collections.singleton(parent));
142142
child.setFriends(new HashSet<>());
143143

144-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
144+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
145145

146146
PersistentResource<Parent> pRec = new PersistentResource<>(parent, null, userScope.getUUIDFor(parent), userScope);
147147

@@ -195,7 +195,7 @@ public void writeList() throws JsonProcessingException {
195195
parent.setFirstName("bob");
196196
child.setFriends(new HashSet<>());
197197

198-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
198+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
199199

200200
JsonApiDocument jsonApiDocument = new JsonApiDocument();
201201
jsonApiDocument.setData(
@@ -233,7 +233,7 @@ public void writeListIncluded() throws JsonProcessingException {
233233
parent.setFirstName("bob");
234234
child.setFriends(new HashSet<>());
235235

236-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
236+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
237237

238238
PersistentResource<Parent> pRec = new PersistentResource<>(parent, null, userScope.getUUIDFor(parent), userScope);
239239

@@ -475,7 +475,7 @@ public void compareOrder() throws JsonProcessingException {
475475
Parent parent2 = new Parent();
476476
parent2.setId(456L);
477477

478-
RequestScope userScope = new TestRequestScope(tx, user, dictionary);
478+
RequestScope userScope = new TestRequestScope(BASE_URL, tx, user, dictionary);
479479

480480
PersistentResource<Parent> pRec1 = new PersistentResource<>(parent1, null, userScope.getUUIDFor(parent1), userScope);
481481
PersistentResource<Parent> pRec2 = new PersistentResource<>(parent2, null, userScope.getUUIDFor(parent2), userScope);

elide-datastore/elide-datastore-jpa/src/main/java/com/yahoo/elide/datastores/jpa/transaction/AbstractJpaTransaction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public Iterable<Object> loadObjects(
203203

204204
if (pagination != null) {
205205
//Issue #1429
206-
if (pagination.returnPageTotals() && (!results.isEmpty() || p.getLimit() == 0)) {
206+
if (pagination.returnPageTotals() && (!results.isEmpty() || pagination.getLimit() == 0)) {
207207
pagination.setPageTotals(getTotalRecords(entityClass,
208208
Optional.ofNullable(filterExpression), scope.getDictionary()));
209209
}

0 commit comments

Comments
 (0)