back to home view all articles

Ping? Pong! - Feature Request :)

Today evening we meet again and summarized the current status.

On the Python we still need to tune some things before releasing it to public. But I can tell you, there is already some nice communication going on.

On the Java we can show already some new things. Since we are using Reactor we also like to use it for our integration tests. The idea is to "replay" incomming WhatsApp Messages and then check the result. In a simple scenario we would like to test that when sending "ping", "pong" should be returned.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = VotesAppApplication.class)
@WebAppConfiguration
public class VotesAppApplicationTest {

  @Autowired
  Reactor reactor;

  @Test
  public void ping_pong_test() throws InterruptedException {
    reactor.notify("group.inbox", Event.wrap("Ping"));

    // If the integration works well, the business logic should answer with "Pong" to "group.outbox"

    // does not exist like this (yet :( )
    assertThat(reactor, receives("Pong").in("group.outbox"));
  }
}

When doing so we haven't found an elegant way to assertThat a GroupMessage-Event was raised. The cool thing is that the authors @smaldini and @jbrisbin liked the Idea and we will maybe see it in some time. Until then we are doing it with some obj.notify() and obj.wait() magic in our integration test

Another neat experience we had was the integration of an embedded mongodb for our integration tests.

The only change we need made was adding this dependency com.github.fakemongo:fongo:1.5.9 and putting the following configuration for our tests:

@Configuration
static class MongoDbTestConfiguration extends AbstractMongoConfiguration {

  @Override
  protected String getDatabaseName() {
    return "test";
  }

  @Override
  public Mongo mongo() {
    return new Fongo("mongo").getMongo();
  }

  @Override
  protected String getMappingBasePackage() {
    return "de.votesapp";
  }
}

Because we currently don't need a real database, we decided to put it into the main configuration as long as we haven't finished the database integration and deployed it to p.