Esempio n. 1
0
  /**
   * Verify that if a constant value is assigned to a given field, and that field appears as an
   * entry mapped from a column, that the constant value will still take precedence.
   *
   * @expectedResults Assert that the new value is maintained.
   */
  @Test
  public void testConstValueOverridesColumnValue() throws Exception {

    Properties mappings = new Properties();
    final String sfdcField = "Name";
    final String csvFieldName =
        "abc"; // this is the column in the csv file to which the sfdc field will be bound

    final String constantValue = "NotAbc";
    final String wrappedConstantValue = "\"" + constantValue + "\"";

    LoadMapper mapper = new LoadMapper(null, null, null);

    // place a dao column -> sfdc field mapping
    // (src, dest).
    mapper.putMapping(csvFieldName, sfdcField);

    // place a constant mapping into the LoadMapper.
    mappings.setProperty(wrappedConstantValue, sfdcField);
    mapper.putPropertyFileMappings(mappings);

    Row input = Row.singleEntryImmutableRow(constantValue, sfdcField);

    Map<String, Object> result = mapper.mapData(input);

    // verify that the old value holds
    assertEquals(constantValue, result.get(sfdcField));
  }
Esempio n. 2
0
 @Test
 public void testVerifyMappingsAreValidUnknownColumn() throws Exception {
   LoadMapper loadMapper = new LoadMapper(getController().getPartnerClient(), null, null);
   loadMapper.putMapping(SOURCE_NAMES[0], "non_existing_col_aa");
   try {
     loadMapper.verifyMappingsAreValid();
     Assert.fail("An exception should have been thrown since destination column does not exist");
   } catch (MappingInitializationException ignored) {
     // expected
   }
 }
Esempio n. 3
0
  @Test
  public void testMapDataEmptyEntriesIgnored() throws Exception {
    LoadMapper loadMapper = new LoadMapper(null, null, null);
    loadMapper.putMapping("SOURCE_COL", "");

    Row inputData = Row.singleEntryImmutableRow("SOURCE_COL", "123");

    Map<String, Object> result = loadMapper.mapData(inputData);

    assertTrue("Empty destination column should have not been mapped", result.isEmpty());
  }
Esempio n. 4
0
 @Test
 public void testVerifyMappingsAreValidEmptyEntries() throws Exception {
   LoadMapper loadMapper = new LoadMapper(null, null, null);
   loadMapper.putMapping("SOURCE_COL", "");
   loadMapper.verifyMappingsAreValid(); // no exception expected
 }