@Test public void getChannelsForNonExistingUserAgent() throws ChannelNotFoundException { final Set<String> channels = jpaDataStore.getChannelIds(UUIDUtil.newUAID()); assertThat(channels.isEmpty(), is(true)); }
@Override public Set<String> getChannelIds(final String uaid) { final JpaOperation<Set<String>> getChannelIds = new JpaOperation<Set<String>>() { @Override public Set<String> perform(final EntityManager em) { final Set<String> channels = new HashSet<String>(); final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent != null) { for (ChannelDTO dto : userAgent.getChannels()) { channels.add(dto.getChannelId()); } } return channels; } }; return jpaExecutor.execute(getChannelIds); }
JpaDataStore implements DataStore { @Override public Set<String> getChannelIds(final String uaid) { final JpaOperation<Set<String>> getChannelIds = new JpaOperation<Set<String>>() { @Override public Set<String> perform(final EntityManager em) { final Set<String> channels = new HashSet<String>(); final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent != null) { for (ChannelDTO dto : userAgent.getChannels()) { channels.add(dto.getChannelId()); } } return channels; } }; return jpaExecutor.execute(getChannelIds); } }
JpaDataStore implements DataStore { @Override public Set<String> getChannelIds(final String uaid) { final JpaOperation<Set<String>> getChannelIds = new JpaOperation<Set<String>>() { @Override public Set<String> perform(final EntityManager em) { final Set<String> channels = new HashSet<String>(); final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent != null) { for (ChannelDTO dto : userAgent.getChannels()) { channels.add(dto.getChannelId()); } } return channels; } }; return jpaExecutor.execute(getChannelIds); } JpaDataStore(final String persistenceUnit); }
JpaDataStore implements DataStore { @Override public Set<String> getChannelIds(final String uaid) { final JpaOperation<Set<String>> getChannelIds = new JpaOperation<Set<String>>() { @Override public Set<String> perform(final EntityManager em) { final Set<String> channels = new HashSet<String>(); final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent != null) { for (ChannelDTO dto : userAgent.getChannels()) { channels.add(dto.getChannelId()); } } return channels; } }; return jpaExecutor.execute(getChannelIds); } JpaDataStore(final String persistenceUnit); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override Channel getChannel(final String channelId); @Override void removeChannels(final Set<String> channelIds); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long version); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acked); }
JpaDataStore implements DataStore { @Override public Set<String> getChannelIds(final String uaid) { final JpaOperation<Set<String>> getChannelIds = new JpaOperation<Set<String>>() { @Override public Set<String> perform(final EntityManager em) { final Set<String> channels = new HashSet<String>(); final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent != null) { for (ChannelDTO dto : userAgent.getChannels()) { channels.add(dto.getChannelId()); } } return channels; } }; return jpaExecutor.execute(getChannelIds); } JpaDataStore(final String persistenceUnit); @Override void savePrivateKeySalt(final byte[] salt); @Override byte[] getPrivateKeySalt(); @Override boolean saveChannel(final Channel channel); @Override Channel getChannel(final String channelId); @Override void removeChannels(final Set<String> channelIds); @Override Set<String> getChannelIds(final String uaid); @Override void removeChannels(final String uaid); @Override String updateVersion(final String endpointToken, final long version); @Override String saveUnacknowledged(final String channelId, final long version); @Override Set<Ack> getUnacknowledged(final String uaid); @Override Set<Ack> removeAcknowledged(final String uaid, final Set<Ack> acked);  }