### Question:
ConfigSerializer implements ComprehendSerializer<PreprocessingConfigRequest> { public static Map<String, ComprehendConfiguration> transformConfigRequestToConfigMap( @NonNull PreprocessingConfigRequest configRequest) { List<ComprehendConfiguration> configList = configRequest.getComprehendConfigurations(); try { Map<String, ComprehendConfiguration> configMap = configList.stream() .filter(config -> !config.configIsInvalid()) .collect(Collectors.toMap( value -> String.format("%s_%s", value.getIndexName(), value.getFieldName()), value -> value)); if (configMap.size() != configList.size()) { throw new InvalidRequestException(CustomerMessage.CONFIG_FIELD_MISSING_OR_EMPTY_ERROR); } return configMap; } catch (IllegalStateException e) { throw new InvalidRequestException(CustomerMessage.CONFIG_FIELD_NAME_DUPLICATED_ERROR); } }  PreprocessingConfigRequest deserialize(@NonNull final String input); String serialize(@NonNull PreprocessingConfigRequest configRequest); static Map<String, ComprehendConfiguration> transformConfigRequestToConfigMap(
            @NonNull PreprocessingConfigRequest configRequest); static PreprocessingConfigRequest transformConfigMapToConfigRequest(
            @NonNull Map<String, ComprehendConfiguration> configMap);  }### Answer:
@Test public void SucceedTransformConfigRequestToConfigMap() { configMap = ConfigSerializer.transformConfigRequestToConfigMap(TestConstants.getConfigRequest()); assertEquals(1, configMap.size()); ComprehendConfiguration object = configMap.get( String.format("%s_%s", TestConstants.INDEX_NAME, TestConstants.FIELD_NAME)); Assert.assertEquals(TestConstants.FIELD_NAME, object.getFieldName()); Assert.assertEquals(TestConstants.COMPREHEND_OPERATIONS, object.getComprehendOperations()); Assert.assertEquals(TestConstants.LANGUAGE_CODE, object.getLanguageCode()); }
@Test public void FailedToTransformConfigRequestToConfigMapEmptyFields() { try { configMap = ConfigSerializer.transformConfigRequestToConfigMap(TestConstants.getEmptyFieldConfigRequest()); } catch (InvalidRequestException e) { assertEquals(CustomerMessage.CONFIG_FIELD_MISSING_OR_EMPTY_ERROR, e.getMessage()); } }
@Test public void FailedToTransformConfigRequestToConfigMapDuplicateName() { try { configMap = ConfigSerializer.transformConfigRequestToConfigMap(TestConstants.getDuplicateConfigRequest()); } catch (InvalidRequestException e) { assertEquals(CustomerMessage.CONFIG_FIELD_NAME_DUPLICATED_ERROR, e.getMessage()); } }