Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
shrverma committed Aug 10, 2023
1 parent a422223 commit ec117cb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
import java.util.Map;
import java.util.Set;

/**
* Basic implementation of the {@link RelationalTranformContext} with single output port
*/
public class MockRelationalTransformContext implements RelationalTranformContext {
private Engine engine;
private Map<String, Relation> inputMap;
Expand All @@ -39,7 +36,6 @@ public class MockRelationalTransformContext implements RelationalTranformContext
private FeatureFlagsProvider featureFlagsProvider;
private Relation outputRelation;


public MockRelationalTransformContext(Engine engine,
Map<String, Relation> inputMap,
Map<String, Schema> inputSchemas,
Expand Down Expand Up @@ -92,9 +88,6 @@ public boolean isFeatureEnabled(String name) {
return this.featureFlagsProvider.isFeatureEnabled(name);
}

public Relation getOutputRelation() {
return outputRelation;
}

public Collection<Capability> getDefaultLanguageCapabilityList() {
return Collections.singleton(StandardSQLCapabilities.POSTGRES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,14 @@

package io.cdap.directives.column;

import io.cdap.MockEngine;
import io.cdap.MockExpression;
import io.cdap.MockRelation;
import io.cdap.MockRelationalTransformContext;
import io.cdap.cdap.etl.api.relational.Engine;
import io.cdap.cdap.etl.api.relational.Relation;
import io.cdap.cdap.etl.api.relational.RelationalTranformContext;
import io.cdap.wrangler.TestingRig;
import io.cdap.wrangler.api.DirectiveParseException;
import io.cdap.wrangler.api.RecipeException;
import io.cdap.wrangler.api.Row;
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static io.cdap.RelationalDirectiveTest.runTransform;
import static org.mockito.ArgumentMatchers.any;

/**
* Tests {@link Rename}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ public void testSentenceRightTrim() throws Exception {
public void testRelationColumn() throws DirectiveParseException, RecipeException {
MockRelation relation = new MockRelation(null, null);
Engine engine = new MockEngine();
RelationalTranformContext relationalTranformContext = new MockRelationalTransformContext(engine, null
, null
,
null
, null
);
RelationalTranformContext relationalTranformContext = new MockRelationalTransformContext(engine,
null, null, null, null);
String[] recipe = {"rtrim testColumn"};
Relation relation1 = runTransform(recipe, relationalTranformContext, relation);
Assert.assertEquals(((MockRelation) relation1).getColumn(), "testColumn");
Expand All @@ -105,12 +101,8 @@ public void testRelationColumn() throws DirectiveParseException, RecipeException
public void testRelationExpression() throws DirectiveParseException, RecipeException {
MockRelation relation = new MockRelation(null, null);
Engine engine = new MockEngine();
RelationalTranformContext relationalTranformContext = new MockRelationalTransformContext(engine, null
, null
,
null
, null
);
RelationalTranformContext relationalTranformContext = new MockRelationalTransformContext(engine,
null, null, null, null);
String[] recipe = {"rtrim testColumn"};
Relation relation1 = runTransform(recipe, relationalTranformContext, relation);
Assert.assertEquals(((MockExpression) ((MockRelation) relation1).getExpression()).getExpression(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,12 @@

package io.cdap.wrangler;

import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.etl.api.relational.Capability;
import io.cdap.cdap.etl.api.relational.Engine;
import io.cdap.cdap.etl.api.relational.Expression;
import io.cdap.cdap.etl.api.relational.ExpressionFactory;
import io.cdap.cdap.etl.api.relational.ExpressionFactoryType;
import io.cdap.cdap.etl.api.relational.InvalidRelation;
import io.cdap.cdap.etl.api.relational.Relation;

import io.cdap.cdap.etl.api.relational.RelationalTranformContext;
import io.cdap.directives.transformation.Lower;
import io.cdap.wrangler.api.Directive;
import io.cdap.wrangler.api.DirectiveLoadException;
import io.cdap.wrangler.api.DirectiveParseException;
import io.cdap.wrangler.api.RecipeException;
import io.cdap.wrangler.parser.GrammarBasedParser;
import io.cdap.wrangler.parser.MigrateToV2;
import io.cdap.wrangler.registry.DirectiveRegistry;
import io.cdap.wrangler.registry.SystemDirectiveRegistry;
import io.cdap.wrangler.utils.SqlExpressionGenerator;
import org.apache.poi.ss.formula.functions.T;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;


Expand Down

0 comments on commit ec117cb

Please sign in to comment.