@Test public void removeChannel() { final InMemoryDataStore store = new InMemoryDataStore(); store.saveChannel(new DefaultChannel(UUIDUtil.newUAID(), "channel-1", "endpoint/1")); assertThat(store.removeChannel("channel-1"), is(true)); assertThat(store.removeChannel("channel-1"), is(false)); }
@Test public void saveChannel() { final InMemoryDataStore store = new InMemoryDataStore(); final boolean saved = store.saveChannel(new DefaultChannel(UUIDUtil.newUAID(), "channel-1", "endpoint/1")); assertThat(saved, is(true)); }
@Test public void getChannel() throws ChannelNotFoundException { final InMemoryDataStore store = new InMemoryDataStore(); store.saveChannel(new DefaultChannel(UUIDUtil.newUAID(), "channel-1", "endpoint/1")); assertThat(store.getChannel("channel-1"), is(notNullValue())); assertThat(store.getChannel("channel-1").getChannelId(), equalTo("channel-1")); assertThat(store.getChannel("channel-1").getPushEndpoint(), equalTo("endpoint/1")); }
@Test public void storeUpdates() { final InMemoryDataStore store = new InMemoryDataStore(); final String uaid = UUIDUtil.newUAID(); final String channelId1 = UUID.randomUUID().toString(); store.saveUpdates(updates(update(channelId1, 10L)), uaid); final Set<Update> updates = store.getUpdates(uaid); assertThat(updates, hasItem(update(channelId1, 10L))); }
@Test public void removeUpdate() { final InMemoryDataStore store = new InMemoryDataStore(); final String uaid = UUIDUtil.newUAID(); final String channelId1 = UUID.randomUUID().toString(); store.saveUpdates(updates(update(channelId1, 10L)), uaid); assertThat(store.removeUpdate(update(channelId1, 10L), uaid), is(true)); assertThat(store.removeUpdate(update(channelId1, 10L), uaid), is(false)); assertThat(store.removeUpdate(update(channelId1, 11L), uaid), is(false)); }
@Test public void removeChannels() throws ChannelNotFoundException { final InMemoryDataStore store = new InMemoryDataStore(); final String uaid1 = UUIDUtil.newUAID(); final String uaid2 = UUIDUtil.newUAID(); store.saveChannel(new DefaultChannel(uaid1, "channel-1", "endpoint/1")); store.saveChannel(new DefaultChannel(uaid2, "channel-2", "endpoint/2")); store.saveChannel(new DefaultChannel(uaid1, "channel-3", "endpoint/3")); store.saveChannel(new DefaultChannel(uaid2, "channel-4", "endpoint/4")); store.removeChannels(uaid2); assertThat(hasChannel("channel-1", store), is(true)); assertThat(hasChannel("channel-2", store), is(false)); assertThat(hasChannel("channel-3", store), is(true)); assertThat(hasChannel("channel-4", store), is(false)); }