Example usage for java.util LinkedHashMap put

List of usage examples for java.util LinkedHashMap put

Introduction

In this page you can find the example usage for java.util LinkedHashMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:com.msopentech.odatajclient.engine.it.EntityCreateTestITCase.java

private void multiKey(final ODataPubFormat format) {
    final ODataEntity message = client.getObjectFactory()
            .newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Message");

    message.addProperty(client.getObjectFactory().newPrimitiveProperty("MessageId",
            client.getPrimitiveValueBuilder().setValue(1000).setType(EdmSimpleType.Int32).build()));
    message.addProperty(client.getObjectFactory().newPrimitiveProperty("FromUsername",
            client.getPrimitiveValueBuilder().setValue("1").setType(EdmSimpleType.String).build()));
    message.addProperty(//from  www.  j a va2 s.c om
            client.getObjectFactory().newPrimitiveProperty("ToUsername", client.getPrimitiveValueBuilder()
                    .setValue("xlodhxzzusxecbzptxlfxprneoxkn").setType(EdmSimpleType.String).build()));
    message.addProperty(client.getObjectFactory().newPrimitiveProperty("Subject",
            client.getPrimitiveValueBuilder().setValue("Test subject").setType(EdmSimpleType.String).build()));
    message.addProperty(client.getObjectFactory().newPrimitiveProperty("Body",
            client.getPrimitiveValueBuilder().setValue("Test body").setType(EdmSimpleType.String).build()));
    message.addProperty(client.getObjectFactory().newPrimitiveProperty("IsRead",
            client.getPrimitiveValueBuilder().setValue(false).setType(EdmSimpleType.Boolean).build()));

    final URIBuilder builder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message");
    final ODataEntityCreateRequest req = client.getCUDRequestFactory().getEntityCreateRequest(builder.build(),
            message);
    req.setFormat(format);

    final ODataEntityCreateResponse res = req.execute();
    assertNotNull(res);
    assertEquals(201, res.getStatusCode());

    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
    multiKey.put("FromUsername", "1");
    multiKey.put("MessageId", 1000);

    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory()
            .getDeleteRequest(builder.appendKeySegment(multiKey).build()).execute();
    assertEquals(204, deleteRes.getStatusCode());
}

From source file:com.workday.autoparse.json.demo.InstanceUpdaterTest.java

@Test
public void testMaps() {
    TestObject testObject = new TestObject();
    testObject.myInterfaceMap = new java.util.LinkedHashMap<>();
    testObject.myInterfaceMap.put("value", new TestObject.InnerTestObject("inside"));

    Map<String, Object> updates = new HashMap<>();

    LinkedHashMap<String, TestObject.InnerTestObject> newInterfaceMap = new LinkedHashMap<>();
    newInterfaceMap.put("value", new TestObject.InnerTestObject("out"));
    updates.put("myInterfaceMap", newInterfaceMap);

    TestObject$$JsonObjectParser.INSTANCE.updateInstanceFromMap(testObject, updates, CONTEXT);

    assertEquals("myInterfaceMap", newInterfaceMap, testObject.myInterfaceMap);
}

From source file:org.apache.olingo.fit.v3.EntityCreateTestITCase.java

private void multiKey(final ODataFormat format) {
    final ODataEntity message = client.getObjectFactory()
            .newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService.Message"));

    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("MessageId",
            client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1000)));
    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("FromUsername",
            client.getObjectFactory().newPrimitiveValueBuilder().buildString("1")));
    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("ToUsername",
            client.getObjectFactory().newPrimitiveValueBuilder().buildString("xlodhxzzusxecbzptxlfxprneoxkn")));
    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("Subject",
            client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test subject")));
    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("Body",
            client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test body")));
    getClient().getBinder().add(message, client.getObjectFactory().newPrimitiveProperty("IsRead",
            client.getObjectFactory().newPrimitiveValueBuilder().buildBoolean(false)));

    final URIBuilder builder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Message");
    final ODataEntityCreateRequest<ODataEntity> req = client.getCUDRequestFactory()
            .getEntityCreateRequest(builder.build(), message);
    req.setFormat(format);// ww w .  j av a  2 s. c  o  m

    final ODataEntityCreateResponse<ODataEntity> res = req.execute();
    assertNotNull(res);
    assertEquals(201, res.getStatusCode());

    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
    multiKey.put("FromUsername", "1");
    multiKey.put("MessageId", 1000);

    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory()
            .getDeleteRequest(builder.appendKeySegment(multiKey).build()).execute();
    assertEquals(204, deleteRes.getStatusCode());
}

From source file:com.datatorrent.stram.engine.OperatorThread.java

private void setupNode(OperatorDeployInfo ndi) {
    //failedNodes.remove(ndi.id);
    //final Node<?> node = nodes.get(ndi.id);

    node.setup(node.context);//  ww  w  .j  av a  2s. c  om

    /* setup context for all the input ports */
    LinkedHashMap<String, PortContextPair<InputPort<?>>> inputPorts = node
            .getPortMappingDescriptor().inputPorts;
    LinkedHashMap<String, Operators.PortContextPair<InputPort<?>>> newInputPorts = new LinkedHashMap<>(
            inputPorts.size());
    for (OperatorDeployInfo.InputDeployInfo idi : ndi.inputs) {
        InputPort<?> port = inputPorts.get(idi.portName).component;
        PortContext context = new PortContext(idi.contextAttributes, node.context);
        newInputPorts.put(idi.portName, new PortContextPair<>(port, context));
        port.setup(context);
    }
    inputPorts.putAll(newInputPorts);

    /* setup context for all the output ports */
    LinkedHashMap<String, PortContextPair<OutputPort<?>>> outputPorts = node
            .getPortMappingDescriptor().outputPorts;
    LinkedHashMap<String, PortContextPair<OutputPort<?>>> newOutputPorts = new LinkedHashMap<>(
            outputPorts.size());
    for (OperatorDeployInfo.OutputDeployInfo odi : ndi.outputs) {
        OutputPort<?> port = outputPorts.get(odi.portName).component;
        PortContext context = new PortContext(odi.contextAttributes, node.context);
        newOutputPorts.put(odi.portName, new PortContextPair<>(port, context));
        port.setup(context);
    }
    outputPorts.putAll(newOutputPorts);

    /* This introduces need for synchronization on processNodeRequest which was solved by adding deleted field in StramToNodeRequest  */
    cContext.processNodeRequests(false);
    node.activate();
    cContext.publish(new ContainerEvent.NodeActivationEvent(node));
}

From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_4.java

protected void updateSysList() throws Exception {
    if (log.isInfoEnabled()) {
        log.info("Updating sys_list...");
    }/*w  w  w  .  j  ava 2  s  .co m*/

    // ---------------------------
    int lstId = 6100;
    if (log.isInfoEnabled()) {
        log.info("Updating syslist " + lstId + " (INSPIRE Themen fr Verschlagwortung)...");
    }

    // clean up, to guarantee no old values !
    sqlStr = "DELETE FROM sys_list where lst_id = " + lstId;
    jdbc.executeUpdate(sqlStr);

    // german syslist
    LinkedHashMap<Integer, String> newSyslist6100_de = UtilsInspireThemes.inspireThemes_de;
    // english syslist
    LinkedHashMap<Integer, String> newSyslist6100_en = UtilsInspireThemes.inspireThemes_en;

    Iterator<Integer> itr = newSyslist6100_de.keySet().iterator();
    while (itr.hasNext()) {
        int key = itr.next();
        // german version
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslist6100_de.get(key)
                        + "', 0, 'N')");
        // english version
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslist6100_en.get(key)
                        + "', 0, 'N')");
    }

    // ---------------------------
    lstId = 527;
    if (log.isInfoEnabled()) {
        log.info("Updating syslist " + lstId
                + " (ISO)Themenkategorie-Codeliste (ISO B.5.27 MD_TopicCategoryCode)...");
    }

    // clean up, to guarantee no old values !
    sqlStr = "DELETE FROM sys_list where lst_id = " + lstId;
    jdbc.executeUpdate(sqlStr);

    // german syslist
    LinkedHashMap<Integer, String> newSyslist527_de = new LinkedHashMap<Integer, String>();
    newSyslist527_de.put(1, "Landwirtschaft");
    newSyslist527_de.put(2, "Biologie");
    newSyslist527_de.put(3, "Grenzen");
    newSyslist527_de.put(4, "Atmosphre");
    newSyslist527_de.put(5, "Wirtschaft");
    newSyslist527_de.put(6, "Hhenangaben");
    newSyslist527_de.put(7, "Umwelt");
    newSyslist527_de.put(8, "Geowissenschaften");
    newSyslist527_de.put(9, "Gesundheitswesen");
    newSyslist527_de.put(10, "Oberflchenbeschreibung");
    newSyslist527_de.put(11, "Militr und Aufklrung");
    newSyslist527_de.put(12, "Binnengewsser");
    newSyslist527_de.put(13, "Ortsangaben");
    newSyslist527_de.put(14, "Meere");
    newSyslist527_de.put(15, "Planungsunterlagen, Kataster");
    newSyslist527_de.put(16, "Gesellschaft");
    newSyslist527_de.put(17, "Bauwerke");
    newSyslist527_de.put(18, "Verkehrswesen");
    newSyslist527_de.put(19, "Ver- und Entsorgung, Kommunikation");
    // english syslist
    LinkedHashMap<Integer, String> newSyslist527_en = new LinkedHashMap<Integer, String>();
    newSyslist527_en.put(1, "farming");
    newSyslist527_en.put(2, "biota");
    newSyslist527_en.put(3, "boundaries");
    newSyslist527_en.put(4, "climatologyMeteorologyAtmosphere");
    newSyslist527_en.put(5, "economy");
    newSyslist527_en.put(6, "elevation");
    newSyslist527_en.put(7, "environment");
    newSyslist527_en.put(8, "geoscientificInformation");
    newSyslist527_en.put(9, "health");
    newSyslist527_en.put(10, "imageryBaseMapsEarthCover");
    newSyslist527_en.put(11, "intelligenceMilitary");
    newSyslist527_en.put(12, "inlandWaters");
    newSyslist527_en.put(13, "location");
    newSyslist527_en.put(14, "oceans");
    newSyslist527_en.put(15, "planningCadastre");
    newSyslist527_en.put(16, "society");
    newSyslist527_en.put(17, "structure");
    newSyslist527_en.put(18, "transportation");
    newSyslist527_en.put(19, "utilitiesCommunication");

    itr = newSyslist527_de.keySet().iterator();
    while (itr.hasNext()) {
        int key = itr.next();
        // german version
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'de', '" + newSyslist527_de.get(key)
                        + "', 0, 'N')");
        // english version
        jdbc.executeUpdate(
                "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) VALUES ("
                        + getNextId() + ", " + lstId + ", " + key + ", 'en', '" + newSyslist527_en.get(key)
                        + "', 0, 'N')");
    }

    if (log.isInfoEnabled()) {
        log.info("Updating sys_list... done");
    }
}

From source file:org.apache.olingo.client.core.it.v3.EntityCreateTestITCase.java

private void multiKey(final ODataPubFormat format) {
    final ODataEntity message = client.getObjectFactory()
            .newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Message");

    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("MessageId",
            client.getPrimitiveValueBuilder().setValue(1000).setType(EdmPrimitiveTypeKind.Int32).build()));
    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FromUsername",
            client.getPrimitiveValueBuilder().setValue("1").setType(EdmPrimitiveTypeKind.String).build()));
    message.getProperties()/* w  ww. jav  a2 s . c  om*/
            .add(client.getObjectFactory().newPrimitiveProperty("ToUsername", client.getPrimitiveValueBuilder()
                    .setValue("xlodhxzzusxecbzptxlfxprneoxkn").setType(EdmPrimitiveTypeKind.String).build()));
    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Subject", client
            .getPrimitiveValueBuilder().setValue("Test subject").setType(EdmPrimitiveTypeKind.String).build()));
    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Body", client
            .getPrimitiveValueBuilder().setValue("Test body").setType(EdmPrimitiveTypeKind.String).build()));
    message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead",
            client.getPrimitiveValueBuilder().setValue(false).setType(EdmPrimitiveTypeKind.Boolean).build()));

    final CommonURIBuilder<?> builder = client.getURIBuilder(getServiceRoot())
            .appendEntitySetSegment("Message");
    final ODataEntityCreateRequest req = client.getCUDRequestFactory().getEntityCreateRequest(builder.build(),
            message);
    req.setFormat(format);

    final ODataEntityCreateResponse res = req.execute();
    assertNotNull(res);
    assertEquals(201, res.getStatusCode());

    final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
    multiKey.put("FromUsername", "1");
    multiKey.put("MessageId", 1000);

    final ODataDeleteResponse deleteRes = client.getCUDRequestFactory()
            .getDeleteRequest(builder.appendKeySegment(multiKey).build()).execute();
    assertEquals(204, deleteRes.getStatusCode());
}

From source file:com.espertech.esper.regression.pattern.TestCronParameter.java

private LinkedHashMap<String, Long> makeExternalClockTimes(LinkedHashMap<String, Object> testData,
        long baseTime, long numMSecBetweenEvents) {
    LinkedHashMap<String, Long> testDataTimers = new LinkedHashMap<String, Long>();

    testDataTimers.put(EventCollection.ON_START_EVENT_ID, baseTime);

    for (String id : testData.keySet()) {
        baseTime += numMSecBetweenEvents;
        testDataTimers.put(id, baseTime);
    }//from  w w w .j  a  v a2 s.c  o  m

    return testDataTimers;
}

From source file:org.n52.sensorweb.series.policy.editor.ctrl.SimplePermissionEditorController.java

/**
 * @param permissionSetName/*from www  .  java2  s .c  om*/
 *        the permission set to be edited
 * @return permissionSet
 */
@RequestMapping(value = "/edit/{permissionSetName}", method = RequestMethod.GET)
public ModelAndView editPermissionSet(@PathVariable String permissionSetName, HttpServletRequest request) {
    ModelAndView mav = new ModelAndView("createPermissionSet");
    PermissionSet permissionSet = simplePermissionService.getPermissionSet(permissionSetName);
    if (permissionSet == null) {
        throw new ResourceNotFoundException("No permissionSet with name '" + permissionSetName + "'.");
    }

    /* for page titles */
    mav.addObject("pageTitle", "Modify Permission Set");
    mav.addObject("heading", "Modify " + permissionSetName);

    /* for the breadcrumb */
    LinkedHashMap<String, String> breadCrumb = new LinkedHashMap<String, String>();
    breadCrumb.put("Manager", request.getContextPath() + "/editor/");
    breadCrumb.put("Permission Set", request.getContextPath() + "/editor/edit/" + permissionSetName);
    mav.addObject("breadCrumb", breadCrumb);

    mav.addObject(permissionSet);
    mav.addObject("preConfiguredEnforcementPoints", enforcementPointService.getEpServices());

    /* Adding additional parameters so as the UI should be aware of the context */
    mav.addObject("context", "modify");
    return mav;
}

From source file:com.baidu.rigel.biplatform.tesseract.isservice.search.service.impl.CallbackSearchServiceImpl.java

/**
 * @param context ?/*from   w ww  . j  av  a  2  s.  co  m*/
 * @param query ?
 * @return 
 * @throws IndexAndSearchException exception occurred when 
 */
public SearchIndexResultSet query(QueryContext context, QueryRequest query) throws IndexAndSearchException {
    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_BEGIN, "callbackquery",
            "[callbackquery:" + query + "]"));
    if (query == null || context == null || StringUtils.isEmpty(query.getCubeId())) {
        LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "callbackquery",
                "[callbackquery:" + query + "]"));
        throw new IndexAndSearchException(
                TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE,
                        IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION),
                IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION);
    }
    // TODO ???
    if (query.getGroupBy() == null || query.getSelect() == null) {
        return null;
    }
    Map<String, String> requestParams = ((QueryContextAdapter) context).getQuestionModel().getRequestParams();
    // Build query target map
    Map<String, List<MiniCubeMeasure>> callbackMeasures = context.getQueryMeasures().stream()
            .filter(m -> m.getType().equals(MeasureType.CALLBACK)).map(m -> {
                CallbackMeasure tmp = (CallbackMeasure) m;
                for (Map.Entry<String, String> entry : tmp.getCallbackParams().entrySet()) {
                    if (requestParams.containsKey(entry.getKey())) {
                        tmp.getCallbackParams().put(entry.getKey(), requestParams.get(entry.getKey()));
                    }
                }
                return m;
            }).collect(Collectors.groupingBy(c -> ((CallbackMeasure) c).getCallbackUrl(), Collectors.toList()));
    if (callbackMeasures == null || callbackMeasures.isEmpty()) {
        LOGGER.error(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_EXCEPTION, "Empty callback measure",
                "[callbackquery:" + query + "]"));
        throw new IndexAndSearchException(
                TesseractExceptionUtils.getExceptionMessage(IndexAndSearchException.QUERYEXCEPTION_MESSAGE,
                        IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION),
                IndexAndSearchExceptionType.ILLEGALARGUMENT_EXCEPTION);
    }
    LOGGER.info("Find callback targets " + callbackMeasures);

    // Keep group-by sequence.
    List<String> groupby = new ArrayList<String>(query.getGroupBy().getGroups());
    LinkedHashMap<String, List<String>> groupbyParams = new LinkedHashMap<String, List<String>>(groupby.size());
    for (String g : groupby) {
        groupbyParams.put(g, new ArrayList<String>());
    }

    LinkedHashMap<String, List<String>> whereParams = new LinkedHashMap<String, List<String>>();
    for (Expression e : query.getWhere().getAndList()) {
        List<String> l = e.getQueryValues().stream().filter(v -> !StringUtils.isEmpty(v.getValue()))
                .map(v -> v.getValue()).collect(Collectors.toList());
        if (groupbyParams.containsKey(e.getProperties())) {
            // if not contains SUMMARY_KEY, add it into group by list
            if (!l.contains(TesseractConstant.SUMMARY_KEY)) {
                l.add(TesseractConstant.SUMMARY_KEY);
            }
            // Put it into group by field
            groupbyParams.get(e.getProperties()).addAll(l);
        } else {
            // Put it into filter field
            if (CollectionUtils.isEmpty(l)) {
                List<Set<String>> tmp = e.getQueryValues().stream().map(v -> v.getLeafValues())
                        .collect(Collectors.toList());
                List<String> values = Lists.newArrayList();
                tmp.forEach(t -> values.addAll(t));
                whereParams.put(e.getProperties(), values);
            } else {
                whereParams.put(e.getProperties(), new ArrayList<String>(l));
            }
        }
    }

    // Prepare query tools
    //        CountDownLatch latch = new CountDownLatch(response.size());
    //        List<Future<CallbackResponse>> results = Lists.newArrayList();
    Map<CallbackExecutor, Future<CallbackResponse>> results = Maps.newHashMap();
    ExecutorCompletionService<CallbackResponse> service = new ExecutorCompletionService<CallbackResponse>(
            taskExecutor);
    StringBuilder callbackMeasureNames = new StringBuilder();
    for (Entry<String, List<MiniCubeMeasure>> e : callbackMeasures.entrySet()) {
        CallbackExecutor ce = new CallbackExecutor(e, groupbyParams, whereParams);
        results.put(ce, service.submit(ce));
        e.getValue().forEach(m -> {
            callbackMeasureNames.append(" " + m.getCaption() + " ");
        });
    }
    //        }
    Map<CallbackExecutor, CallbackResponse> response = new ConcurrentHashMap<CallbackExecutor, CallbackResponse>(
            callbackMeasures.size());
    StringBuffer sb = new StringBuffer();
    results.forEach((k, v) -> {
        try {
            response.put(k, v.get());
        } catch (Exception e1) {
            LOGGER.error(e1.getMessage(), e1);
            sb.append(": " + callbackMeasureNames.toString()
                    + " ??, ?");
        }
    });
    if (!StringUtils.isEmpty(sb.toString())) {
        if (ThreadLocalPlaceholder.getProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY) != null) {
            ThreadLocalPlaceholder.unbindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY);
        }
        ThreadLocalPlaceholder.bindProperty(ThreadLocalPlaceholder.ERROR_MSG_KEY, sb.toString());
    }
    // Package result
    SqlQuery sqlQuery = QueryRequestUtil.transQueryRequest2SqlQuery(query);
    SearchIndexResultSet result = null;
    if (!response.isEmpty()) {
        result = packageResultRecords(query, sqlQuery, response);
    } else {
        result = new SearchIndexResultSet(new Meta(query.getGroupBy().getGroups().toArray(new String[0])), 0);
    }

    LOGGER.info(String.format(LogInfoConstants.INFO_PATTERN_FUNCTION_END, "query", "[query:" + query + "]"));
    return result;
}

From source file:com.streamsets.pipeline.stage.destination.hdfs.TestHdfsTarget.java

/**
 * Verifies normal behavior when target directory is in the header.
 *///  w  ww.  j a va 2  s  .co  m
@Test
public void testHdfsDelimitedDataFormat() throws Exception {
    DataGeneratorFormatConfig dataGeneratorFormatConfig = new DataGeneratorFormatConfig();
    dataGeneratorFormatConfig.csvFileFormat = CsvMode.CSV;
    dataGeneratorFormatConfig.csvReplaceNewLines = true;
    dataGeneratorFormatConfig.csvReplaceNewLinesString = " ";
    dataGeneratorFormatConfig.csvHeader = CsvHeader.NO_HEADER;

    HdfsTarget hdfsTarget = HdfsTargetUtil.newBuilder().dataGeneratorFormatConfig(dataGeneratorFormatConfig)
            .dirPathTemplateInHeader(true).dataForamt(DataFormat.DELIMITED).build();

    TargetRunner runner = new TargetRunner.Builder(HdfsDTarget.class, hdfsTarget)
            .setOnRecordError(OnRecordError.STOP_PIPELINE).build();
    runner.runInit();

    Record record = RecordCreator.create();
    record.getHeader().setAttribute(HdfsTarget.TARGET_DIRECTORY_HEADER, getTestDir() + "/hdfs/");
    LinkedHashMap<String, Field> list = new LinkedHashMap<>();
    list.put("x", Field.create("x\nz"));
    list.put("y", Field.create("y"));
    record.set(Field.createListMap(list));

    runner.runWrite(ImmutableList.copyOf(new Record[] { record }));

    runner.runDestroy();

    File[] fileList = new File(getTestDir() + "/hdfs/").listFiles();
    Assert.assertEquals(1, fileList.length);
    Assert.assertEquals("x z,y\r\n", FileUtils.readFileToString(fileList[0], Charset.defaultCharset()));
}