protected void assertHistoryRecorded() { MySqlSchema duplicate = build.storeDatabaseHistoryInFile(TEST_FILE_PATH).createSchemas(); duplicate.loadHistory(source); // Make sure table is defined in each ... assertThat(duplicate.tableIds()).isEqualTo(mysql.tableIds()); for (int i = 0; i != 2; ++i) { duplicate.tableIds().forEach(tableId -> { TableSchema dupSchema = duplicate.schemaFor(tableId); TableSchema schema = mysql.schemaFor(tableId); assertThat(schema).isEqualTo(dupSchema); Table dupTable = duplicate.tableFor(tableId); Table table = mysql.tableFor(tableId); assertThat(table).isEqualTo(dupTable); }); mysql.tableIds().forEach(tableId -> { TableSchema dupSchema = duplicate.schemaFor(tableId); TableSchema schema = mysql.schemaFor(tableId); assertThat(schema).isEqualTo(dupSchema); Table dupTable = duplicate.tableFor(tableId); Table table = mysql.tableFor(tableId); assertThat(table).isEqualTo(dupTable); }); duplicate.refreshSchemas(); } }
@Test public void testLegacyIdCorrectlyAnnotated() { ThriftStructMetadataBuilder builder = new ThriftStructMetadataBuilder(new ThriftCatalog(), LegacyIdCorrect.class); ThriftStructMetadata metadata = builder.build(); Set<Integer> seen = new HashSet<>(); for (ThriftFieldMetadata field : metadata.getFields()) { seen.add((int) field.getId()); } assertThat(seen) .as("fields found in LegacyIdCorrect") .isEqualTo(LegacyIdCorrect.IDS); }
@Test public void testLegacyIdOnUnion() { ThriftUnionMetadataBuilder builder = new ThriftUnionMetadataBuilder(new ThriftCatalog(), LegacyIdUnionCorrect.class); ThriftStructMetadata metadata = builder.build(); Set<Integer> seen = new HashSet<>(); for (ThriftFieldMetadata field : metadata.getFields()) { seen.add((int) field.getId()); } assertThat(seen) .as("fields found in LegacyIdUnionCorrect") .isEqualTo(LegacyIdUnionCorrect.IDS); }
.isEqualTo(LegacyIdCorrect.IDS);
@Test public void testGetStorageCollectionsQuery() throws Exception { DBCollection collection = db.getCollection("testQueryCollection"); if (collection != null) { collection.drop(); } collection = db.createCollection("testQueryCollection", new BasicDBObject("count", 0)); // insert data records for the test setupPeopleData(collection); assertThat(collection.count()).isEqualTo(6); // This should return 3 items // SimpleResourceParams resourceParams = new SimpleResourceParams(); resourceParams.put("q", "[{$group:{_id:{country:'$country'},numPeople:{$sum:1}}}]"); RequestContext requestContext = new RequestContext.Builder() .returnFields(new DefaultReturnFields("*(*)")) .resourceParams(resourceParams) .build(); ResourceState result = client.read(requestContext, "/testApp/" + BASEPATH + "/testQueryCollection/_aggregate"); // verify response assertThat(result).isNotNull(); assertThat(result.id()).isEqualTo("_aggregate"); assertThat(result.getProperty("result")).isNotNull(); assertThat(result.getProperty("result")).isInstanceOf(List.class); List results = (List) result.getProperty("result"); assertThat(results.size()).isEqualTo(3); Set countries = checkAggregateItems(results); Set expected = new HashSet(Arrays.asList(new String[] { "DE", "FR", "US" })); assertThat(countries).isEqualTo(expected); }
protected void assertHistoryRecorded() { MySqlSchema duplicate = build.storeDatabaseHistoryInFile(TEST_FILE_PATH).createSchemas(); duplicate.loadHistory(source); // Make sure table is defined in each ... assertThat(duplicate.tableIds()).isEqualTo(mysql.tableIds()); for (int i = 0; i != 2; ++i) { duplicate.tableIds().forEach(tableId -> { TableSchema dupSchema = duplicate.schemaFor(tableId); TableSchema schema = mysql.schemaFor(tableId); assertThat(schema).isEqualTo(dupSchema); Table dupTable = duplicate.tableFor(tableId); Table table = mysql.tableFor(tableId); assertThat(table).isEqualTo(dupTable); }); mysql.tableIds().forEach(tableId -> { TableSchema dupSchema = duplicate.schemaFor(tableId); TableSchema schema = mysql.schemaFor(tableId); assertThat(schema).isEqualTo(dupSchema); Table dupTable = duplicate.tableFor(tableId); Table table = mysql.tableFor(tableId); assertThat(table).isEqualTo(dupTable); }); duplicate.refreshSchemas(); } }