ContextId { public Map<String, String> toMetaData() { Map<String, String> metaData = new HashMap<String, String>(); metaData.put(META_KEY_ID, id); return metaData; } ContextId(String id); String getId(); void setId(String id); Map<String, String> toMetaData(); static ContextId fromMetaData(Map<String, String> metaData); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static Map<String, String> getContextIdWildCard(); static final String META_KEY_ID; }
@Test public void testToMetaData_shouldStoreIdInMap() throws Exception { ContextId contextId = new ContextId("idFromContextId"); Map<String, String> metaData = contextId.toMetaData(); assertThat(metaData, hasEntry("id", "idFromContextId")); }