### Question:
MapBasedHateoasLinkInjector implements HateoasLinkInjector<Object> { @Override public Map injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity) { try { Map<String, Object> entityMap = (Map<String, Object>) entity; Collection links; if (!entityMap.containsKey(linksFieldName)) { entityMap.put(linksFieldName, Lists.newLinkedList()); } links = (Collection) entityMap.get(linksFieldName); Collection<Map<String, Object>> linksToAdd = Collections2.transform(linkProducer.getLinks(entity), new Function<HateoasLink, Map<String, Object>>() { @Override public Map<String, Object> apply(HateoasLink from) { return from.toMap(verbosity); } }); links.addAll(linksToAdd); return entityMap; } catch (Exception e) { throw new HateoasInjectException(e); } } MapBasedHateoasLinkInjector(String linksFieldName);  MapBasedHateoasLinkInjector(); @Override boolean canInject(Object entity); @Override Map injectLinks(Object entity, LinkProducer<Object> linkProducer, final HateoasVerbosity verbosity);  }### Answer:
@SuppressWarnings("unchecked") @Test public void linksFieldIsInjectedAutomaticallyInMaps() { Map<String, Object> dummyEntity = new HashMap<String, Object>(); dummyEntity.put("id", "someId"); Map<String, Object> returnedEntity = (Map<String, Object>) tested.injectLinks( dummyEntity, linkProducer, HateoasVerbosity.MINIMUM); assertSame(dummyEntity, returnedEntity); assertEquals("someId", dummyEntity.get("id")); Collection<Map<String, Object>> links = (Collection<Map<String, Object>>) dummyEntity.get("links"); assertSame(EXPECTED_MAP, Iterables.getOnlyElement(links)); }