@Test public void testGetMessageMetadataAsDictionaryQuery() throws Exception { Map<MessageId, BdfDictionary> map = new HashMap<>(); map.put(messageId, dictionary); BdfDictionary query = BdfDictionary.of(new BdfEntry("query", "me")); Metadata queryMetadata = new Metadata(); queryMetadata.put("query", getRandomBytes(42)); Transaction txn = new Transaction(null, true); context.checking(new Expectations() {{ oneOf(db).startTransaction(true); will(returnValue(txn)); oneOf(metadataEncoder).encode(query); will(returnValue(queryMetadata)); oneOf(db).getMessageMetadata(txn, groupId, queryMetadata); will(returnValue(Collections.singletonMap(messageId, metadata))); oneOf(metadataParser).parse(metadata); will(returnValue(dictionary)); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); assertEquals(map, clientHelper.getMessageMetadataAsDictionary(groupId, query)); context.assertIsSatisfied(); }
@Override public BdfDictionary getMessageMetadataAsDictionary(MessageId m) throws DbException, FormatException { BdfDictionary dictionary; Transaction txn = db.startTransaction(true); try { dictionary = getMessageMetadataAsDictionary(txn, m); db.commitTransaction(txn); } finally { db.endTransaction(txn); } return dictionary; }
ClientHelperImpl implements ClientHelper { @Override public BdfDictionary getMessageMetadataAsDictionary(MessageId m) throws DbException, FormatException { BdfDictionary dictionary; Transaction txn = db.startTransaction(true); try { dictionary = getMessageMetadataAsDictionary(txn, m); db.commitTransaction(txn); } finally { db.endTransaction(txn); } return dictionary; } }
ClientHelperImpl implements ClientHelper { @Override public BdfDictionary getMessageMetadataAsDictionary(MessageId m) throws DbException, FormatException { BdfDictionary dictionary; Transaction txn = db.startTransaction(true); try { dictionary = getMessageMetadataAsDictionary(txn, m); db.commitTransaction(txn); } finally { db.endTransaction(txn); } return dictionary; } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); }
ClientHelperImpl implements ClientHelper { @Override public BdfDictionary getMessageMetadataAsDictionary(MessageId m) throws DbException, FormatException { BdfDictionary dictionary; Transaction txn = db.startTransaction(true); try { dictionary = getMessageMetadataAsDictionary(txn, m); db.commitTransaction(txn); } finally { db.endTransaction(txn); } return dictionary; } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override void addLocalMessage(Message m, BdfDictionary metadata,
			boolean shared); @Override void addLocalMessage(Transaction txn, Message m,
			BdfDictionary metadata, boolean shared); @Override Message createMessage(GroupId g, long timestamp, BdfList body); @Override Message createMessageForStoringMetadata(GroupId g); @Override Message getMessage(MessageId m); @Override Message getMessage(Transaction txn, MessageId m); @Override BdfList getMessageAsList(MessageId m); @Override BdfList getMessageAsList(Transaction txn, MessageId m); @Override BdfDictionary getGroupMetadataAsDictionary(GroupId g); @Override BdfDictionary getGroupMetadataAsDictionary(Transaction txn,
			GroupId g); @Override BdfDictionary getMessageMetadataAsDictionary(MessageId m); @Override BdfDictionary getMessageMetadataAsDictionary(Transaction txn,
			MessageId m); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g, BdfDictionary query); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g, BdfDictionary query); @Override void mergeGroupMetadata(GroupId g, BdfDictionary metadata); @Override void mergeGroupMetadata(Transaction txn, GroupId g,
			BdfDictionary metadata); @Override void mergeMessageMetadata(MessageId m, BdfDictionary metadata); @Override void mergeMessageMetadata(Transaction txn, MessageId m,
			BdfDictionary metadata); @Override byte[] toByteArray(BdfDictionary dictionary); @Override byte[] toByteArray(BdfList list); @Override BdfDictionary toDictionary(byte[] b, int off, int len); @Override BdfDictionary toDictionary(TransportProperties transportProperties); @Override BdfDictionary toDictionary(
			Map<TransportId, TransportProperties> map); @Override BdfList toList(byte[] b, int off, int len); @Override BdfList toList(byte[] b); @Override BdfList toList(Message m); @Override BdfList toList(Author a); @Override byte[] sign(String label, BdfList toSign, byte[] privateKey); @Override void verifySignature(byte[] signature, String label, BdfList signed,
			byte[] publicKey); @Override Author parseAndValidateAuthor(BdfList author); @Override TransportProperties parseAndValidateTransportProperties(
			BdfDictionary properties); @Override Map<TransportId, TransportProperties> parseAndValidateTransportPropertiesMap(
			BdfDictionary properties); }
ClientHelperImpl implements ClientHelper { @Override public BdfDictionary getMessageMetadataAsDictionary(MessageId m) throws DbException, FormatException { BdfDictionary dictionary; Transaction txn = db.startTransaction(true); try { dictionary = getMessageMetadataAsDictionary(txn, m); db.commitTransaction(txn); } finally { db.endTransaction(txn); } return dictionary; } @Inject  ClientHelperImpl(DatabaseComponent db, MessageFactory messageFactory,
			BdfReaderFactory bdfReaderFactory,
			BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
			MetadataEncoder metadataEncoder, CryptoComponent crypto,
			AuthorFactory authorFactory); @Override void addLocalMessage(Message m, BdfDictionary metadata,
			boolean shared); @Override void addLocalMessage(Transaction txn, Message m,
			BdfDictionary metadata, boolean shared); @Override Message createMessage(GroupId g, long timestamp, BdfList body); @Override Message createMessageForStoringMetadata(GroupId g); @Override Message getMessage(MessageId m); @Override Message getMessage(Transaction txn, MessageId m); @Override BdfList getMessageAsList(MessageId m); @Override BdfList getMessageAsList(Transaction txn, MessageId m); @Override BdfDictionary getGroupMetadataAsDictionary(GroupId g); @Override BdfDictionary getGroupMetadataAsDictionary(Transaction txn,
			GroupId g); @Override BdfDictionary getMessageMetadataAsDictionary(MessageId m); @Override BdfDictionary getMessageMetadataAsDictionary(Transaction txn,
			MessageId m); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			GroupId g, BdfDictionary query); @Override Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
			Transaction txn, GroupId g, BdfDictionary query); @Override void mergeGroupMetadata(GroupId g, BdfDictionary metadata); @Override void mergeGroupMetadata(Transaction txn, GroupId g,
			BdfDictionary metadata); @Override void mergeMessageMetadata(MessageId m, BdfDictionary metadata); @Override void mergeMessageMetadata(Transaction txn, MessageId m,
			BdfDictionary metadata); @Override byte[] toByteArray(BdfDictionary dictionary); @Override byte[] toByteArray(BdfList list); @Override BdfDictionary toDictionary(byte[] b, int off, int len); @Override BdfDictionary toDictionary(TransportProperties transportProperties); @Override BdfDictionary toDictionary(
			Map<TransportId, TransportProperties> map); @Override BdfList toList(byte[] b, int off, int len); @Override BdfList toList(byte[] b); @Override BdfList toList(Message m); @Override BdfList toList(Author a); @Override byte[] sign(String label, BdfList toSign, byte[] privateKey); @Override void verifySignature(byte[] signature, String label, BdfList signed,
			byte[] publicKey); @Override Author parseAndValidateAuthor(BdfList author); @Override TransportProperties parseAndValidateTransportProperties(
			BdfDictionary properties); @Override Map<TransportId, TransportProperties> parseAndValidateTransportPropertiesMap(
			BdfDictionary properties);  }