bmeriaux commented on a change in pull request #6735: [FLINK-9126] New 
CassandraPojoInputFormat to output data as a custom annotated Cassandra Pojo
URL: https://github.com/apache/flink/pull/6735#discussion_r221747948
 
 

 ##########
 File path: 
flink-connectors/flink-connector-cassandra/src/test/java/org/apache/flink/streaming/connectors/cassandra/CassandraConnectorITCase.java
 ##########
 @@ -470,6 +477,41 @@ public void testCassandraTableSink() throws Exception {
                Assert.assertTrue("The input data was not completely written to 
Cassandra", input.isEmpty());
        }
 
+       @Test
+       public void testCassandraBatchPojoFormat() throws Exception {
+
+               session.execute(CREATE_TABLE_QUERY.replace(TABLE_NAME_VARIABLE, 
"batches"));
+
+               CassandraPojoSink<CustomCassandraAnnotatedPojo> sink = new 
CassandraPojoSink<>(CustomCassandraAnnotatedPojo.class, builder);
+               sink.open(new Configuration());
+
+               List<CustomCassandraAnnotatedPojo> 
customCassandraAnnotatedPojos = IntStream.range(0, 20)
+                       .mapToObj(x -> new 
CustomCassandraAnnotatedPojo(UUID.randomUUID().toString(), x, 0))
+                       .collect(Collectors.toList());
+
+               customCassandraAnnotatedPojos.forEach(sink::send);
+               sink.close();
+
+               InputFormat<CustomCassandraAnnotatedPojo, InputSplit> source = 
new CassandraPojoInputFormat<>(SELECT_DATA_QUERY.replace(TABLE_NAME_VARIABLE, 
"batches"), builder, CustomCassandraAnnotatedPojo.class);
+               source.configure(new Configuration());
+               source.open(null);
+
+               List<CustomCassandraAnnotatedPojo> result = new ArrayList<>();
+               while (!source.reachedEnd()) {
+                       CustomCassandraAnnotatedPojo temp = 
source.nextRecord(null);
+                       result.add(temp);
+               }
+
+               source.close();
+               Assert.assertEquals(20, result.size());
+               
result.sort(Comparator.comparingInt(CustomCassandraAnnotatedPojo::getCounter));
+               
customCassandraAnnotatedPojos.sort(Comparator.comparingInt(CustomCassandraAnnotatedPojo::getCounter));
+
+               for (int i = 0; i < result.size(); i++) {
+                       assertThat(result.get(i), 
samePropertyValuesAs(customCassandraAnnotatedPojos.get(i)));
 
 Review comment:
   it's a reflex for me to explicitly sort collection before assertions, i 
think it is more explicit/easier to understand, but i can remove it if it is 
not in standard :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to