@Test public void getUnacknowledgedNoChannelsSavedYet() { final String uaid = UUIDUtil.newUAID(); final Set<Ack> storedUpdates = jpaDataStore.getUnacknowledged(uaid); assertThat(storedUpdates.size(), is(0)); }
@Override public Set<Ack> getUnacknowledged(final String uaid) { final JpaOperation<Set<Ack>> getUnacks = new JpaOperation<Set<Ack>>() { @Override public Set<Ack> perform(final EntityManager em) { final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent == null) { return Collections.emptySet(); } final HashSet<Ack> acks = new HashSet<Ack>(); for (AckDTO ackDTO : userAgent.getAcks()) { acks.add(new AckImpl(ackDTO.getChannelId(), ackDTO.getVersion())); } return acks; } }; return jpaExecutor.execute(getUnacks); }
JpaDataStore implements DataStore { @Override public Set<Ack> getUnacknowledged(final String uaid) { final JpaOperation<Set<Ack>> getUnacks = new JpaOperation<Set<Ack>>() { @Override public Set<Ack> perform(final EntityManager em) { final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent == null) { return Collections.emptySet(); } final HashSet<Ack> acks = new HashSet<Ack>(); for (AckDTO ackDTO : userAgent.getAcks()) { acks.add(new AckImpl(ackDTO.getChannelId(), ackDTO.getVersion())); } return acks; } }; return jpaExecutor.execute(getUnacks); } }
JpaDataStore implements DataStore { @Override public Set<Ack> getUnacknowledged(final String uaid) { final JpaOperation<Set<Ack>> getUnacks = new JpaOperation<Set<Ack>>() { @Override public Set<Ack> perform(final EntityManager em) { final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent == null) { return Collections.emptySet(); } final HashSet<Ack> acks = new HashSet<Ack>(); for (AckDTO ackDTO : userAgent.getAcks()) { acks.add(new AckImpl(ackDTO.getChannelId(), ackDTO.getVersion())); } return acks; } }; return jpaExecutor.execute(getUnacks); } JpaDataStore(final String persistenceUnit); }
JpaDataStore implements DataStore { @Override public Set<Ack> getUnacknowledged(final String uaid) { final JpaOperation<Set<Ack>> getUnacks = new JpaOperation<Set<Ack>>() { @Override public Set<Ack> perform(final EntityManager em) { final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent == null) { return Collections.emptySet(); } final HashSet<Ack> acks = new HashSet<Ack>(); for (AckDTO ackDTO : userAgent.getAcks()) { acks.add(new AckImpl(ackDTO.getChannelId(), ackDTO.getVersion())); } return acks; } }; return jpaExecutor.execute(getUnacks); } 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<Ack> getUnacknowledged(final String uaid) { final JpaOperation<Set<Ack>> getUnacks = new JpaOperation<Set<Ack>>() { @Override public Set<Ack> perform(final EntityManager em) { final UserAgentDTO userAgent = em.find(UserAgentDTO.class, uaid); if (userAgent == null) { return Collections.emptySet(); } final HashSet<Ack> acks = new HashSet<Ack>(); for (AckDTO ackDTO : userAgent.getAcks()) { acks.add(new AckImpl(ackDTO.getChannelId(), ackDTO.getVersion())); } return acks; } }; return jpaExecutor.execute(getUnacks); } 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);  }