use of com.google.api.ads.admanager.axis.v202205.ResultSet in project googleads-java-lib by googleads.
the class PqlTest method testGetColumnLabels.
@Test
public void testGetColumnLabels() {
ResultSet resultSet = new ResultSet();
resultSet.setColumnTypes(new ColumnType[] { column1, column2, column3 });
assertEquals(Lists.newArrayList(new String[] { "column1", "column2", "column3" }), Pql.getColumnLabels(resultSet));
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project googleads-java-lib by googleads.
the class PqlTest method testCombineResultSet.
@Test
public void testCombineResultSet() {
Row row1 = new Row();
row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
Row row2 = new Row();
row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
Row row3 = new Row();
row3.setValues(new Value[] { textValue3, booleanValue3, numberValue3 });
ResultSet resultSet1 = new ResultSet();
resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
resultSet1.setRows(new Row[] { row1, row2 });
ResultSet resultSet2 = new ResultSet();
resultSet2.setColumnTypes(new ColumnType[] { column1, column2, column3 });
resultSet2.setRows(new Row[] { row3 });
ResultSet combinedResultSet = Pql.combineResultSets(resultSet1, resultSet2);
assertEquals(3, combinedResultSet.getRows().length);
assertArrayEquals(new ColumnType[] { column1, column2, column3 }, combinedResultSet.getColumnTypes());
assertArrayEquals(new Value[] { textValue1, booleanValue1, numberValue1 }, combinedResultSet.getRows()[0].getValues());
assertArrayEquals(new Value[] { textValue2, booleanValue2, numberValue2 }, combinedResultSet.getRows()[1].getValues());
assertArrayEquals(new Value[] { textValue3, booleanValue3, numberValue3 }, combinedResultSet.getRows()[2].getValues());
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project googleads-java-lib by googleads.
the class PqlTest method testCombineResultSet_badColumns.
@Test
public void testCombineResultSet_badColumns() {
Row row1 = new Row();
row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
Row row2 = new Row();
row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
Row row3 = new Row();
row3.setValues(new Value[] { textValue3, booleanValue3 });
ResultSet resultSet1 = new ResultSet();
resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
resultSet1.setRows(new Row[] { row1, row2 });
ResultSet resultSet2 = new ResultSet();
resultSet2.setColumnTypes(new ColumnType[] { column1, column2 });
resultSet2.setRows(new Row[] { row3 });
thrown.expect(IllegalArgumentException.class);
Pql.combineResultSets(resultSet1, resultSet2);
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method testInvalidRecordReceived.
@Test
public void testInvalidRecordReceived() {
final Timestamp startTimestamp = Timestamp.ofTimeSecondsAndNanos(0, 1000);
final Timestamp endTimestamp = Timestamp.ofTimeSecondsAndNanos(startTimestamp.getSeconds(), startTimestamp.getNanos() + 1);
mockTableExists();
mockGetWatermark(startTimestamp);
ResultSet getPartitionResultSet = mockGetParentPartition(startTimestamp, endTimestamp);
mockGetPartitionsAfter(Timestamp.ofTimeSecondsAndNanos(startTimestamp.getSeconds(), startTimestamp.getNanos() - 1), getPartitionResultSet);
mockGetPartitionsAfter(Timestamp.ofTimeSecondsAndNanos(startTimestamp.getSeconds(), startTimestamp.getNanos()), ResultSet.newBuilder().setMetadata(PARTITION_METADATA_RESULT_SET_METADATA).build());
mockGetPartitionsAfter(Timestamp.ofTimeSecondsAndNanos(startTimestamp.getSeconds(), startTimestamp.getNanos() + 1), ResultSet.newBuilder().setMetadata(PARTITION_METADATA_RESULT_SET_METADATA).build());
mockInvalidChangeStreamRecordReceived(startTimestamp, endTimestamp);
try {
pipeline.apply(SpannerIO.readChangeStream().withSpannerConfig(getSpannerConfig()).withChangeStreamName(TEST_CHANGE_STREAM).withMetadataDatabase(TEST_DATABASE).withMetadataTable(TEST_TABLE).withInclusiveStartAt(startTimestamp).withInclusiveEndAt(endTimestamp));
pipeline.run().waitUntilFinish();
} finally {
thrown.expect(PipelineExecutionException.class);
thrown.expectMessage("Field not found");
}
}
use of com.google.api.ads.admanager.axis.v202205.ResultSet in project beam by apache.
the class SpannerChangeStreamErrorTest method mockGetWatermark.
private void mockGetWatermark(Timestamp watermark) {
Statement watermarkStatement = Statement.newBuilder("SELECT Watermark FROM my-metadata-table WHERE State != @state ORDER BY Watermark ASC LIMIT 1").bind("state").to(State.FINISHED.name()).build();
ResultSetMetadata watermarkResultSetMetadata = ResultSetMetadata.newBuilder().setRowType(StructType.newBuilder().addFields(Field.newBuilder().setName("Watermark").setType(Type.newBuilder().setCode(TypeCode.TIMESTAMP).build()).build()).build()).build();
ResultSet watermarkResultSet = ResultSet.newBuilder().addRows(ListValue.newBuilder().addValues(Value.newBuilder().setStringValue(watermark.toString()).build()).build()).setMetadata(watermarkResultSetMetadata).build();
mockSpannerService.putStatementResult(StatementResult.query(watermarkStatement, watermarkResultSet));
}
Aggregations