### Question:
MessageMetadataParser { static Map<String,Object> parseTransactionMetadata( MapValue meta ) throws BoltIOException { AnyValue anyValue = meta.get( TX_META_DATA_KEY ); if ( anyValue == Values.NO_VALUE ) { return null; } else if ( anyValue instanceof MapValue ) { MapValue mapValue = (MapValue) anyValue; TransactionMetadataWriter writer = new TransactionMetadataWriter(); Map<String,Object> txMeta = new HashMap<>( mapValue.size() ); mapValue.foreach( ( key, value ) -> txMeta.put( key, writer.valueAsObject( value ) ) ); return txMeta; } else { throw new BoltIOException( Status.Request.Invalid, "Expecting transaction metadata value to be a Map value, but got: " + anyValue ); } } private  MessageMetadataParser();   }### Answer:
@Test void shouldAllowNoTransactionMetadata() throws Exception { assertNull( parseTransactionMetadata( emptyMap() ) ); }
@Test void shouldThrowForIncorrectTransactionMetadata() { BoltIOException e = assertThrows( BoltIOException.class, () -> parseTransactionMetadata( asMapValue( map( "tx_metadata", "{key1: 'value1', key2: 'value2'}" ) ) ) ); assertTrue( e.causesFailureMessage() ); }