Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Flow toString #14

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright [2021] [The Original Author]
~Copyright [2024] [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.
Expand Down Expand Up @@ -107,7 +107,7 @@
</build>

<properties>
<revision>0.1.4</revision>
<revision>0.1.5</revision>
<guava.version>19.0</guava.version>
<guice.version>4.2.3</guice.version>
</properties>
Expand All @@ -118,6 +118,13 @@
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
2 changes: 1 addition & 1 deletion tef-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright [2021] [The Original Author]
~Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
19 changes: 17 additions & 2 deletions tef-core/src/main/java/flipkart/tef/flow/SimpleFlow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand All @@ -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
*/
Expand All @@ -39,6 +40,12 @@ public class SimpleFlow {
*/
private final List<Class<? extends IBizlogic>> 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.
*/
Expand All @@ -57,4 +64,12 @@ public List<Class<? extends IBizlogic>> getBizlogics() {
public BiMap<DataAdapterKey<?>, Class<? extends IDataBizlogic<?>>> getDataAdapterMap() {
return dataAdapterMap;
}

public String toString() {
if (stringRepresentation == null) {
stringRepresentation = "bizlogics ->\n" + bizlogics.stream().map(Class::getName).collect(Collectors.joining("\n"));
}

return stringRepresentation;
}
}
66 changes: 66 additions & 0 deletions tef-core/src/test/java/flipkart/tef/flow/SimpleFlowTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
*Copyright [2024] [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) {

}
}
}
9 changes: 1 addition & 8 deletions tef-impl/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright [2021] [The Original Author]
~Copyright [2024] [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.
Expand Down Expand Up @@ -33,13 +33,6 @@
<version>${revision}</version>
<artifactId>tef-core</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
2 changes: 1 addition & 1 deletion tef-impl/src/main/java/flipkart/tef/TefGuiceModule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand All @@ -16,7 +16,6 @@

package flipkart.tef.execution;

import com.google.common.reflect.Reflection;
import flipkart.tef.annotations.InjectData;
import flipkart.tef.exception.TefExecutionException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright [2021] [The Original Author]
*Copyright [2024] [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.
Expand Down
Loading
Loading