use of com.google.firebase.firestore.conformance.model.TestCase in project firebase-android-sdk by firebase.
the class TestCaseConverter method convertTestCases.
public List<TestCase> convertTestCases(DatastoreTestTrace.TestTrace trace) {
List<TestCase> testCases = new ArrayList<>();
for (DatastoreTestTrace.DatastoreAction action : trace.getActionList()) {
if (actionFilter.test(action)) {
TestCase.Builder builder = TestCase.Builder.builder();
DatastoreTestTrace.FirestoreV1Action firestoreAction = action.getFirestoreV1Action();
List<Collection> collections = convertDatabaseContents(firestoreAction);
StructuredQuery queryProto = firestoreAction.getRunQuery().getRequest().getStructuredQuery();
String parentPath = ResourcePath.fromString(firestoreAction.getRunQuery().getRequest().getParent()).popFirst(5).toString();
Query query = convertQuery(queryProto, parentPath);
// Add query collection to contents if there are no pre-existing documents.
if (collections.isEmpty()) {
collections.add(Collection.Builder.builder().setName(query.getCollection()).build());
}
builder.setCollections(collections);
builder.setQuery(query);
// Convert results.
builder.setException(firestoreAction.hasStatus());
if (!firestoreAction.hasStatus()) {
Result.Builder result = Result.Builder.builder();
List<RunQueryResponse> responses = firestoreAction.getRunQuery().getResponseList();
result.setDocuments(responses.stream().filter(r -> r.hasDocument()).map(r -> r.getDocument()).collect(Collectors.toList()));
builder.setResult(result.build());
}
builder.setName(String.format("%s_%d", trace.getTraceId(), action.getActionId()));
testCases.add(builder.build());
}
}
return testCases;
}
use of com.google.firebase.firestore.conformance.model.TestCase in project firebase-android-sdk by firebase.
the class ConformanceTest method run.
@Test
public void run() throws Exception {
for (TestCase testCase : testCases) {
ConformanceRuntime runtime = new ConformanceRuntime(firestore, Source.CACHE);
executeTestCases(testCase, runtime);
}
}
Aggregations