From c72736da16b5a21dab408569d717c326e9c64da9 Mon Sep 17 00:00:00 2001 From: bageshwar <2353296+bageshwar@users.noreply.github.com> Date: Fri, 26 Jan 2024 07:33:33 +0530 Subject: [PATCH 1/2] SimpleFlow .toString method --- pom.xml | 9 ++- .../java/flipkart/tef/flow/SimpleFlow.java | 17 ++++- .../flipkart/tef/flow/SimpleFlowTest.java | 66 +++++++++++++++++++ tef-impl/pom.xml | 7 -- 4 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java diff --git a/pom.xml b/pom.xml index 1127bef..56fb0b0 100644 --- a/pom.xml +++ b/pom.xml @@ -107,7 +107,7 @@ - 0.1.4 + 0.1.5 19.0 4.2.3 @@ -118,6 +118,13 @@ guice ${guice.version} + + + junit + junit + 4.12 + test + diff --git a/tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java b/tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java index e3cb0d2..3cfc366 100644 --- a/tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java +++ b/tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java @@ -24,12 +24,13 @@ import flipkart.tef.bizlogics.IDataBizlogic; import java.util.List; +import java.util.stream.Collectors; /** * Simple Flow Represents an Execution DAG. The list of bizlogics are in strict order of execution. * Cycles are guaranteed to be not present. * - * + * * Date: 19/06/20 * Time: 5:02 PM */ @@ -39,6 +40,12 @@ public class SimpleFlow { */ private final List> bizlogics; + /** + * toString method triggers the population of this variable. It contains the ordered classnames + * of the list of bizlogics that represent this flow. + */ + private String stringRepresentation; + /** * Map keyed by the Data Object against the Data Adapter that is responsible for producing it. */ @@ -57,4 +64,12 @@ public List> getBizlogics() { public BiMap, Class>> getDataAdapterMap() { return dataAdapterMap; } + + public String toString() { + if (stringRepresentation == null) { + stringRepresentation = "bizlogics ->\n" + bizlogics.stream().map(Class::getName).collect(Collectors.joining("\n")); + } + + return stringRepresentation; + } } diff --git a/tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java b/tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java new file mode 100644 index 0000000..f05cebb --- /dev/null +++ b/tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java @@ -0,0 +1,66 @@ +/* + * Copyright [2021] [The Original Author] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package flipkart.tef.flow; + + +import com.google.common.collect.HashBiMap; +import flipkart.tef.bizlogics.IBizlogic; +import flipkart.tef.bizlogics.TefContext; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +public class SimpleFlowTest { + + + @Test + public void testToStringForEmptyFlow() { + SimpleFlow instance = new SimpleFlow(Collections.emptyList(), HashBiMap.create()); + String expResult = "bizlogics ->\n"; + String result = instance.toString(); + assertEquals(expResult, result); + } + + @Test + public void testToStringForNonEmptyFlow() { + SimpleFlow instance = new SimpleFlow(Arrays.asList(Bizlogic1.class, Bizlogic2.class), HashBiMap.create()); + String expResult = "bizlogics ->\n" + + "flipkart.tef.flow.SimpleFlowTest$Bizlogic1\n" + + "flipkart.tef.flow.SimpleFlowTest$Bizlogic2"; + String result = instance.toString(); + assertEquals(expResult, result); + } + + static class Bizlogic1 implements IBizlogic { + + @Override + public void execute(TefContext tefContext) { + + } + } + + static class Bizlogic2 implements IBizlogic { + + @Override + public void execute(TefContext tefContext) { + + } + } +} \ No newline at end of file diff --git a/tef-impl/pom.xml b/tef-impl/pom.xml index 29d00cb..eaa9df5 100644 --- a/tef-impl/pom.xml +++ b/tef-impl/pom.xml @@ -33,13 +33,6 @@ ${revision} tef-core - - - junit - junit - 4.12 - test - \ No newline at end of file From 51f709b0d638c60484b62e9a3416a91bc7b82937 Mon Sep 17 00:00:00 2001 From: bageshwar <2353296+bageshwar@users.noreply.github.com> Date: Fri, 26 Jan 2024 07:35:16 +0530 Subject: [PATCH 2/2] Copyright year update --- pom.xml | 2 +- tef-core/pom.xml | 2 +- tef-core/src/main/java/flipkart/tef/FlowExecutionListener.java | 2 +- tef-core/src/main/java/flipkart/tef/annotations/DependsOn.java | 2 +- tef-core/src/main/java/flipkart/tef/annotations/EmitData.java | 2 +- .../src/main/java/flipkart/tef/annotations/InjectData.java | 2 +- .../src/main/java/flipkart/tef/bizlogics/DataAdapterKey.java | 2 +- .../main/java/flipkart/tef/bizlogics/DataAdapterResult.java | 2 +- tef-core/src/main/java/flipkart/tef/bizlogics/IBizlogic.java | 2 +- .../src/main/java/flipkart/tef/bizlogics/IDataBizlogic.java | 2 +- tef-core/src/main/java/flipkart/tef/bizlogics/TefContext.java | 2 +- tef-core/src/main/java/flipkart/tef/exception/ErrorCode.java | 2 +- .../java/flipkart/tef/exception/TefExecutionException.java | 2 +- tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java | 2 +- tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java | 2 +- tef-impl/pom.xml | 2 +- tef-impl/src/main/java/flipkart/tef/TefGuiceModule.java | 2 +- .../java/flipkart/tef/bizlogics/AsyncDataAdapterBizlogic.java | 2 +- .../java/flipkart/tef/bizlogics/BasicEnrichmentBizlogic.java | 2 +- .../java/flipkart/tef/bizlogics/BasicValidationBizlogic.java | 2 +- .../main/java/flipkart/tef/bizlogics/DataAdapterBizlogic.java | 2 +- .../tef/capability/AdapterConflictRuntimeException.java | 2 +- .../main/java/flipkart/tef/capability/BizlogicDependency.java | 2 +- .../java/flipkart/tef/capability/CapabilityDefinition.java | 2 +- .../flipkart/tef/capability/EmptyCapabilityDefinition.java | 2 +- .../flipkart/tef/capability/model/EnrichmentResultData.java | 2 +- .../main/java/flipkart/tef/capability/model/MapBaseData.java | 2 +- .../flipkart/tef/capability/model/ValidationResultData.java | 2 +- .../UnableToResolveDataFromAdapterRuntimeException.java | 2 +- tef-impl/src/main/java/flipkart/tef/execution/DataContext.java | 2 +- .../java/flipkart/tef/execution/DataDependencyException.java | 2 +- .../src/main/java/flipkart/tef/execution/DataInjector.java | 2 +- .../main/java/flipkart/tef/execution/DefaultDataInjector.java | 3 +-- tef-impl/src/main/java/flipkart/tef/execution/FlowBuilder.java | 2 +- .../src/main/java/flipkart/tef/execution/FlowExecutor.java | 2 +- .../java/flipkart/tef/execution/FluentCapabilityBuilder.java | 2 +- .../java/flipkart/tef/execution/InjectableValueProvider.java | 2 +- .../src/main/java/flipkart/tef/execution/MutationListener.java | 2 +- tef-impl/src/test/java/flipkart/tef/TestGuiceModule.java | 2 +- tef-impl/src/test/java/flipkart/tef/TestTefContext.java | 2 +- .../test/java/flipkart/tef/bizlogics/DataAdapterKeyTest.java | 2 +- .../src/test/java/flipkart/tef/execution/ExecutionStage.java | 2 +- .../src/test/java/flipkart/tef/execution/ExecutionStep.java | 2 +- .../src/test/java/flipkart/tef/execution/FlowBuilderTest.java | 2 +- .../java/flipkart/tef/execution/FlowExecutorMutationTest.java | 2 +- .../src/test/java/flipkart/tef/execution/FlowExecutorTest.java | 2 +- .../flipkart/tef/execution/FluentCapabilityBuilderTest.java | 2 +- .../java/flipkart/tef/execution/MyFlowExecutionListener.java | 2 +- 48 files changed, 48 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index 56fb0b0..8d91e9d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@