@Test
  public void insertMixOfWronglyFormedAndCorrectlyFormedEvents() {
    try {
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList =
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.properandImproperEvent, streamDefinition1.getStreamId());
    List<String> insertedEvents = new ArrayList<String>();
    int eventCounter = 0;
    for (Event event : eventList) {
      try {
        String rowKey = insertEvent(cluster, event, eventCounter++);
        // inserts row key only if event is valid, i.e. only proper events will add a row key
        insertedEvents.add(rowKey);
      } catch (Exception e) {
        // ignore
      }
    }
    assertEquals(2, insertedEvents.size());
  }
  @Test
  public void checkHappyPathStreamStoreOperations() {

    try {
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    StreamDefinition streamDefinitionFromStore = null;
    try {
      Credentials credentials = getCredentials(cluster);
      streamDefinitionFromStore =
          cassandraConnector.getStreamDefinitionFromCassandra(
              getCluster(), streamDefinition1.getStreamId());
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
    assertEquals(streamDefinition1, streamDefinitionFromStore);
    List<Event> eventList =
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.properEvent, streamDefinition1.getStreamId());
    try {
      int eventCounter = 0;
      for (Event event : eventList) {
        insertEvent(cluster, event, eventCounter++);
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
  }
  @Test
  public void checkEqualityofEventIdAndStreamDefnId() {

    try {
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList =
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.properEvent, streamDefinition1.getStreamId());

    for (Event event : eventList) {
      assertEquals(event.getStreamId(), streamDefinition1.getStreamId());
    }
  }
  @Test
  public void insertEventsFromMultipleStreams() {
    try {
      // save stream defn 1
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition1);

      // save stream defn 3
      cassandraConnector.saveStreamDefinitionToStore(getCluster(), streamDefinition3);
    } catch (StreamDefinitionStoreException e) {
      e.printStackTrace();
      fail();
    }

    List<Event> eventList = new ArrayList<Event>();
    // retrieve stream id 1
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent1, streamDefinition1.getStreamId()));

    // retrieve stream id 3
    eventList.addAll(
        EventConverterUtils.convertFromJson(
            CassandraTestConstants.multipleProperEvent3, streamDefinition3.getStreamId()));

    Map<String, Event> insertedEvents = new HashMap<String, Event>();
    int eventCounter = 0;
    for (Event event : eventList) {
      try {
        String rowKey = insertEvent(cluster, event, eventCounter++);
        // inserts row key only if event is valid, i.e. only proper events will add a row key
        insertedEvents.put(rowKey, event);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    assertEquals(4, insertedEvents.size());

    Map<String, Event> retrievedEvents = new HashMap<String, Event>();

    for (Map.Entry<String, Event> eventProps : insertedEvents.entrySet()) {
      try {
        retrievedEvents.put(
            eventProps.getKey(),
            getEvent(cluster, eventProps.getValue().getStreamId(), eventProps.getKey()));
      } catch (EventProcessingException e) {
        e.printStackTrace();
        fail();
      }
    }

    for (Map.Entry<String, Event> rowKeyAndEvent : retrievedEvents.entrySet()) {
      Event retrievedEvent = rowKeyAndEvent.getValue();
      Event originialEvent = insertedEvents.get(rowKeyAndEvent.getKey());
      System.out.println(
          "Retrieved Event : " + retrievedEvent + "\n Original Event : " + originialEvent + "\n\n");
      if (streamDefinition1.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition1));
      } else if (streamDefinition2.getStreamId().equals(originialEvent.getStreamId())) {
        assertTrue(DataBridgeUtils.equals(originialEvent, retrievedEvent, streamDefinition3));
      }
    }
  }