I'm currently playing about with the awaitility function within my tests. I'm trying to post a message to my pubnub console. However this currently isn't happening due to the unsubscribe teardown I've implemented. I'm struggling with the syntax for the awaitility. I've got a couple of lines in to show you what I've been doing. Could someone point me down the right path?
import com.pubnub.api.PubnubException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import service.PubnubService;
import static com.jayway.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
 * Created by peterki on 07/09/2016.
 */
public class PublisherTest {
    private PubnubService service = new PubnubService();
    //Arrange method for all of the tests
    @Before
    public void setupConnection() throws PubnubException {
        // Setup Subscriber
        service.subscribe("my_channel");
        // Do nothing until the subscriber has connected.
        do{} while (!service.isConnected());
    }
    @After
    public void TeardownConnection() throws PubnubException {
        // Unsubscribe from channel after each test has completed. So that the next test isn't waiting so subscribe.
        service.unsubscribe("my_channel");
    }
    @Test
    public void testSportMessageType() throws PubnubException {
        // Publish to External Service
        service.publish("my_channel", "Hello Peter");
        //Wait till we receive the message
        await().until(); -> service.publish("my_channel"); == 1;
        await().until(() -> service.publish("my_channel", "Hello Peter")() == 1);
        // Assert the message is what we want
    }
}