@Test(
     groups = "wso2.das",
     description = "Range operations",
     dependsOnMethods = "paginationSearch")
 public void range() throws Exception {
   RecordBean[] byRange =
       webServiceClient.getByRange(
           TABLE1.replace('.', '_'), new String[] {"uuid"}, 0, System.currentTimeMillis(), 0, 200);
   Assert.assertNotNull(byRange, "Returns null array");
   Assert.assertEquals(byRange.length, 100, "Not contains 100 records");
   List<String> recordIds = new ArrayList<>(100);
   for (RecordBean recordBean : byRange) {
     recordIds.add(recordBean.getId());
   }
   RecordBean[] byId =
       webServiceClient.getById(
           TABLE1.replace('.', '_'), new String[] {"uuid"}, recordIds.toArray(new String[100]));
   Assert.assertNotNull(byId, "Returns null array");
   Assert.assertEquals(byId.length, 100, "Not contains 100 records");
   webServiceClient.deleteByIds(TABLE1.replace('.', '_'), recordIds.toArray(new String[100]));
   Thread.sleep(40000);
   byRange =
       webServiceClient.getByRange(
           TABLE1.replace('.', '_'), new String[] {"uuid"}, 0, System.currentTimeMillis(), 0, 200);
   Assert.assertNull(byRange, "Returns not null array");
 }
 @Test(groups = "wso2.das", description = "Range operations", dependsOnMethods = "range")
 public void search() throws Exception {
   List<Event> events = new ArrayList<>(100);
   for (int i = 0; i < 100; i++) {
     Event event =
         new Event(
             null,
             System.currentTimeMillis(),
             new Object[0],
             new Object[0],
             new Object[] {(long) i, String.valueOf(i)});
     events.add(event);
   }
   publishEvents(events);
   webServiceClient.waitForIndexing(5000);
   Thread.sleep(5000);
   RecordBean[] search = webServiceClient.search(TABLE1.replace('.', '_'), "uuid:1", 0, 10);
   Assert.assertNotNull(search, "Returning null array");
   Assert.assertEquals(search.length, 1, "Result doesn't contain one record");
   Assert.assertEquals(
       webServiceClient.searchCount(TABLE1.replace('.', '_'), "uuid:1"),
       1,
       "Search count is " + "wrong");
   webServiceClient.clearIndices(TABLE1.replace('.', '_'));
   Thread.sleep(5000);
   Assert.assertEquals(
       webServiceClient.searchCount(TABLE1.replace('.', '_'), "uuid:1"),
       0,
       "Clear indexing not " + "happening");
 }
 @Test(groups = "wso2.das", description = "Check table exist", dependsOnMethods = "getTableSchema")
 public void tableExists() throws Exception {
   Assert.assertTrue(
       webServiceClient.tableExists(TABLE1.replace('.', '_')), "Returns false for existing table");
   Assert.assertFalse(
       webServiceClient.tableExists("nonExistTable"), "Returns true for non existing table");
 }
 @Test(groups = "wso2.das", description = "Adding valid stream definition")
 public void addStreamDefinition() throws Exception {
   init();
   StreamDefinitionBean streamDefinitionBean = getEventStreamBeanTable1Version1();
   webServiceClient.addStreamDefinition(streamDefinitionBean);
   Thread.sleep(5000);
   StreamDefinitionBean streamDefinition =
       webServiceClient.getStreamDefinition(TABLE1, STREAM_VERSION_1);
   Assert.assertEquals(streamDefinition.getName(), TABLE1, "Stream name mismatch");
   Assert.assertNotNull(streamDefinition.getPayloadData(), "Empty payload array");
   Assert.assertEquals(streamDefinition.getPayloadData().length, 2, "Invalid payload data count");
 }
 @Test(groups = "wso2.das", description = "Pagination search", dependsOnMethods = "getRecordCount")
 public void paginationSearch() throws Exception {
   if (webServiceClient.isPaginationSupported(TABLE1.replace('.', '_'))) {
     Set<String> ids = new HashSet<>(100);
     long time = System.currentTimeMillis();
     for (int i = 0; i < 4; i++) {
       RecordBean[] byRange =
           webServiceClient.getByRange(
               TABLE1.replace('.', '_'), new String[] {"uuid"}, 0, time, i * 25, 25);
       Assert.assertEquals(byRange.length, 25, "Pagination result count is wrong");
       for (RecordBean recordBean : byRange) {
         ids.add(recordBean.getId());
       }
     }
     Assert.assertEquals(ids.size(), 100, "Doesn't contain all the records doing the pagination");
   }
 }
 @Test(
     groups = "wso2.das",
     description = "Check stream exception situation",
     dependsOnMethods = "addStreamDefinition",
     expectedExceptions = AxisFault.class)
 public void addSameStreamDefWithDifferentAttribute() throws Exception {
   StreamDefinitionBean streamDefinitionBean =
       getEventStreamBeanTable1Version1DifferentAttribute();
   webServiceClient.addStreamDefinition(streamDefinitionBean);
 }
 @Test(groups = "wso2.das", description = "Get table list", dependsOnMethods = "getTableSchema")
 public void listTables() throws Exception {
   AnalyticsTable table2Version1 = getAnalyticsTable2Version1();
   persistenceClient.addAnalyticsTable(table2Version1);
   Thread.sleep(15000);
   String[] tables = webServiceClient.listTables();
   Assert.assertNotNull(tables, "Return null array");
   Assert.assertTrue(
       Arrays.asList(tables).contains(TABLE1.replace('.', '_').toUpperCase()),
       "Table1 name does not return");
   Assert.assertTrue(
       Arrays.asList(tables).contains(TABLE2.replace('.', '_').toUpperCase()),
       "Table2 name does not return");
 }
 @Test(
     groups = "wso2.das",
     description = "Check get table schema",
     dependsOnMethods = "addStreamDefinition")
 public void getTableSchema() throws Exception {
   AnalyticsTable table1Version1 = getAnalyticsTable1Version1();
   persistenceClient.addAnalyticsTable(table1Version1);
   Thread.sleep(15000);
   AnalyticsSchemaBean tableSchema = webServiceClient.getTableSchema(TABLE1.replace('.', '_'));
   Assert.assertNotNull(table1Version1, "Getting null table schema object");
   Assert.assertEquals(tableSchema.getColumns().length, 3, "Getting invalid column count");
   Assert.assertEquals(
       tableSchema.getPrimaryKeys().length, 1, "Getting invalid primary key count");
 }
 @Test(
     groups = "wso2.das",
     description = "Publish event",
     dependsOnMethods = "addStreamDefinition")
 public void publishEvent() throws Exception {
   StreamDefinitionBean streamDefTable2Version1 = getEventStreamBeanTable2Version1();
   webServiceClient.addStreamDefinition(streamDefTable2Version1);
   EventBean eventBean = new EventBean();
   eventBean.setStreamName(TABLE2);
   eventBean.setStreamVersion(STREAM_VERSION_1);
   RecordValueEntryBean[] payloadData = new RecordValueEntryBean[2];
   RecordValueEntryBean uuid = new RecordValueEntryBean();
   uuid.setFieldName("uuid");
   uuid.setType("LONG");
   uuid.setLongValue(123);
   payloadData[0] = uuid;
   RecordValueEntryBean name = new RecordValueEntryBean();
   name.setFieldName("name");
   name.setType("STRING");
   name.setStringValue("DAS");
   payloadData[1] = name;
   eventBean.setPayloadData(payloadData);
   webServiceClient.publishEvent(eventBean);
 }
 @Test(groups = "wso2.das", description = "Get record count", dependsOnMethods = "listTables")
 public void getRecordCount() throws Exception {
   deployEventReceivers();
   Thread.sleep(15000);
   List<Event> events = new ArrayList<>(100);
   for (int i = 0; i < 100; i++) {
     Event event =
         new Event(
             null,
             System.currentTimeMillis(),
             new Object[0],
             new Object[0],
             new Object[] {(long) i, String.valueOf(i)});
     events.add(event);
   }
   publishEvents(events);
   Thread.sleep(2000);
   Assert.assertEquals(
       webServiceClient.getRecordCount(TABLE1.replace('.', '_'), 0, System.currentTimeMillis()),
       100,
       "Record count is invalid");
 }