use of org.talend.designer.mapper.managers.MapperManager in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method testGetLookupTableProblem.
@Test
public void testGetLookupTableProblem() {
MapperComponent mapperComponent = createMapperComponent();
ExternalMapperData externalData = (ExternalMapperData) mapperComponent.getExternalData();
MapperManager mapperManager = mapperComponent.getMapperMain().getMapperManager();
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = ((MapperComponent) mapperManager.getAbstractMapComponent()).getMapperMain();
List<? extends IConnection> incomingConnections = new ArrayList<IConnection>(mapperManager.getAbstractMapComponent().getIncomingConnections());
ArrayList<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
InputTable lookupTable = inputTables.get(1);
ProblemsAnalyser analyser = new ProblemsAnalyser(mapperManager);
// match mode:Unique Match +no expression
lookupTable.setMatchingMode(TMAP_MATCHING_MODE.UNIQUE_MATCH);
analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
List<Problem> problems = analyser.getProblems();
Assert.assertEquals(problems.size(), 1);
Assert.assertEquals(problems.get(0).getDescription(), "The lookup table 'row2' should have at least one expression key filled.");
// match mode:All Row +expression
lookupTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
lookupTable.getColumnEntries().get(0).setExpression("row1.newColumn1");
analyser = new ProblemsAnalyser(mapperComponent.getMapperMain().getMapperManager());
analyser.getLookupTableProblem(lookupTable, mapperManager.isTableHasAtLeastOneHashKey(lookupTable));
problems = analyser.getProblems();
Assert.assertEquals(problems.size(), 1);
Assert.assertEquals(problems.get(0).getDescription(), "The expression key can't be used in lookup table 'row2' with match mode 'All Rows'.");
}
Aggregations