### Question:
CustomEntityDecorator implements EntityDecorator { @Override public void decorate(EntityBody entity, EntityDefinition definition, MultivaluedMap<String, String> queryParams) { List<String> params = queryParams.get(ParameterConstants.INCLUDE_CUSTOM); final Boolean includeCustomEntity = Boolean.valueOf((params != null) ? params.get(0) : "false"); if (includeCustomEntity) { String entityId = (String) entity.get("id"); EntityBody custom = definition.getService().getCustom(entityId); if (custom != null) { entity.put(ResourceConstants.CUSTOM, custom); } } }  @Override void decorate(EntityBody entity, EntityDefinition definition, MultivaluedMap<String, String> queryParams);  }### Answer:
@Test public void testDecoratorNonParam() { MultivaluedMap<String, String> map = new MultivaluedMapImpl(); map.add(ParameterConstants.INCLUDE_CUSTOM, String.valueOf(false)); EntityBody body = createTestEntity(); customEntityDecorator.decorate(body, null, map); assertEquals("Should match", 3, body.keySet().size()); assertEquals("Should match", "Male", body.get("sex")); assertEquals("Should match", 1234, body.get("studentUniqueStateId")); }
@Test public void testDecoratorWithParam() { MultivaluedMap<String, String> map = new MultivaluedMapImpl(); map.add(ParameterConstants.INCLUDE_CUSTOM, String.valueOf(true)); EntityBody custom = createCustomEntity(); EntityService service = mock(EntityService.class); when(service.getCustom("1234")).thenReturn(custom); EntityDefinition definition = mock(EntityDefinition.class); when(definition.getService()).thenReturn(service); EntityBody body = createTestEntity(); customEntityDecorator.decorate(body, definition, map); assertEquals("Should match", 4, body.keySet().size()); assertEquals("Should match", "Male", body.get("sex")); assertEquals("Should match", 1234, body.get("studentUniqueStateId")); EntityBody customBody = (EntityBody) body.get(ResourceConstants.CUSTOM); assertNotNull("Should not be null", customBody); assertEquals("Should match", "1", customBody.get("customValue")); }