All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.SystemOutDiffManagerImpl Maven / Gradle / Ivy

package org.etlunit;

import org.etlunit.parser.ETLTestOperation;

import java.io.File;
import java.util.List;

public class SystemOutDiffManagerImpl implements DiffManagerImpl
{
	@Override
	public DiffGrid reportDiff(ETLTestOperation method, String failureId)
	{
		StringBuilder builder = new StringBuilder();

		builder.append("RECORD_NUM\tCHANGE_TYPE\tCOLUMN_NAME\tSOURCE_VALUE\tTARGET_VALUE");

		String x = builder.toString();
		System.out.println(x);
		System.out
				.println(
						"-------------------------------------------------------------------------------------------------------------------------------------------------------"
								.substring(0, x.length()));

		return new DiffGrid()
		{
			@Override
			public DiffGridRow addRow(final int lineNo, final int tarLine, final line_type type)
			{
				return new DiffGridRow()
				{
					private String columnName = null;
					private String sourceValue = null;
					private String targetValue = null;
					private String orderKey = null;

					StringBuilder stb = new StringBuilder();

					@Override
					public void setColumnName(String col)
					{
						columnName = col;
					}

					@Override
					public void setOrderKey(String key)
					{
						orderKey = key;
					}

					@Override
					public void setSourceValue(String value)
					{
						sourceValue = value;
					}

					@Override
					public void setTargetValue(String value)
					{
						targetValue = value;
					}

					@Override
					public void done()
					{
						stb.setLength(0);

						stb
								.append(lineNo)
								.append('\t')
								.append(type)
								.append('\t')
								.append(type == line_type.changed
										? columnName
										: (type == line_type.added ? "TARGET_ADDED" : "SOURCE_REMOVED"))
								.append('\t')
								.append(sourceValue)
								.append('\t')
								.append(targetValue);

						System.out.println(stb.toString());
					}
				};
			}

			@Override
			public void done()
			{
				System.out.println();
			}
		};
	}

	@Override
	public DataSetGrid reportDataSet(ETLTestOperation method, List columns, String failureId)
	{
		throw new UnsupportedOperationException();
	}

	@Override
	public void setOutputDirectory(File file)
	{
	}

	@Override
	public void dispose()
	{
		System.out.println();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy