@SuppressWarnings("unchecked") private Error readError(Map<String, Object> payload) { String message = null; final List<Error.Location> locations = new ArrayList<>(); final Map<String, Object> customAttributes = new HashMap<>(); for (Map.Entry<String, Object> entry : payload.entrySet()) { if ("message".equals(entry.getKey())) { Object value = entry.getValue(); message = value != null ? value.toString() : null; } else if ("locations".equals(entry.getKey())) { List<Map<String, Object>> locationItems = (List<Map<String, Object>>) entry.getValue(); if (locationItems != null) { for (Map<String, Object> item : locationItems) { locations.add(readErrorLocation(item)); } } } else { if (entry.getValue() != null) { customAttributes.put(entry.getKey(), entry.getValue()); } } } return new Error(message, locations, customAttributes); }
@Override public Object answer(InvocationOnMock invocation) throws Throwable { ((ApolloInterceptor.CallBack) invocation.getArguments()[2]).onResponse( new ApolloInterceptor.InterceptorResponse( mockHttpResponse(), com.apollographql.apollo.api.Response.<MockOperation.Data>builder(new MockOperation()) .errors(Collections.singletonList(new Error("SomeOtherError", null, null))) .build(), Collections.<Record>emptyList() ) ); return null; } }).when(chain).proceedAsync(
mockHttpResponse(), com.apollographql.apollo.api.Response.<MockOperation.Data>builder(new MockOperation()) .errors(Collections.singletonList(new Error("PersistedQueryNotFound", null, null))) .build(), Collections.<Record>emptyList()
mockHttpResponse(), com.apollographql.apollo.api.Response.<MockOperation.Data>builder(new MockOperation()) .errors(Collections.singletonList(new Error("PersistedQueryNotSupported", null, null))) .build(), Collections.<Record>emptyList()
@SuppressWarnings("unchecked") private Error readError(Map<String, Object> payload) { String message = null; final List<Error.Location> locations = new ArrayList<>(); final Map<String, Object> customAttributes = new HashMap<>(); for (Map.Entry<String, Object> entry : payload.entrySet()) { if ("message".equals(entry.getKey())) { Object value = entry.getValue(); message = value != null ? value.toString() : null; } else if ("locations".equals(entry.getKey())) { List<Map<String, Object>> locationItems = (List<Map<String, Object>>) entry.getValue(); if (locationItems != null) { for (Map<String, Object> item : locationItems) { locations.add(readErrorLocation(item)); } } } else { if (entry.getValue() != null) { customAttributes.put(entry.getKey(), entry.getValue()); } } } return new Error(message, locations, customAttributes); }
@SuppressWarnings("unchecked") private Error readError(Map<String, Object> payload) { String message = null; final List<Error.Location> locations = new ArrayList<>(); final Map<String, Object> customAttributes = new HashMap<>(); for (Map.Entry<String, Object> entry : payload.entrySet()) { if ("message".equals(entry.getKey())) { Object value = entry.getValue(); message = value != null ? value.toString() : null; } else if ("locations".equals(entry.getKey())) { List<Map<String, Object>> locationItems = (List<Map<String, Object>>) entry.getValue(); if (locationItems != null) { for (Map<String, Object> item : locationItems) { locations.add(readErrorLocation(item)); } } } else { if (entry.getValue() != null) { customAttributes.put(entry.getKey(), entry.getValue()); } } } return new Error(message, locations, customAttributes); }