@Test(timeout = TIMEOUT_MS)
public void testUpdateTarget() throws Exception {

    Session session = cassandraCQLUnit.getSession();
    BoundStatement countStmt = session.prepare("SELECT COUNT(*) FROM load_balancer_targets;").bind();
    PreparedStatement stateStmt = session.prepare("SELECT state FROM load_balancer_targets WHERE load_balancer_id = ? AND ip_address = ?;");
    assertThat(session.execute(countStmt).one().getLong(0)).isEqualTo(0);
    LoadBalancerTarget target = new LoadBalancerTarget("lb-1", "task-1", "1.1.1.1");
    CassandraLoadBalancerStore store = getInitdStore();
    store.addOrUpdateTargets(target.withState(LoadBalancerTarget.State.REGISTERED)).block();
    assertThat(session.execute(countStmt).one().getLong(0)).isEqualTo(1);
    Row registered = session.execute(stateStmt.bind("lb-1", "1.1.1.1")).one();
    assertThat(registered.getString("state")).isEqualTo("REGISTERED");
    store.addOrUpdateTargets(target.withState(LoadBalancerTarget.State.DEREGISTERED)).block();
    assertThat(session.execute(countStmt).one().getLong(0)).isEqualTo(1);
    Row deregistered = session.execute(stateStmt.bind("lb-1", "1.1.1.1")).one();
    assertThat(deregistered.getString("state")).isEqualTo("DEREGISTERED");
}