repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
decatur/j2js-compiler
src/main/java/com/j2js/dom/BooleanLiteral.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author wolfgang */ public class BooleanLiteral extends Expression { // Note: Never ever use TRUE as part of a DOM. public static BooleanLiteral FALSE = new BooleanLiteral(false); // Note: Never ever use TRUE as part of a DOM. public static BooleanLiteral TRUE = new BooleanLiteral(true); private boolean value; public BooleanLiteral(boolean theValue) { value = theValue; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/BooleanLiteral.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author wolfgang */ public class BooleanLiteral extends Expression { // Note: Never ever use TRUE as part of a DOM. public static BooleanLiteral FALSE = new BooleanLiteral(false); // Note: Never ever use TRUE as part of a DOM. public static BooleanLiteral TRUE = new BooleanLiteral(true); private boolean value; public BooleanLiteral(boolean theValue) { value = theValue; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/cfg/DominatorTree.java
// Path: src/main/java/com/j2js/Log.java // public class Log { // // public static Log logger; // // public static Log getLogger() { // return logger; // } // // private int state = INFO; // // /** // * @return Returns the state. // */ // public int getState() { // return state; // } // // /** // * @param state The state to set. // */ // public void setState(int state) { // this.state = state; // } // // public static final int DEBUG = 3; // public static final int INFO = 2; // public static final int WARN = 1; // public static final int ERROR = 0; // // public void debug(CharSequence arg0, Throwable arg1) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // arg1.printStackTrace(); // } // } // // public void debug(CharSequence arg0) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // } // } // // public void debug(Throwable arg0) { // if (isDebugEnabled()) { // arg0.printStackTrace(); // } // } // // public void error(CharSequence arg0, Throwable arg1) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // arg1.printStackTrace(); // } // } // // public void error(CharSequence arg0) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // } // } // // public void error(Throwable arg0) { // if (isErrorEnabled()) { // arg0.printStackTrace(); // } // } // // public void info(CharSequence arg0, Throwable arg1) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // arg1.printStackTrace(); // } // } // // public void info(CharSequence arg0) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // } // } // // public void info(Throwable arg0) { // if (isInfoEnabled()) { // arg0.printStackTrace(); // } // } // // public boolean isDebugEnabled() { // return state >= DEBUG; // } // // public boolean isErrorEnabled() { // return state >= ERROR; // } // // public boolean isInfoEnabled() { // return state >= INFO; // } // // public boolean isWarnEnabled() { // return state >= WARN; // } // // public void warn(CharSequence arg0, Throwable arg1) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // arg1.printStackTrace(); // } // } // // public void warn(CharSequence arg0) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // } // } // // public void warn(Throwable arg0) { // if (isWarnEnabled()) { // arg0.printStackTrace(); // } // } // // }
import java.util.*; import com.j2js.Log;
package com.j2js.cfg; /** * Class to build the dominator tree of a given control flow graph. * The algorithm is according Purdum-Moore, which isn't as fast as Lengauer-Tarjan, but a lot simpler. */ public class DominatorTree { private ControlFlowGraph graph; public DominatorTree(ControlFlowGraph theGraph) { graph = theGraph; } /** * Sets the pre-order index of a node. */ private void visit(Node node, Collection<Node> visited) { // Establish preorder index. node.setPreOrderIndex(visited.size()); visited.add(node); for (Node succ : node.succs()) { if (! visited.contains(succ)) { visit(succ, visited); } } } /** * Builds the dominator tree and store it in the respective nodes. * It will remove all unreachable nodes on the way! */ public void build() { // Construct list of nodes in pre-order order. ArrayList<Node> preOrder = new ArrayList<Node>(); visit(graph.getSource(), preOrder); // Remove unreachable nodes. for (Node node : new ArrayList<Node>(graph.getNodes())) { if (!preOrder.contains(node)) {
// Path: src/main/java/com/j2js/Log.java // public class Log { // // public static Log logger; // // public static Log getLogger() { // return logger; // } // // private int state = INFO; // // /** // * @return Returns the state. // */ // public int getState() { // return state; // } // // /** // * @param state The state to set. // */ // public void setState(int state) { // this.state = state; // } // // public static final int DEBUG = 3; // public static final int INFO = 2; // public static final int WARN = 1; // public static final int ERROR = 0; // // public void debug(CharSequence arg0, Throwable arg1) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // arg1.printStackTrace(); // } // } // // public void debug(CharSequence arg0) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // } // } // // public void debug(Throwable arg0) { // if (isDebugEnabled()) { // arg0.printStackTrace(); // } // } // // public void error(CharSequence arg0, Throwable arg1) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // arg1.printStackTrace(); // } // } // // public void error(CharSequence arg0) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // } // } // // public void error(Throwable arg0) { // if (isErrorEnabled()) { // arg0.printStackTrace(); // } // } // // public void info(CharSequence arg0, Throwable arg1) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // arg1.printStackTrace(); // } // } // // public void info(CharSequence arg0) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // } // } // // public void info(Throwable arg0) { // if (isInfoEnabled()) { // arg0.printStackTrace(); // } // } // // public boolean isDebugEnabled() { // return state >= DEBUG; // } // // public boolean isErrorEnabled() { // return state >= ERROR; // } // // public boolean isInfoEnabled() { // return state >= INFO; // } // // public boolean isWarnEnabled() { // return state >= WARN; // } // // public void warn(CharSequence arg0, Throwable arg1) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // arg1.printStackTrace(); // } // } // // public void warn(CharSequence arg0) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // } // } // // public void warn(Throwable arg0) { // if (isWarnEnabled()) { // arg0.printStackTrace(); // } // } // // } // Path: src/main/java/com/j2js/cfg/DominatorTree.java import java.util.*; import com.j2js.Log; package com.j2js.cfg; /** * Class to build the dominator tree of a given control flow graph. * The algorithm is according Purdum-Moore, which isn't as fast as Lengauer-Tarjan, but a lot simpler. */ public class DominatorTree { private ControlFlowGraph graph; public DominatorTree(ControlFlowGraph theGraph) { graph = theGraph; } /** * Sets the pre-order index of a node. */ private void visit(Node node, Collection<Node> visited) { // Establish preorder index. node.setPreOrderIndex(visited.size()); visited.add(node); for (Node succ : node.succs()) { if (! visited.contains(succ)) { visit(succ, visited); } } } /** * Builds the dominator tree and store it in the respective nodes. * It will remove all unreachable nodes on the way! */ public void build() { // Construct list of nodes in pre-order order. ArrayList<Node> preOrder = new ArrayList<Node>(); visit(graph.getSource(), preOrder); // Remove unreachable nodes. for (Node node : new ArrayList<Node>(graph.getNodes())) { if (!preOrder.contains(node)) {
Log.getLogger().warn("Unreachable code detected and removed");
decatur/j2js-compiler
src/main/java/com/j2js/dom/Name.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 20, 2005 */ public class Name extends Expression { private String identifier; public Name(String newIdentifier) { //super(); identifier = newIdentifier; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/Name.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 20, 2005 */ public class Name extends Expression { private String identifier; public Name(String newIdentifier) { //super(); identifier = newIdentifier; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/ArrayInitializer.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import java.util.List; import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author wolfgang */ public class ArrayInitializer extends Expression { private List<Expression> expressions = new java.util.ArrayList<Expression>();
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/ArrayInitializer.java import java.util.List; import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author wolfgang */ public class ArrayInitializer extends Expression { private List<Expression> expressions = new java.util.ArrayList<Expression>();
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/PrimitiveCast.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; public class PrimitiveCast extends Expression { public int castType = 0; public Expression expression; public PrimitiveCast(int theCastType, Expression expr, Type typeBinding) { super(); type = typeBinding; castType = theCastType; expression = expr; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/PrimitiveCast.java import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; public class PrimitiveCast extends Expression { public int castType = 0; public Expression expression; public PrimitiveCast(int theCastType, Expression expr, Type typeBinding) { super(); type = typeBinding; castType = theCastType; expression = expr; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/SwitchStatement.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
/* * Created on Oct 24, 2004 */ package com.j2js.dom; /** * @author wolfgang */ public class SwitchStatement extends Block { private Expression expression; public SwitchStatement() { super(); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/SwitchStatement.java import com.j2js.visitors.AbstractVisitor; /* * Created on Oct 24, 2004 */ package com.j2js.dom; /** * @author wolfgang */ public class SwitchStatement extends Block { private Expression expression; public SwitchStatement() { super(); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/Assignment.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import java.util.HashMap; import com.j2js.visitors.AbstractVisitor;
static public Operator MINUS_ASSIGN = new Operator("-="); static public Operator TIMES_ASSIGN = new Operator("*="); static public Operator DIVIDE_ASSIGN = new Operator("/="); static public Operator BIT_AND_ASSIGN = new Operator("&="); static public Operator BIT_OR_ASSIGN = new Operator("|="); static public Operator BIT_XOR_ASSIGN = new Operator("^="); static public Operator REMAINDER_ASSIGN = new Operator("%="); static public Operator LEFT_SHIFT_ASSIGN = new Operator("<<="); static public Operator RIGHT_SHIFT_SIGNED_ASSIGN = new Operator(">>="); static public Operator RIGHT_SHIFT_UNSIGNED_ASSIGN = new Operator(">>>="); private String token; Operator(String theToken) { token = theToken; opsByToken.put(theToken, this); } public String toString() { return token; } } private Operator operator; public Assignment(Operator theOperator) { super(); operator = theOperator; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/Assignment.java import java.util.HashMap; import com.j2js.visitors.AbstractVisitor; static public Operator MINUS_ASSIGN = new Operator("-="); static public Operator TIMES_ASSIGN = new Operator("*="); static public Operator DIVIDE_ASSIGN = new Operator("/="); static public Operator BIT_AND_ASSIGN = new Operator("&="); static public Operator BIT_OR_ASSIGN = new Operator("|="); static public Operator BIT_XOR_ASSIGN = new Operator("^="); static public Operator REMAINDER_ASSIGN = new Operator("%="); static public Operator LEFT_SHIFT_ASSIGN = new Operator("<<="); static public Operator RIGHT_SHIFT_SIGNED_ASSIGN = new Operator(">>="); static public Operator RIGHT_SHIFT_UNSIGNED_ASSIGN = new Operator(">>>="); private String token; Operator(String theToken) { token = theToken; opsByToken.put(theToken, this); } public String toString() { return token; } } private Operator operator; public Assignment(Operator theOperator) { super(); operator = theOperator; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/PStarExpression.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * Class representing the union of pre- and post-fix expression. * @author kuehn */ public class PStarExpression extends Expression { // Operators common to both pre- and post-fix expression. static public Operator INCREMENT = new Operator("++"); static public Operator DECREMENT = new Operator("--"); static public class Operator { private String token; Operator(String theToken) { token = theToken; } public String toString() { return token; } public Operator complement() { if (this == PStarExpression.INCREMENT) return PStarExpression.DECREMENT; else if (this == PStarExpression.DECREMENT) return PStarExpression.INCREMENT; else throw new RuntimeException("Operation not supported for " + this); } } private ASTNode operand; private Operator operator;
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/PStarExpression.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * Class representing the union of pre- and post-fix expression. * @author kuehn */ public class PStarExpression extends Expression { // Operators common to both pre- and post-fix expression. static public Operator INCREMENT = new Operator("++"); static public Operator DECREMENT = new Operator("--"); static public class Operator { private String token; Operator(String theToken) { token = theToken; } public String toString() { return token; } public Operator complement() { if (this == PStarExpression.INCREMENT) return PStarExpression.DECREMENT; else if (this == PStarExpression.DECREMENT) return PStarExpression.INCREMENT; else throw new RuntimeException("Operation not supported for " + this); } } private ASTNode operand; private Operator operator;
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/ConditionalExpression.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
/* * Created on Sep 10, 2005 */ package com.j2js.dom; /** * @author wolfgang */ public class ConditionalExpression extends Expression { private Expression conditionExpression = null; private Expression thenExpression = null; private Expression elseExpression = null;
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/ConditionalExpression.java import com.j2js.visitors.AbstractVisitor; /* * Created on Sep 10, 2005 */ package com.j2js.dom; /** * @author wolfgang */ public class ConditionalExpression extends Expression { private Expression conditionExpression = null; private Expression thenExpression = null; private Expression elseExpression = null;
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/InstanceofExpression.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 27, 2005 */ public class InstanceofExpression extends Expression { private Expression leftOperand; private Type rightOperand;
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/InstanceofExpression.java import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 27, 2005 */ public class InstanceofExpression extends Expression { private Expression leftOperand; private Type rightOperand;
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/OperandState.java
// Path: src/main/java/com/j2js/dom/ASTNode.java // public class ASTNode { // // public static final int BEFORE = 0; // public static final int AFTER = 1; // public static final int SAME = 2; // public static final int CONTAINS = 3; // public static final int ISCONTAINED = 4; // // int beginIndex = Integer.MAX_VALUE; // int endIndex = Integer.MIN_VALUE; // private ASTNode parent = null; // private ASTNode previousSibling = null; // private ASTNode nextSibling = null; // // private int stackDelta = 0; // // public ASTNode() { // super(); // } // // public ASTNode(int theBeginIndex, int theEndIndex) { // setRange(theBeginIndex, theEndIndex); // } // // /** // * @return Returns the stackDelta. // */ // public int getStackDelta() { // return stackDelta; // } // // /** // * @param theStackDelta The stackDelta to set. // */ // public void setStackDelta(int theStackDelta) { // stackDelta = theStackDelta; // } // // public void widen(ASTNode node) { // leftWiden(node.beginIndex); // rightWiden(node.endIndex); // } // // public void leftWiden(int targetBeginIndex) { // if (targetBeginIndex < beginIndex) beginIndex = targetBeginIndex; // } // // public void rightWiden(int targetEndIndex) { // if (targetEndIndex > endIndex) endIndex = targetEndIndex; // } // // public void setRange(int theBeginIndex, int theEndIndex) { // setBeginIndex(theBeginIndex); // setEndIndex(theEndIndex); // } // // // private void checkRange() { // // if (endIndex!=Integer.MIN_VALUE && beginIndex!=Integer.MAX_VALUE && endIndex<beginIndex) { // // throw new RuntimeException("Begin index greater than end index: " + beginIndex + ">" + endIndex); // // } // // } // // /** Getter for property beginIndex. // * @return Value of property beginIndex. // */ // public int getBeginIndex() { // return beginIndex; // } // // /** Setter for property beginIndex. // * @param theBeginIndex New value of property beginIndex. // */ // public void setBeginIndex(int theBeginIndex) { // beginIndex = theBeginIndex; // } // // /** Getter for property endIndex. // * @return Value of property endIndex. // */ // public int getEndIndex() { // return endIndex; // } // // /** Setter for property endIndex. // * @param endIndex New value of property endIndex. // */ // public void setEndIndex(int theEndIndex) { // endIndex = theEndIndex; // } // // public boolean isRightSiblingOf(ASTNode leftSibling) { // for (ASTNode node=this; node!=null; node=node.getPreviousSibling()) { // if (node == leftSibling) { // return true; // } // } // return false; // } // // public ASTNode rightMostSibling() { // for (ASTNode node=this;;) { // if (node.getNextSibling() == null) { // return node; // } // node = node.getNextSibling(); // } // } // // public boolean isAncestorOf(ASTNode node) { // do { // node = node.getParentNode(); // if (node == this) { // return true; // } // } while (node != null); // // return false; // } // // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append(getClass().getSimpleName()); // if (getBeginIndex() != Integer.MAX_VALUE) { // sb.append("["); // sb.append(getBeginIndex()); // sb.append(", "); // sb.append(getEndIndex()); // sb.append("]"); // } // return sb.toString(); // } // // /** // * @return Returns the parent. // */ // public ASTNode getParentNode() { // return parent; // } // // public Block getParentBlock() { // return (Block) parent; // } // // public Block getLogicalParentBlock() { // if (parent != null && parent.parent instanceof IfStatement) { // return (Block) parent.parent; // } // return (Block) parent; // } // // /** // * @param theParent The parent to set. // */ // public void setParentNode(ASTNode theParent) { // parent = theParent; // } // // public void visit(AbstractVisitor visitor) { // visitor.visit(this); // } // // /** // * @return Returns the nextSibling. // */ // public ASTNode getNextSibling() { // return nextSibling; // } // /** // * @param theNextSibling The nextSibling to set. // */ // public void setNextSibling(ASTNode theNextSibling) { // nextSibling = theNextSibling; // } // /** // * @return Returns the previousSibling. // */ // public ASTNode getPreviousSibling() { // return previousSibling; // } // /** // * @param thePreviousSibling The previousSibling to set. // */ // public void setPreviousSibling(ASTNode thePreviousSibling) { // previousSibling = thePreviousSibling; // } // }
import com.j2js.dom.ASTNode;
/* * Created on 20.10.2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package com.j2js; /** * @author kuehn * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class OperandState { int code; int beginIndex; int endIndex;
// Path: src/main/java/com/j2js/dom/ASTNode.java // public class ASTNode { // // public static final int BEFORE = 0; // public static final int AFTER = 1; // public static final int SAME = 2; // public static final int CONTAINS = 3; // public static final int ISCONTAINED = 4; // // int beginIndex = Integer.MAX_VALUE; // int endIndex = Integer.MIN_VALUE; // private ASTNode parent = null; // private ASTNode previousSibling = null; // private ASTNode nextSibling = null; // // private int stackDelta = 0; // // public ASTNode() { // super(); // } // // public ASTNode(int theBeginIndex, int theEndIndex) { // setRange(theBeginIndex, theEndIndex); // } // // /** // * @return Returns the stackDelta. // */ // public int getStackDelta() { // return stackDelta; // } // // /** // * @param theStackDelta The stackDelta to set. // */ // public void setStackDelta(int theStackDelta) { // stackDelta = theStackDelta; // } // // public void widen(ASTNode node) { // leftWiden(node.beginIndex); // rightWiden(node.endIndex); // } // // public void leftWiden(int targetBeginIndex) { // if (targetBeginIndex < beginIndex) beginIndex = targetBeginIndex; // } // // public void rightWiden(int targetEndIndex) { // if (targetEndIndex > endIndex) endIndex = targetEndIndex; // } // // public void setRange(int theBeginIndex, int theEndIndex) { // setBeginIndex(theBeginIndex); // setEndIndex(theEndIndex); // } // // // private void checkRange() { // // if (endIndex!=Integer.MIN_VALUE && beginIndex!=Integer.MAX_VALUE && endIndex<beginIndex) { // // throw new RuntimeException("Begin index greater than end index: " + beginIndex + ">" + endIndex); // // } // // } // // /** Getter for property beginIndex. // * @return Value of property beginIndex. // */ // public int getBeginIndex() { // return beginIndex; // } // // /** Setter for property beginIndex. // * @param theBeginIndex New value of property beginIndex. // */ // public void setBeginIndex(int theBeginIndex) { // beginIndex = theBeginIndex; // } // // /** Getter for property endIndex. // * @return Value of property endIndex. // */ // public int getEndIndex() { // return endIndex; // } // // /** Setter for property endIndex. // * @param endIndex New value of property endIndex. // */ // public void setEndIndex(int theEndIndex) { // endIndex = theEndIndex; // } // // public boolean isRightSiblingOf(ASTNode leftSibling) { // for (ASTNode node=this; node!=null; node=node.getPreviousSibling()) { // if (node == leftSibling) { // return true; // } // } // return false; // } // // public ASTNode rightMostSibling() { // for (ASTNode node=this;;) { // if (node.getNextSibling() == null) { // return node; // } // node = node.getNextSibling(); // } // } // // public boolean isAncestorOf(ASTNode node) { // do { // node = node.getParentNode(); // if (node == this) { // return true; // } // } while (node != null); // // return false; // } // // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append(getClass().getSimpleName()); // if (getBeginIndex() != Integer.MAX_VALUE) { // sb.append("["); // sb.append(getBeginIndex()); // sb.append(", "); // sb.append(getEndIndex()); // sb.append("]"); // } // return sb.toString(); // } // // /** // * @return Returns the parent. // */ // public ASTNode getParentNode() { // return parent; // } // // public Block getParentBlock() { // return (Block) parent; // } // // public Block getLogicalParentBlock() { // if (parent != null && parent.parent instanceof IfStatement) { // return (Block) parent.parent; // } // return (Block) parent; // } // // /** // * @param theParent The parent to set. // */ // public void setParentNode(ASTNode theParent) { // parent = theParent; // } // // public void visit(AbstractVisitor visitor) { // visitor.visit(this); // } // // /** // * @return Returns the nextSibling. // */ // public ASTNode getNextSibling() { // return nextSibling; // } // /** // * @param theNextSibling The nextSibling to set. // */ // public void setNextSibling(ASTNode theNextSibling) { // nextSibling = theNextSibling; // } // /** // * @return Returns the previousSibling. // */ // public ASTNode getPreviousSibling() { // return previousSibling; // } // /** // * @param thePreviousSibling The previousSibling to set. // */ // public void setPreviousSibling(ASTNode thePreviousSibling) { // previousSibling = thePreviousSibling; // } // } // Path: src/main/java/com/j2js/OperandState.java import com.j2js.dom.ASTNode; /* * Created on 20.10.2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package com.j2js; /** * @author kuehn * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class OperandState { int code; int beginIndex; int endIndex;
ASTNode stmt;
decatur/j2js-compiler
src/main/java/com/j2js/dom/ReturnStatement.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /* * Created on Sep 12, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ /** * @author wolfgang * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class ReturnStatement extends ASTNode { private Expression expression; public ReturnStatement(int theBeginIndex, int theEndIndex) { setRange(theBeginIndex, theEndIndex); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/ReturnStatement.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /* * Created on Sep 12, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ /** * @author wolfgang * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class ReturnStatement extends ASTNode { private Expression expression; public ReturnStatement(int theBeginIndex, int theEndIndex) { setRange(theBeginIndex, theEndIndex); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/SynchronizedBlock.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
/* * Copyright 2005 by Wolfgang Kuehn * Created on 18.10.2005 */ package com.j2js.dom; /** * @author wolfgang */ public class SynchronizedBlock extends Block { public Expression monitor;
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/SynchronizedBlock.java import com.j2js.visitors.AbstractVisitor; /* * Copyright 2005 by Wolfgang Kuehn * Created on 18.10.2005 */ package com.j2js.dom; /** * @author wolfgang */ public class SynchronizedBlock extends Block { public Expression monitor;
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/ClassInstanceCreation.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import org.apache.bcel.generic.ObjectType; import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author wolfgang */ public class ClassInstanceCreation extends MethodInvocation { public ClassInstanceCreation(ObjectType theType) { type = theType; } public ClassInstanceCreation(MethodDeclaration methodDecl, MethodBinding methodBinding) { super(methodDecl, methodBinding); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/ClassInstanceCreation.java import org.apache.bcel.generic.ObjectType; import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author wolfgang */ public class ClassInstanceCreation extends MethodInvocation { public ClassInstanceCreation(ObjectType theType) { type = theType; } public ClassInstanceCreation(MethodDeclaration methodDecl, MethodBinding methodBinding) { super(methodDecl, methodBinding); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/assembly/ProcedureUnit.java
// Path: src/main/java/com/j2js/Log.java // public class Log { // // public static Log logger; // // public static Log getLogger() { // return logger; // } // // private int state = INFO; // // /** // * @return Returns the state. // */ // public int getState() { // return state; // } // // /** // * @param state The state to set. // */ // public void setState(int state) { // this.state = state; // } // // public static final int DEBUG = 3; // public static final int INFO = 2; // public static final int WARN = 1; // public static final int ERROR = 0; // // public void debug(CharSequence arg0, Throwable arg1) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // arg1.printStackTrace(); // } // } // // public void debug(CharSequence arg0) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // } // } // // public void debug(Throwable arg0) { // if (isDebugEnabled()) { // arg0.printStackTrace(); // } // } // // public void error(CharSequence arg0, Throwable arg1) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // arg1.printStackTrace(); // } // } // // public void error(CharSequence arg0) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // } // } // // public void error(Throwable arg0) { // if (isErrorEnabled()) { // arg0.printStackTrace(); // } // } // // public void info(CharSequence arg0, Throwable arg1) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // arg1.printStackTrace(); // } // } // // public void info(CharSequence arg0) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // } // } // // public void info(Throwable arg0) { // if (isInfoEnabled()) { // arg0.printStackTrace(); // } // } // // public boolean isDebugEnabled() { // return state >= DEBUG; // } // // public boolean isErrorEnabled() { // return state >= ERROR; // } // // public boolean isInfoEnabled() { // return state >= INFO; // } // // public boolean isWarnEnabled() { // return state >= WARN; // } // // public void warn(CharSequence arg0, Throwable arg1) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // arg1.printStackTrace(); // } // } // // public void warn(CharSequence arg0) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // } // } // // public void warn(Throwable arg0) { // if (isWarnEnabled()) { // arg0.printStackTrace(); // } // } // // }
import java.io.IOException; import java.io.Writer; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import com.j2js.Log;
package com.j2js.assembly; public abstract class ProcedureUnit extends MemberUnit { // Set of all member signatures targeted by this method. private Collection<Signature> targetSignatures = new HashSet<Signature>(); public ProcedureUnit(Signature theSignature, ClassUnit theDeclaringClazz) { super(theSignature, theDeclaringClazz); } public void addTarget(Signature targetSignature) { if (!targetSignature.toString().contains("#")) { throw new IllegalArgumentException("Signature must be field or method: " + targetSignature); } //Logger.getLogger().info("Adding " + this + " -> " + targetSignature); targetSignatures.add(targetSignature); } public void removeTargets() { Iterator iter = targetSignatures.iterator(); while (iter.hasNext()) { iter.next(); iter.remove(); } } void write(int depth, Writer writer) throws IOException { if (getData() == null) return;
// Path: src/main/java/com/j2js/Log.java // public class Log { // // public static Log logger; // // public static Log getLogger() { // return logger; // } // // private int state = INFO; // // /** // * @return Returns the state. // */ // public int getState() { // return state; // } // // /** // * @param state The state to set. // */ // public void setState(int state) { // this.state = state; // } // // public static final int DEBUG = 3; // public static final int INFO = 2; // public static final int WARN = 1; // public static final int ERROR = 0; // // public void debug(CharSequence arg0, Throwable arg1) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // arg1.printStackTrace(); // } // } // // public void debug(CharSequence arg0) { // if (isDebugEnabled()) { // System.out.println("[DEBUG] " + arg0); // } // } // // public void debug(Throwable arg0) { // if (isDebugEnabled()) { // arg0.printStackTrace(); // } // } // // public void error(CharSequence arg0, Throwable arg1) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // arg1.printStackTrace(); // } // } // // public void error(CharSequence arg0) { // if (isErrorEnabled()) { // System.out.println("[ERROR] " + arg0); // } // } // // public void error(Throwable arg0) { // if (isErrorEnabled()) { // arg0.printStackTrace(); // } // } // // public void info(CharSequence arg0, Throwable arg1) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // arg1.printStackTrace(); // } // } // // public void info(CharSequence arg0) { // if (isInfoEnabled()) { // System.out.println("[INFO] " + arg0); // } // } // // public void info(Throwable arg0) { // if (isInfoEnabled()) { // arg0.printStackTrace(); // } // } // // public boolean isDebugEnabled() { // return state >= DEBUG; // } // // public boolean isErrorEnabled() { // return state >= ERROR; // } // // public boolean isInfoEnabled() { // return state >= INFO; // } // // public boolean isWarnEnabled() { // return state >= WARN; // } // // public void warn(CharSequence arg0, Throwable arg1) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // arg1.printStackTrace(); // } // } // // public void warn(CharSequence arg0) { // if (isWarnEnabled()) { // System.out.println("[WARNING] " + arg0); // } // } // // public void warn(Throwable arg0) { // if (isWarnEnabled()) { // arg0.printStackTrace(); // } // } // // } // Path: src/main/java/com/j2js/assembly/ProcedureUnit.java import java.io.IOException; import java.io.Writer; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import com.j2js.Log; package com.j2js.assembly; public abstract class ProcedureUnit extends MemberUnit { // Set of all member signatures targeted by this method. private Collection<Signature> targetSignatures = new HashSet<Signature>(); public ProcedureUnit(Signature theSignature, ClassUnit theDeclaringClazz) { super(theSignature, theDeclaringClazz); } public void addTarget(Signature targetSignature) { if (!targetSignature.toString().contains("#")) { throw new IllegalArgumentException("Signature must be field or method: " + targetSignature); } //Logger.getLogger().info("Adding " + this + " -> " + targetSignature); targetSignatures.add(targetSignature); } public void removeTargets() { Iterator iter = targetSignatures.iterator(); while (iter.hasNext()) { iter.next(); iter.remove(); } } void write(int depth, Writer writer) throws IOException { if (getData() == null) return;
Log.getLogger().debug(getIndent(depth) + getSignature());
decatur/j2js-compiler
src/main/java/com/j2js/dom/ContinueStatement.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; public class ContinueStatement extends LabeledJump { public ContinueStatement(Block block) { super(block); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/ContinueStatement.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; public class ContinueStatement extends LabeledJump { public ContinueStatement(Block block) { super(block); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/IfStatement.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author kuehn */ public class IfStatement extends Block { public IfStatement() { super(); } public Expression getExpression() { return (Expression) getChildAt(0); } public void setExpression(Expression expression) { widen(expression); setChildAt(0, expression); } public Block getIfBlock() { return (Block) getChildAt(1); } public void setIfBlock(Block block) { widen(block); setChildAt(1, block); } public Block getElseBlock() { if (getChildCount() < 3) return null; return (Block) getChildAt(2); } public void setElseBlock(Block block) { widen(block); setChildAt(2, block); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/IfStatement.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author kuehn */ public class IfStatement extends Block { public IfStatement() { super(); } public Expression getExpression() { return (Expression) getChildAt(0); } public void setExpression(Expression expression) { widen(expression); setChildAt(0, expression); } public Block getIfBlock() { return (Block) getChildAt(1); } public void setIfBlock(Block block) { widen(block); setChildAt(1, block); } public Block getElseBlock() { if (getChildCount() < 3) return null; return (Block) getChildAt(2); } public void setElseBlock(Block block) { widen(block); setChildAt(2, block); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/InfixExpression.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
CONDITIONAL_OR.complement = CONDITIONAL_AND; } private String token; private Operator complement; Operator(String theToken) { token = theToken; } public String toString() { return token; } /** * @return Returns the complement. */ public Operator getComplement() { return complement; } } private Operator operator; public InfixExpression(Operator op) { super(); operator = op; if (operator.getComplement() != null) type = org.apache.bcel.generic.Type.BOOLEAN; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/InfixExpression.java import com.j2js.visitors.AbstractVisitor; CONDITIONAL_OR.complement = CONDITIONAL_AND; } private String token; private Operator complement; Operator(String theToken) { token = theToken; } public String toString() { return token; } /** * @return Returns the complement. */ public Operator getComplement() { return complement; } } private Operator operator; public InfixExpression(Operator op) { super(); operator = op; if (operator.getComplement() != null) type = org.apache.bcel.generic.Type.BOOLEAN; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/CastExpression.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author kuehn */ public class CastExpression extends Expression { private Expression expression;
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/CastExpression.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author kuehn */ public class CastExpression extends Expression { private Expression expression;
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/StringLiteral.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /** * @author wolfgang */ public class StringLiteral extends Expression { private String value; public StringLiteral(String theValue) { value = theValue; type = Type.STRING; }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/StringLiteral.java import org.apache.bcel.generic.Type; import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /** * @author wolfgang */ public class StringLiteral extends Expression { private String value; public StringLiteral(String theValue) { value = theValue; type = Type.STRING; }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/CatchClause.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /* * CatchStatement.java * * Created on 22. Mai 2004, 22:49 */ /** * * @author kuehn */ public class CatchClause extends Block { private VariableDeclaration exception; /** Creates a new instance of CatchStatement */ //public CatchStatement() { //} public CatchClause(int theBeginIndex) { super(theBeginIndex); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/CatchClause.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /* * CatchStatement.java * * Created on 22. Mai 2004, 22:49 */ /** * * @author kuehn */ public class CatchClause extends Block { private VariableDeclaration exception; /** Creates a new instance of CatchStatement */ //public CatchStatement() { //} public CatchClause(int theBeginIndex) { super(theBeginIndex); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/FieldRead.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; public class FieldRead extends FieldAccess { public FieldRead() { }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/FieldRead.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; public class FieldRead extends FieldAccess { public FieldRead() { }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/FieldWrite.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; public class FieldWrite extends FieldAccess implements Assignable { public FieldWrite() { }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/FieldWrite.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; public class FieldWrite extends FieldAccess implements Assignable { public FieldWrite() { }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/DoStatement.java
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // }
import com.j2js.visitors.AbstractVisitor;
package com.j2js.dom; /* * DoStatement.java * * Created on 21. Mai 2004, 17:30 */ /** * * @author kuehn */ public class DoStatement extends LoopStatement { public DoStatement() { super(); } public DoStatement(int theBeginIndex) { super(theBeginIndex); } public DoStatement(int theBeginIndex, int theEndIndex) { super(theBeginIndex, theEndIndex); }
// Path: src/main/java/com/j2js/visitors/AbstractVisitor.java // public abstract class AbstractVisitor { // // // public abstract void visit(ASTNode node); // // public void visit(TypeDeclaration node) { // visit((ASTNode) node); // } // // public void visit(MethodDeclaration node) { // visit((ASTNode) node); // } // // public void visit(DoStatement node) { // visit((ASTNode) node); // } // // public void visit(WhileStatement node) { // visit((ASTNode) node); // } // // public void visit(IfStatement node) { // visit((ASTNode) node); // } // // public void visit(TryStatement node) { // visit((ASTNode) node); // } // // public void visit(Block node) { // visit((ASTNode) node); // } // // public void visit(InfixExpression node) { // visit((ASTNode) node); // } // // public void visit(PrefixExpression node) { // visit((ASTNode) node); // } // // public void visit(PostfixExpression node) { // visit((ASTNode) node); // } // // public void visit(SwitchStatement node) { // visit((ASTNode) node); // } // // public void visit(SwitchCase node) { // visit((ASTNode) node); // } // // public void visit(CatchClause node) { // visit((ASTNode) node); // } // // public void visit(ReturnStatement node) { // visit((ASTNode) node); // } // // public void visit(Assignment node) { // visit((ASTNode) node); // } // // public void visit(NumberLiteral node) { // visit((ASTNode) node); // } // // public void visit(StringLiteral node) { // visit((ASTNode) node); // } // // public void visit(ClassLiteral node) { // visit((ASTNode) node); // } // // public void visit(NullLiteral node) { // visit((ASTNode) node); // } // // public void visit(MethodInvocation node) { // visit((ASTNode) node); // } // // public void visit(ClassInstanceCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayInitializer node) { // visit((ASTNode) node); // } // // public void visit(ArrayCreation node) { // visit((ASTNode) node); // } // // public void visit(ArrayAccess node) { // visit((ASTNode) node); // } // // public void visit(VariableDeclaration node) { // visit((ASTNode) node); // } // // public void visit(VariableBinding node) { // visit((ASTNode) node); // } // // public void visit(ThisExpression node) { // visit((ASTNode) node); // } // // public void visit(FieldAccess node) { // visit((ASTNode) node); // } // // public void visit(BreakStatement node) { // visit((ASTNode) node); // } // // public void visit(ContinueStatement node) { // visit((ASTNode) node); // } // // public void visit(CastExpression node) { // visit((ASTNode) node); // } // // public void visit(BooleanLiteral node) { // visit((ASTNode) node); // } // // public void visit(ThrowStatement node) { // visit((ASTNode) node); // } // // public void visit(Name node) { // visit((ASTNode) node); // } // // public void visit(InstanceofExpression node) { // visit((ASTNode) node); // } // // public void visit(ConditionalExpression node) { // visit((ASTNode) node); // } // // public void visit(SynchronizedBlock node) { // visit((ASTNode) node); // } // // public void visit(PrimitiveCast node) { // visit((ASTNode) node); // } // // } // Path: src/main/java/com/j2js/dom/DoStatement.java import com.j2js.visitors.AbstractVisitor; package com.j2js.dom; /* * DoStatement.java * * Created on 21. Mai 2004, 17:30 */ /** * * @author kuehn */ public class DoStatement extends LoopStatement { public DoStatement() { super(); } public DoStatement(int theBeginIndex) { super(theBeginIndex); } public DoStatement(int theBeginIndex, int theEndIndex) { super(theBeginIndex, theEndIndex); }
public void visit(AbstractVisitor visitor) {
decatur/j2js-compiler
src/main/java/com/j2js/dom/Expression.java
// Path: src/main/java/com/j2js/Form.java // public class Form { // // public static int CATEGORY1 = 1; // public static int CATEGORY2 = 2; // // public static class Value { // public String type; // public String name; // // public Value(String theType, String theName) { // type = theType; // name = theName; // } // // public int getCategory() { // return type.equals("cat2") || type.equals("long") || type.equals("double")?CATEGORY2:CATEGORY1; // } // } // // private int index; // private Form.Value[] ins; // private Form.Value[] outs; // private Form.Value[] operands; // private Type type; // // /** // * @return Returns the ins. // */ // public Form.Value[] getIns() { // return ins; // } // // /** // * @param theIns The ins to set. // */ // public void setIns(Form.Value[] theIns) { // ins = theIns; // } // // /** // * @return Returns the operands. // */ // public Form.Value[] getOperands() { // return operands; // } // // /** // * @param theOperands The operands to set. // */ // public void setOperands(Form.Value[] theOperands) { // operands = theOperands; // } // // /** // * @return Returns the outs. // */ // public Form.Value[] getOuts() { // return outs; // } // // /** // * @param theOuts The outs to set. // */ // public void setOuts(Form.Value[] theOuts) { // outs = theOuts; // // if (theOuts.length != 1) return; // // String s = theOuts[0].type; // if (s.equals("object")) type = Type.OBJECT; // else if (s.equals("int")) type = Type.INT; // else if (s.equals("short")) type = Type.SHORT; // else if (s.equals("byte")) type = Type.SHORT; // else if (s.equals("long")) type = Type.LONG; // else if (s.equals("float")) type = Type.FLOAT; // else if (s.equals("double")) type = Type.DOUBLE; // else if (!s.equals("cat1") && !s.equals("returnAddress") && !s.equals("")) // throw new RuntimeException("Unhandled type: " + s); // } // // public int getOpStackDelta() { // return getOuts().length - getIns().length; // } // // public Type getResultType() { // if (type == null) throw new RuntimeException("Result type is not available for " + this); // // return type; // } // /** // * @return Returns the index. // */ // public int getIndex() { // return index; // } // /** // * @param theIndex The index to set. // */ // public void setIndex(int theIndex) { // index = theIndex; // } // }
import org.apache.bcel.generic.Type; import com.j2js.Form;
package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 17, 2005 */ public class Expression extends Block implements Cloneable { Type type = Type.UNKNOWN; public Expression() { super(); } public Expression(int theBeginIndex, int theEndIndex) { super(theBeginIndex, theEndIndex); } public Object clone() { if (getChildCount() > 0) throw new RuntimeException("Cannot clone expression with children"); ASTNode node; try { node = (ASTNode) super.clone(); } catch (CloneNotSupportedException e) { return null; } node.setParentNode(null); node.setPreviousSibling(null); node.setNextSibling(null); return node; } public Type getTypeBinding() { return type; } public void setTypeBinding(Type theType) { type = theType; } public int getCategory() {
// Path: src/main/java/com/j2js/Form.java // public class Form { // // public static int CATEGORY1 = 1; // public static int CATEGORY2 = 2; // // public static class Value { // public String type; // public String name; // // public Value(String theType, String theName) { // type = theType; // name = theName; // } // // public int getCategory() { // return type.equals("cat2") || type.equals("long") || type.equals("double")?CATEGORY2:CATEGORY1; // } // } // // private int index; // private Form.Value[] ins; // private Form.Value[] outs; // private Form.Value[] operands; // private Type type; // // /** // * @return Returns the ins. // */ // public Form.Value[] getIns() { // return ins; // } // // /** // * @param theIns The ins to set. // */ // public void setIns(Form.Value[] theIns) { // ins = theIns; // } // // /** // * @return Returns the operands. // */ // public Form.Value[] getOperands() { // return operands; // } // // /** // * @param theOperands The operands to set. // */ // public void setOperands(Form.Value[] theOperands) { // operands = theOperands; // } // // /** // * @return Returns the outs. // */ // public Form.Value[] getOuts() { // return outs; // } // // /** // * @param theOuts The outs to set. // */ // public void setOuts(Form.Value[] theOuts) { // outs = theOuts; // // if (theOuts.length != 1) return; // // String s = theOuts[0].type; // if (s.equals("object")) type = Type.OBJECT; // else if (s.equals("int")) type = Type.INT; // else if (s.equals("short")) type = Type.SHORT; // else if (s.equals("byte")) type = Type.SHORT; // else if (s.equals("long")) type = Type.LONG; // else if (s.equals("float")) type = Type.FLOAT; // else if (s.equals("double")) type = Type.DOUBLE; // else if (!s.equals("cat1") && !s.equals("returnAddress") && !s.equals("")) // throw new RuntimeException("Unhandled type: " + s); // } // // public int getOpStackDelta() { // return getOuts().length - getIns().length; // } // // public Type getResultType() { // if (type == null) throw new RuntimeException("Result type is not available for " + this); // // return type; // } // /** // * @return Returns the index. // */ // public int getIndex() { // return index; // } // /** // * @param theIndex The index to set. // */ // public void setIndex(int theIndex) { // index = theIndex; // } // } // Path: src/main/java/com/j2js/dom/Expression.java import org.apache.bcel.generic.Type; import com.j2js.Form; package com.j2js.dom; /** * Copyright by Wolfgang Kuehn 2005 * Created on Feb 17, 2005 */ public class Expression extends Block implements Cloneable { Type type = Type.UNKNOWN; public Expression() { super(); } public Expression(int theBeginIndex, int theEndIndex) { super(theBeginIndex, theEndIndex); } public Object clone() { if (getChildCount() > 0) throw new RuntimeException("Cannot clone expression with children"); ASTNode node; try { node = (ASTNode) super.clone(); } catch (CloneNotSupportedException e) { return null; } node.setParentNode(null); node.setPreviousSibling(null); node.setNextSibling(null); return node; } public Type getTypeBinding() { return type; } public void setTypeBinding(Type theType) { type = theType; } public int getCategory() {
if (getTypeBinding().getType() == Type.LONG.getType()) return Form.CATEGORY2;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerMVCIntegrationTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailControllerMVCIntegrationTest { @Autowired
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerMVCIntegrationTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailControllerMVCIntegrationTest { @Autowired
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerMVCIntegrationTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailControllerMVCIntegrationTest { @Autowired private EmailRepository emailRepository; @Autowired private MockMvc mockMvc; @BeforeEach void init(){ emailRepository.deleteAll(); } @Test void shouldReturnEmptyListWhenNoEmailsAreAvailable() throws Exception { this.mockMvc.perform(get("/email?page")) .andExpect(status().isOk())
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerMVCIntegrationTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailControllerMVCIntegrationTest { @Autowired private EmailRepository emailRepository; @Autowired private MockMvc mockMvc; @BeforeEach void init(){ emailRepository.deleteAll(); } @Test void shouldReturnEmptyListWhenNoEmailsAreAvailable() throws Exception { this.mockMvc.perform(get("/email?page")) .andExpect(status().isOk())
.andExpect(model().attribute("mails", emptyIterableOf(Email.class)))
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimer.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional;
package de.gessnerfl.fakesmtp.service; @Service @Transactional(propagation = Propagation.REQUIRES_NEW) public class EmailRetentionTimer {
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/main/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimer.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; package de.gessnerfl.fakesmtp.service; @Service @Transactional(propagation = Propagation.REQUIRES_NEW) public class EmailRetentionTimer {
private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimer.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional;
package de.gessnerfl.fakesmtp.service; @Service @Transactional(propagation = Propagation.REQUIRES_NEW) public class EmailRetentionTimer { private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/main/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimer.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; package de.gessnerfl.fakesmtp.service; @Service @Transactional(propagation = Propagation.REQUIRES_NEW) public class EmailRetentionTimer { private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
private final EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatcher; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; import java.util.Optional; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.controller; @ExtendWith(MockitoExtension.class) class EmailControllerTest { @Mock private Model model; @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatcher; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; import java.util.Optional; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.controller; @ExtendWith(MockitoExtension.class) class EmailControllerTest { @Mock private Model model; @Mock
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatcher; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; import java.util.Optional; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.controller; @ExtendWith(MockitoExtension.class) class EmailControllerTest { @Mock private Model model; @Mock private EmailRepository emailRepository; @Mock private BuildProperties buildProperties; @InjectMocks private EmailController sut; @Test void shouldReturnEmailsPaged() { final String appVersion = "appVersion";
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/controller/EmailControllerTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatcher; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.ui.Model; import java.util.Optional; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.controller; @ExtendWith(MockitoExtension.class) class EmailControllerTest { @Mock private Model model; @Mock private EmailRepository emailRepository; @Mock private BuildProperties buildProperties; @InjectMocks private EmailController sut; @Test void shouldReturnEmailsPaged() { final String appVersion = "appVersion";
final Page<Email> page = createFirstPageEmail();
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageForwarderTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.springframework.mail.SimpleMailMessage; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageForwarderTest { @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageForwarderTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.springframework.mail.SimpleMailMessage; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageForwarderTest { @Mock
private FakeSmtpConfigurationProperties configurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerConfiguratorTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.subethamail.smtp.AuthenticationHandlerFactory; import org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory; import org.subethamail.smtp.server.SMTPServer; import java.net.InetAddress; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.instanceOf; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class SmtpServerConfiguratorTest { @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerConfiguratorTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import org.subethamail.smtp.AuthenticationHandlerFactory; import org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory; import org.subethamail.smtp.server.SMTPServer; import java.net.InetAddress; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.instanceOf; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class SmtpServerConfiguratorTest { @Mock
private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/controller/EmailRestControllerMVCIntegrationTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import com.fasterxml.jackson.databind.ObjectMapper; import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailRestControllerMVCIntegrationTest { @Autowired
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/controller/EmailRestControllerMVCIntegrationTest.java import com.fasterxml.jackson.databind.ObjectMapper; import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; package de.gessnerfl.fakesmtp.controller; @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest @AutoConfigureMockMvc class EmailRestControllerMVCIntegrationTest { @Autowired
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/BasicUsernamePasswordValidator.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.subethamail.smtp.auth.LoginFailedException; import org.subethamail.smtp.auth.UsernamePasswordValidator;
package de.gessnerfl.fakesmtp.server.impl; @Service public class BasicUsernamePasswordValidator implements UsernamePasswordValidator {
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/BasicUsernamePasswordValidator.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.subethamail.smtp.auth.LoginFailedException; import org.subethamail.smtp.auth.UsernamePasswordValidator; package de.gessnerfl.fakesmtp.server.impl; @Service public class BasicUsernamePasswordValidator implements UsernamePasswordValidator {
private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/EmailFilterTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class EmailFilterTest { private static final String TEST_EMAIL_ADDRESS_1 = "john@doe.com"; private static final String TEST_EMAIL_ADDRESS_2 = "jane@doe.com"; @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/EmailFilterTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class EmailFilterTest { private static final String TEST_EMAIL_ADDRESS_1 = "john@doe.com"; private static final String TEST_EMAIL_ADDRESS_2 = "jane@doe.com"; @Mock
private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerFactoryImpl.java
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // }
import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import org.subethamail.smtp.helper.SimpleMessageListenerAdapter; import org.subethamail.smtp.server.SMTPServer;
package de.gessnerfl.fakesmtp.server.impl; @Profile("default") @Service
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerFactoryImpl.java import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import org.subethamail.smtp.helper.SimpleMessageListenerAdapter; import org.subethamail.smtp.server.SMTPServer; package de.gessnerfl.fakesmtp.server.impl; @Profile("default") @Service
public class SmtpServerFactoryImpl implements SmtpServerFactory {
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerFactoryImpl.java
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // }
import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import org.subethamail.smtp.helper.SimpleMessageListenerAdapter; import org.subethamail.smtp.server.SMTPServer;
package de.gessnerfl.fakesmtp.server.impl; @Profile("default") @Service public class SmtpServerFactoryImpl implements SmtpServerFactory { private final MessageListener messageListener; private final SmtpServerConfigurator configurator; @Autowired public SmtpServerFactoryImpl(MessageListener messageListener, SmtpServerConfigurator configurator) { this.messageListener = messageListener; this.configurator = configurator; } @Override
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerFactoryImpl.java import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import org.subethamail.smtp.helper.SimpleMessageListenerAdapter; import org.subethamail.smtp.server.SMTPServer; package de.gessnerfl.fakesmtp.server.impl; @Profile("default") @Service public class SmtpServerFactoryImpl implements SmtpServerFactory { private final MessageListener messageListener; private final SmtpServerConfigurator configurator; @Autowired public SmtpServerFactoryImpl(MessageListener messageListener, SmtpServerConfigurator configurator) { this.messageListener = messageListener; this.configurator = configurator; } @Override
public SmtpServer create() {
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerConfigurator.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory; import org.subethamail.smtp.server.SMTPServer;
package de.gessnerfl.fakesmtp.server.impl; @Service public class SmtpServerConfigurator {
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/SmtpServerConfigurator.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory; import org.subethamail.smtp.server.SMTPServer; package de.gessnerfl.fakesmtp.server.impl; @Service public class SmtpServerConfigurator {
private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List;
package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn";
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // } // Path: src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List; package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn";
private final EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List;
package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn"; private final EmailRepository emailRepository;
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // } // Path: src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List; package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn"; private final EmailRepository emailRepository;
private final EmailAttachmentRepository emailAttachmentRepository;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List;
package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn"; private final EmailRepository emailRepository; private final EmailAttachmentRepository emailAttachmentRepository;
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailAttachmentRepository.java // @Repository // public interface EmailAttachmentRepository extends JpaRepository<EmailAttachment,Long> { // // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/util/MediaTypeUtil.java // @Service // public class MediaTypeUtil { // // public MediaType getMediaTypeForFileName(ServletContext servletContext, String fileName) { // var mineType = servletContext.getMimeType(fileName); // try { // return MediaType.parseMediaType(mineType); // } catch (Exception e) { // return MediaType.APPLICATION_OCTET_STREAM; // } // } // // } // Path: src/main/java/de/gessnerfl/fakesmtp/controller/EmailRestController.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailAttachmentRepository; import de.gessnerfl.fakesmtp.repository.EmailRepository; import de.gessnerfl.fakesmtp.util.MediaTypeUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.ServletContext; import javax.validation.constraints.Min; import java.util.Collections; import java.util.List; package de.gessnerfl.fakesmtp.controller; @RestController @RequestMapping("/api") @Validated public class EmailRestController { private static final int DEFAULT_PAGE_SIZE = 10; private static final String DEFAULT_SORT_PROPERTY = "receivedOn"; private final EmailRepository emailRepository; private final EmailAttachmentRepository emailAttachmentRepository;
private final MediaTypeUtil mediaTypeUtil;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.service; @ExtendWith(MockitoExtension.class) class EmailRetentionTimerTest { @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimerTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.service; @ExtendWith(MockitoExtension.class) class EmailRetentionTimerTest { @Mock
private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.service; @ExtendWith(MockitoExtension.class) class EmailRetentionTimerTest { @Mock private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties; @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/service/EmailRetentionTimerTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.service; @ExtendWith(MockitoExtension.class) class EmailRetentionTimerTest { @Mock private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties; @Mock
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/BasicUsernamePasswordValidatorTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.subethamail.smtp.auth.LoginFailedException; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class BasicUsernamePasswordValidatorTest { @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/BasicUsernamePasswordValidatorTest.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.subethamail.smtp.auth.LoginFailedException; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class BasicUsernamePasswordValidatorTest { @Mock
private FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/RawDataTest.java
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // }
import de.gessnerfl.fakesmtp.TestResourceUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import javax.mail.internet.MimeMessage;
package de.gessnerfl.fakesmtp.server.impl; class RawDataTest { @Test void shouldReturnMimeMessage() throws Exception {
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/RawDataTest.java import de.gessnerfl.fakesmtp.TestResourceUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import javax.mail.internet.MimeMessage; package de.gessnerfl.fakesmtp.server.impl; class RawDataTest { @Test void shouldReturnMimeMessage() throws Exception {
RawData sut = new RawData("from", "to", TestResourceUtil.getTestFileContentBytes(("mail-with-subject.eml")));
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/MessageListener.java
// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.subethamail.smtp.helper.SimpleMessageListener; import java.io.IOException; import java.io.InputStream;
package de.gessnerfl.fakesmtp.server.impl; @Service @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = IOException.class) public class MessageListener implements SimpleMessageListener { private final EmailFactory emailFactory; private final EmailFilter emailFilter;
// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/MessageListener.java import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.subethamail.smtp.helper.SimpleMessageListener; import java.io.IOException; import java.io.InputStream; package de.gessnerfl.fakesmtp.server.impl; @Service @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = IOException.class) public class MessageListener implements SimpleMessageListener { private final EmailFactory emailFactory; private final EmailFilter emailFilter;
private final EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/MessageForwarder.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.SimpleMailMessage; import org.springframework.stereotype.Service; import javax.mail.MessagingException;
package de.gessnerfl.fakesmtp.server.impl; @Service public class MessageForwarder {
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/MessageForwarder.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.SimpleMailMessage; import org.springframework.stereotype.Service; import javax.mail.MessagingException; package de.gessnerfl.fakesmtp.server.impl; @Service public class MessageForwarder {
private final FakeSmtpConfigurationProperties configurationProperties;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/server/impl/EmailFilter.java
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // }
import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import java.util.Arrays; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils;
package de.gessnerfl.fakesmtp.server.impl; @Service public class EmailFilter {
// Path: src/main/java/de/gessnerfl/fakesmtp/config/FakeSmtpConfigurationProperties.java // @Component // @ConfigurationProperties(prefix = "fakesmtp") // public class FakeSmtpConfigurationProperties { // // private static final int DEFAULT_PORT = 25; // // @NotNull // private Integer port = DEFAULT_PORT; // private InetAddress bindAddress; // private Authentication authentication; // private String filteredEmailRegexList; // private boolean forwardEmails = false; // // @NotNull // private Persistence persistence = new Persistence(); // // public Integer getPort() { // return port; // } // // public void setPort(Integer port) { // this.port = port; // } // // public InetAddress getBindAddress() { // return bindAddress; // } // // public void setBindAddress(InetAddress bindAddress) { // this.bindAddress = bindAddress; // } // // public Authentication getAuthentication() { // return authentication; // } // // public void setAuthentication(Authentication authentication) { // this.authentication = authentication; // } // // public Persistence getPersistence() { // return persistence; // } // // public void setPersistence(Persistence persistence) { // this.persistence = persistence; // } // // public String getFilteredEmailRegexList() { // return filteredEmailRegexList; // } // // public void setFilteredEmailRegexList(String filteredEmailRegexList) { // this.filteredEmailRegexList = filteredEmailRegexList; // } // // public boolean isForwardEmails() { // return forwardEmails; // } // // public void setForwardEmails(boolean forwardEmails) { // this.forwardEmails = forwardEmails; // } // // public static class Authentication { // @NotNull // private String username; // @NotNull // private String password; // // public String getUsername() { // return username; // } // // public void setUsername(String username) { // this.username = username; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // } // // public static class Persistence { // static final int DEFAULT_MAX_NUMBER_EMAILS = 100; // // @NotNull // private Integer maxNumberEmails = DEFAULT_MAX_NUMBER_EMAILS; // // public Integer getMaxNumberEmails() { // return maxNumberEmails; // } // // public void setMaxNumberEmails(Integer maxNumberEmails) { // this.maxNumberEmails = maxNumberEmails; // } // } // } // Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/EmailFilter.java import de.gessnerfl.fakesmtp.config.FakeSmtpConfigurationProperties; import java.util.Arrays; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; package de.gessnerfl.fakesmtp.server.impl; @Service public class EmailFilter {
private final FakeSmtpConfigurationProperties fakeSmtpConfigurationProperties;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageListenerTest { @Mock private EmailFactory emailFactory; @Mock private EmailFilter emailFilter; @Mock
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageListenerTest { @Mock private EmailFactory emailFactory; @Mock private EmailFilter emailFilter; @Mock
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerTest.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*;
package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageListenerTest { @Mock private EmailFactory emailFactory; @Mock private EmailFilter emailFilter; @Mock private EmailRepository emailRepository; @Mock private MessageForwarder messageForwarder; @Mock private Logger logger; @InjectMocks private MessageListener sut; @Test void shouldAcceptAllMails(){ assertTrue(sut.accept("foo", "bar")); } @Test void shouldCreateEmailEntityAndStoreItInDatabaseWhenEmailIsDelivered() throws IOException { var from = "from"; var to = "to"; var contentString = "content"; var content = contentString.getBytes(StandardCharsets.UTF_8); var contentStream = new ByteArrayInputStream(content);
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerTest.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.slf4j.Logger; import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; package de.gessnerfl.fakesmtp.server.impl; @ExtendWith(MockitoExtension.class) class MessageListenerTest { @Mock private EmailFactory emailFactory; @Mock private EmailFilter emailFilter; @Mock private EmailRepository emailRepository; @Mock private MessageForwarder messageForwarder; @Mock private Logger logger; @InjectMocks private MessageListener sut; @Test void shouldAcceptAllMails(){ assertTrue(sut.accept("foo", "bar")); } @Test void shouldCreateEmailEntityAndStoreItInDatabaseWhenEmailIsDelivered() throws IOException { var from = "from"; var to = "to"; var contentString = "content"; var content = contentString.getBytes(StandardCharsets.UTF_8); var contentStream = new ByteArrayInputStream(content);
var mail = mock(Email.class);
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MockSmtpServerFactory.java
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // }
import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import static org.mockito.Mockito.mock;
package de.gessnerfl.fakesmtp.server.impl; @Profile("integrationtest") @Service
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MockSmtpServerFactory.java import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import static org.mockito.Mockito.mock; package de.gessnerfl.fakesmtp.server.impl; @Profile("integrationtest") @Service
public class MockSmtpServerFactory implements SmtpServerFactory {
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MockSmtpServerFactory.java
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // }
import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import static org.mockito.Mockito.mock;
package de.gessnerfl.fakesmtp.server.impl; @Profile("integrationtest") @Service public class MockSmtpServerFactory implements SmtpServerFactory { @Override
// Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServer.java // public interface SmtpServer { // void start(); // void stop(); // } // // Path: src/main/java/de/gessnerfl/fakesmtp/server/SmtpServerFactory.java // public interface SmtpServerFactory { // SmtpServer create(); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MockSmtpServerFactory.java import de.gessnerfl.fakesmtp.server.SmtpServer; import de.gessnerfl.fakesmtp.server.SmtpServerFactory; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import static org.mockito.Mockito.mock; package de.gessnerfl.fakesmtp.server.impl; @Profile("integrationtest") @Service public class MockSmtpServerFactory implements SmtpServerFactory { @Override
public SmtpServer create() {
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerIntegrationTest.java
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.TestResourceUtil; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.transaction.Transactional; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.*;
package de.gessnerfl.fakesmtp.server.impl; @Transactional @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest class MessageListenerIntegrationTest { private static final String SENDER = "sender"; private static final String RECEIVER = "receiver"; @Autowired
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerIntegrationTest.java import de.gessnerfl.fakesmtp.TestResourceUtil; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.transaction.Transactional; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.*; package de.gessnerfl.fakesmtp.server.impl; @Transactional @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest class MessageListenerIntegrationTest { private static final String SENDER = "sender"; private static final String RECEIVER = "receiver"; @Autowired
private EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerIntegrationTest.java
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.TestResourceUtil; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.transaction.Transactional; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.*;
package de.gessnerfl.fakesmtp.server.impl; @Transactional @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest class MessageListenerIntegrationTest { private static final String SENDER = "sender"; private static final String RECEIVER = "receiver"; @Autowired private EmailRepository emailRepository; @Autowired private MessageListener sut; @BeforeEach void setup(){ emailRepository.deleteAll(); } @Test void shouldCreateEmailForEmlFileWithSubject() throws Exception { var testFilename = "mail-with-subject.eml";
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java // public class TestResourceUtil { // private static final String TEST_DATA_FOLDER = "/test-data/"; // // public static String getTestFileContent(String testFilename) throws IOException { // return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8); // } // // public static byte[] getTestFileContentBytes(String testFilename) throws IOException { // return IOUtils.toByteArray(getTestFile(testFilename)); // } // // public static InputStream getTestFile(String filename) { // var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename); // if (stream == null) { // stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename); // } // assertNotNull(stream); // return stream; // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerIntegrationTest.java import de.gessnerfl.fakesmtp.TestResourceUtil; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit.jupiter.SpringExtension; import javax.transaction.Transactional; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.hasSize; import static org.junit.jupiter.api.Assertions.*; package de.gessnerfl.fakesmtp.server.impl; @Transactional @ActiveProfiles("integrationtest") @ExtendWith(SpringExtension.class) @SpringBootTest class MessageListenerIntegrationTest { private static final String SENDER = "sender"; private static final String RECEIVER = "receiver"; @Autowired private EmailRepository emailRepository; @Autowired private MessageListener sut; @BeforeEach void setup(){ emailRepository.deleteAll(); } @Test void shouldCreateEmailForEmlFileWithSubject() throws Exception { var testFilename = "mail-with-subject.eml";
var data = TestResourceUtil.getTestFile(testFilename);
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/controller/EmailController.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*;
package de.gessnerfl.fakesmtp.controller; @Controller @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) public class EmailController { private static final Sort DEFAULT_SORT = Sort.by(Sort.Direction.DESC, "receivedOn"); private static final int DEFAULT_PAGE_SIZE = 10; static final String APP_VERSION_MODEL_NAME = "appVersion"; static final String EMAIL_LIST_VIEW = "email-list"; static final String EMAIL_LIST_MODEL_NAME = "mails"; static final String SINGLE_EMAIL_VIEW = "email"; static final String SINGLE_EMAIL_MODEL_NAME = "mail"; static final String REDIRECT_EMAIL_LIST_VIEW = "redirect:/email";
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/main/java/de/gessnerfl/fakesmtp/controller/EmailController.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; package de.gessnerfl.fakesmtp.controller; @Controller @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) public class EmailController { private static final Sort DEFAULT_SORT = Sort.by(Sort.Direction.DESC, "receivedOn"); private static final int DEFAULT_PAGE_SIZE = 10; static final String APP_VERSION_MODEL_NAME = "appVersion"; static final String EMAIL_LIST_VIEW = "email-list"; static final String EMAIL_LIST_MODEL_NAME = "mails"; static final String SINGLE_EMAIL_VIEW = "email"; static final String SINGLE_EMAIL_MODEL_NAME = "mail"; static final String REDIRECT_EMAIL_LIST_VIEW = "redirect:/email";
private final EmailRepository emailRepository;
gessnerfl/fake-smtp-server
src/main/java/de/gessnerfl/fakesmtp/controller/EmailController.java
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // }
import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*;
@Autowired public EmailController(EmailRepository emailRepository, BuildProperties buildProperties) { this.emailRepository = emailRepository; this.buildProperties = buildProperties; } @GetMapping({"/", "/email"}) public String getAll(@RequestParam(value = "page", defaultValue = "0") int page, @RequestParam(value = "size", defaultValue = "" + DEFAULT_PAGE_SIZE) int size, Model model) { return getAllEmailsPaged(page, size, model); } private String getAllEmailsPaged(int page, int size, Model model) { if(page < 0 || size <= 0){ return REDIRECT_EMAIL_LIST_VIEW; } var result = emailRepository.findAll(PageRequest.of(page, size, DEFAULT_SORT)); if (result.getNumber() != 0 && result.getNumber() >= result.getTotalPages()) { return REDIRECT_EMAIL_LIST_VIEW; } model.addAttribute(EMAIL_LIST_MODEL_NAME, result); addApplicationVersion(model); return EMAIL_LIST_VIEW; } @GetMapping("/email/{id}") public String getEmailById(@PathVariable Long id, Model model) { return emailRepository.findById(id).map(email -> appendToModelAndReturnView(model, email)).orElse(REDIRECT_EMAIL_LIST_VIEW); }
// Path: src/main/java/de/gessnerfl/fakesmtp/model/Email.java // @Entity // @Table(name = "email") // public class Email { // @Id // @SequenceGenerator(name = "email_generator", sequenceName = "email_sequence", allocationSize = 1) // @GeneratedValue(generator = "email_generator") // private Long id; // // @Column(name="from_address", length = 255, nullable = false) // @Basic(optional = false) // private String fromAddress; // // @Column(name="to_address", length = 255, nullable = false) // @Basic(optional = false) // private String toAddress; // // @Lob // @Column(name="subject", nullable = false) // @Basic(optional = false) // private String subject; // // @Column(name="received_on", nullable = false) // @Basic(optional = false) // @Temporal(TemporalType.TIMESTAMP) // private Date receivedOn; // // @Lob // @Column(name="raw_data", nullable = false) // @Basic(optional = false) // private String rawData; // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailContent> contents = new ArrayList<>(); // // @OneToMany(mappedBy="email", cascade = CascadeType.ALL, orphanRemoval=true) // private List<EmailAttachment> attachments = new ArrayList<>(); // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getFromAddress() { // return fromAddress; // } // // public void setFromAddress(String fromAddress) { // this.fromAddress = fromAddress; // } // // public String getToAddress() { // return toAddress; // } // // public void setToAddress(String toAddress) { // this.toAddress = toAddress; // } // // public String getSubject() { // return subject; // } // // public void setSubject(String subject) { // this.subject = subject; // } // // public Date getReceivedOn() { // return receivedOn; // } // // public void setReceivedOn(Date receivedOn) { // this.receivedOn = receivedOn; // } // // public void setRawData(String rawData){ // this.rawData = rawData; // } // // public String getRawData() { // return rawData; // } // // public void addContent(EmailContent content) { // content.setEmail(this); // contents.add(content); // } // // @JsonIgnore // public List<EmailContent> getContents() { // return contents.stream().sorted(comparing(EmailContent::getContentType)).collect(toList()); // } // // @JsonIgnore // public Optional<EmailContent> getPlainContent(){ // return getContentOfType(ContentType.PLAIN); // } // // @JsonIgnore // public Optional<EmailContent> getHtmlContent(){ // return getContentOfType(ContentType.HTML); // } // // private Optional<EmailContent> getContentOfType(ContentType contentType){ // return contents.stream().filter(c -> contentType.equals(c.getContentType())).findFirst(); // } // // public void addAttachment(EmailAttachment attachment) { // attachment.setEmail(this); // attachments.add(attachment); // } // // public List<EmailAttachment> getAttachments() { // return attachments; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || getClass() != o.getClass()) return false; // // var email = (Email) o; // // return id.equals(email.id); // } // // @Override // public int hashCode() { // return id.hashCode(); // } // } // // Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java // @Repository // public interface EmailRepository extends JpaRepository<Email,Long>{ // // @Transactional // @Modifying // @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true) // int deleteEmailsExceedingDateRetentionLimit(int maxNumber); // } // Path: src/main/java/de/gessnerfl/fakesmtp/controller/EmailController.java import de.gessnerfl.fakesmtp.model.Email; import de.gessnerfl.fakesmtp.repository.EmailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.info.BuildProperties; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @Autowired public EmailController(EmailRepository emailRepository, BuildProperties buildProperties) { this.emailRepository = emailRepository; this.buildProperties = buildProperties; } @GetMapping({"/", "/email"}) public String getAll(@RequestParam(value = "page", defaultValue = "0") int page, @RequestParam(value = "size", defaultValue = "" + DEFAULT_PAGE_SIZE) int size, Model model) { return getAllEmailsPaged(page, size, model); } private String getAllEmailsPaged(int page, int size, Model model) { if(page < 0 || size <= 0){ return REDIRECT_EMAIL_LIST_VIEW; } var result = emailRepository.findAll(PageRequest.of(page, size, DEFAULT_SORT)); if (result.getNumber() != 0 && result.getNumber() >= result.getTotalPages()) { return REDIRECT_EMAIL_LIST_VIEW; } model.addAttribute(EMAIL_LIST_MODEL_NAME, result); addApplicationVersion(model); return EMAIL_LIST_VIEW; } @GetMapping("/email/{id}") public String getEmailById(@PathVariable Long id, Model model) { return emailRepository.findById(id).map(email -> appendToModelAndReturnView(model, email)).orElse(REDIRECT_EMAIL_LIST_VIEW); }
private String appendToModelAndReturnView(Model model, Email email) {
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/AppSettingsBindings.java
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // }
import android.content.Context; import android.databinding.BaseObservable; import android.databinding.Bindable; import android.databinding.Observable; import android.support.v4.content.ContextCompat; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.FirebaseDatabase; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.Util.ColorConverter; import java.util.HashMap;
@Bindable public String backgroundGooglePhotosAlbumId; @Bindable public String backgroundGooglePhotosAlbumName; @Exclude public AppSettingsHelperFragment appSettings; static String COLUMN_COUNT = "COLUMN_COUNT"; static String BACKGROUND_TYPE = "BACKGROUND_TYPE"; static String BACKGROUND_COLOR = "BACKGROUND_COLOR"; static String WIDGET_TRANSPARENCY = "WIDGET_TRANSPARENCY"; static String WIDGET_COLOR = "WIDGET_COLOR"; static String TEXT_COLOR = "TEXT_COLOR"; static String SCREEN_PADDING = "SCREEN_PADDING"; static String SLIDESHOW_INTERVAL = "SLIDESHOW_INTERVAL"; static String BACKGROUND_GOOGLE_ALBUM_ID = "backgroundGooglePhotosAlbumId"; static String BACKGROUND_GOOGLE_ALBUM_NAME = "backgroundGooglePhotosAlbumName"; static String LOCALE = "LOCALE"; static final String LANGUAGE_CODE = "LANGUAGE_CODE"; public AppSettingsBindings() { } void initDefaults(Context context) { // default settings if (dashBackgroundColor == null)
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsBindings.java import android.content.Context; import android.databinding.BaseObservable; import android.databinding.Bindable; import android.databinding.Observable; import android.support.v4.content.ContextCompat; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.FirebaseDatabase; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.Util.ColorConverter; import java.util.HashMap; @Bindable public String backgroundGooglePhotosAlbumId; @Bindable public String backgroundGooglePhotosAlbumName; @Exclude public AppSettingsHelperFragment appSettings; static String COLUMN_COUNT = "COLUMN_COUNT"; static String BACKGROUND_TYPE = "BACKGROUND_TYPE"; static String BACKGROUND_COLOR = "BACKGROUND_COLOR"; static String WIDGET_TRANSPARENCY = "WIDGET_TRANSPARENCY"; static String WIDGET_COLOR = "WIDGET_COLOR"; static String TEXT_COLOR = "TEXT_COLOR"; static String SCREEN_PADDING = "SCREEN_PADDING"; static String SLIDESHOW_INTERVAL = "SLIDESHOW_INTERVAL"; static String BACKGROUND_GOOGLE_ALBUM_ID = "backgroundGooglePhotosAlbumId"; static String BACKGROUND_GOOGLE_ALBUM_NAME = "backgroundGooglePhotosAlbumName"; static String LOCALE = "LOCALE"; static final String LANGUAGE_CODE = "LANGUAGE_CODE"; public AppSettingsBindings() { } void initDefaults(Context context) { // default settings if (dashBackgroundColor == null)
dashBackgroundColor = ColorConverter.intToString(ContextCompat.getColor(context, R.color.tv_background));
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/AppSettingsBindings.java
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // }
import android.content.Context; import android.databinding.BaseObservable; import android.databinding.Bindable; import android.databinding.Observable; import android.support.v4.content.ContextCompat; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.FirebaseDatabase; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.Util.ColorConverter; import java.util.HashMap;
@Exclude public AppSettingsHelperFragment appSettings; static String COLUMN_COUNT = "COLUMN_COUNT"; static String BACKGROUND_TYPE = "BACKGROUND_TYPE"; static String BACKGROUND_COLOR = "BACKGROUND_COLOR"; static String WIDGET_TRANSPARENCY = "WIDGET_TRANSPARENCY"; static String WIDGET_COLOR = "WIDGET_COLOR"; static String TEXT_COLOR = "TEXT_COLOR"; static String SCREEN_PADDING = "SCREEN_PADDING"; static String SLIDESHOW_INTERVAL = "SLIDESHOW_INTERVAL"; static String BACKGROUND_GOOGLE_ALBUM_ID = "backgroundGooglePhotosAlbumId"; static String BACKGROUND_GOOGLE_ALBUM_NAME = "backgroundGooglePhotosAlbumName"; static String LOCALE = "LOCALE"; static final String LANGUAGE_CODE = "LANGUAGE_CODE"; public AppSettingsBindings() { } void initDefaults(Context context) { // default settings if (dashBackgroundColor == null) dashBackgroundColor = ColorConverter.intToString(ContextCompat.getColor(context, R.color.tv_background)); if (numberOfColumns == null) numberOfColumns = 2; if (backgroundType == null)
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsBindings.java import android.content.Context; import android.databinding.BaseObservable; import android.databinding.Bindable; import android.databinding.Observable; import android.support.v4.content.ContextCompat; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.FirebaseDatabase; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.Util.ColorConverter; import java.util.HashMap; @Exclude public AppSettingsHelperFragment appSettings; static String COLUMN_COUNT = "COLUMN_COUNT"; static String BACKGROUND_TYPE = "BACKGROUND_TYPE"; static String BACKGROUND_COLOR = "BACKGROUND_COLOR"; static String WIDGET_TRANSPARENCY = "WIDGET_TRANSPARENCY"; static String WIDGET_COLOR = "WIDGET_COLOR"; static String TEXT_COLOR = "TEXT_COLOR"; static String SCREEN_PADDING = "SCREEN_PADDING"; static String SLIDESHOW_INTERVAL = "SLIDESHOW_INTERVAL"; static String BACKGROUND_GOOGLE_ALBUM_ID = "backgroundGooglePhotosAlbumId"; static String BACKGROUND_GOOGLE_ALBUM_NAME = "backgroundGooglePhotosAlbumName"; static String LOCALE = "LOCALE"; static final String LANGUAGE_CODE = "LANGUAGE_CODE"; public AppSettingsBindings() { } void initDefaults(Context context) { // default settings if (dashBackgroundColor == null) dashBackgroundColor = ColorConverter.intToString(ContextCompat.getColor(context, R.color.tv_background)); if (numberOfColumns == null) numberOfColumns = 2; if (backgroundType == null)
backgroundType = BackgroundType.SLIDESHOW.getValue();
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/settingsFragments/RSSSettings.java
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // }
import android.os.Bundle; import android.support.annotation.NonNull; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.Switch; import com.afollestad.materialdialogs.MaterialDialog; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.silver.dan.castdemo.settingsFragments; public class RSSSettings extends WidgetSettingsFragment { @BindView(R.id.feed_url) TwoLineSettingItem feedUrl; @BindView(R.id.display_rss_dates) Switch displayDates;
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/RSSSettings.java import android.os.Bundle; import android.support.annotation.NonNull; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.Switch; import com.afollestad.materialdialogs.MaterialDialog; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.silver.dan.castdemo.settingsFragments; public class RSSSettings extends WidgetSettingsFragment { @BindView(R.id.feed_url) TwoLineSettingItem feedUrl; @BindView(R.id.display_rss_dates) Switch displayDates;
WidgetOption feedUrlOption, showDatesOption;
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetList.java
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/SimpleItemTouchHelperCallback.java // public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { // // private final ItemTouchHelperAdapter mAdapter; // // public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) { // mAdapter = adapter; // } // // @Override // public boolean isLongPressDragEnabled() { // return false; // } // // @Override // public boolean isItemViewSwipeEnabled() { // return false; // } // // @Override // public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; // return makeMovementFlags(dragFlags, swipeFlags); // } // // @Override // public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { // if (source.getItemViewType() != target.getItemViewType()) { // return false; // } // // mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); // return true; // } // // @Override // public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { // mAdapter.onItemDismiss(viewHolder.getAdapterPosition()); // } // // @Override // public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemSelected(); // } // // super.onSelectedChanged(viewHolder, actionState); // } // // @Override // public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // super.clearView(recyclerView, viewHolder); // // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemClear(); // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/CanBeCreatedListener.java // public abstract class CanBeCreatedListener { // private int requiredCondition; // // public abstract void onCanBeCreated(); // // public boolean ifConditionsAreMet(int key) { // return key == requiredCondition; // } // // public void setRequestCallbackReturnCode(int condition) { // this.requiredCondition = condition; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // }
import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.OvershootInterpolator; import com.afollestad.materialdialogs.MaterialDialog; import com.google.android.gms.cast.framework.CastSession; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgetList.SimpleItemTouchHelperCallback; import com.silver.dan.castdemo.widgets.CanBeCreatedListener; import com.silver.dan.castdemo.widgets.UIWidget; import java.util.ArrayList; import java.util.Iterator; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import jp.wasabeef.recyclerview.animators.SlideInUpAnimator;
adapter = new WidgetListAdapter((MainActivity) getActivity(), this); MainActivity.getDashboard().onLoaded(getContext(), new OnCompleteCallback() { @Override public void onComplete() { adapter.setWidgets(MainActivity.getDashboard().getWidgetList()); adapter.notifyItemRangeInserted(0, MainActivity.getDashboard().getWidgetList().size()); } @Override public void onError(Exception e) { // @todo } }); } @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.widget_list, container, false); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); widgetList.setAdapter(adapter); widgetList.setLayoutManager(new LinearLayoutManager(getContext())); widgetList.setItemAnimator(new SlideInUpAnimator(new OvershootInterpolator(1f)));
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/SimpleItemTouchHelperCallback.java // public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { // // private final ItemTouchHelperAdapter mAdapter; // // public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) { // mAdapter = adapter; // } // // @Override // public boolean isLongPressDragEnabled() { // return false; // } // // @Override // public boolean isItemViewSwipeEnabled() { // return false; // } // // @Override // public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; // return makeMovementFlags(dragFlags, swipeFlags); // } // // @Override // public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { // if (source.getItemViewType() != target.getItemViewType()) { // return false; // } // // mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); // return true; // } // // @Override // public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { // mAdapter.onItemDismiss(viewHolder.getAdapterPosition()); // } // // @Override // public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemSelected(); // } // // super.onSelectedChanged(viewHolder, actionState); // } // // @Override // public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // super.clearView(recyclerView, viewHolder); // // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemClear(); // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/CanBeCreatedListener.java // public abstract class CanBeCreatedListener { // private int requiredCondition; // // public abstract void onCanBeCreated(); // // public boolean ifConditionsAreMet(int key) { // return key == requiredCondition; // } // // public void setRequestCallbackReturnCode(int condition) { // this.requiredCondition = condition; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetList.java import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.OvershootInterpolator; import com.afollestad.materialdialogs.MaterialDialog; import com.google.android.gms.cast.framework.CastSession; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgetList.SimpleItemTouchHelperCallback; import com.silver.dan.castdemo.widgets.CanBeCreatedListener; import com.silver.dan.castdemo.widgets.UIWidget; import java.util.ArrayList; import java.util.Iterator; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import jp.wasabeef.recyclerview.animators.SlideInUpAnimator; adapter = new WidgetListAdapter((MainActivity) getActivity(), this); MainActivity.getDashboard().onLoaded(getContext(), new OnCompleteCallback() { @Override public void onComplete() { adapter.setWidgets(MainActivity.getDashboard().getWidgetList()); adapter.notifyItemRangeInserted(0, MainActivity.getDashboard().getWidgetList().size()); } @Override public void onError(Exception e) { // @todo } }); } @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.widget_list, container, false); ButterKnife.bind(this, view); return view; } @Override public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); widgetList.setAdapter(adapter); widgetList.setLayoutManager(new LinearLayoutManager(getContext())); widgetList.setItemAnimator(new SlideInUpAnimator(new OvershootInterpolator(1f)));
ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetList.java
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/SimpleItemTouchHelperCallback.java // public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { // // private final ItemTouchHelperAdapter mAdapter; // // public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) { // mAdapter = adapter; // } // // @Override // public boolean isLongPressDragEnabled() { // return false; // } // // @Override // public boolean isItemViewSwipeEnabled() { // return false; // } // // @Override // public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; // return makeMovementFlags(dragFlags, swipeFlags); // } // // @Override // public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { // if (source.getItemViewType() != target.getItemViewType()) { // return false; // } // // mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); // return true; // } // // @Override // public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { // mAdapter.onItemDismiss(viewHolder.getAdapterPosition()); // } // // @Override // public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemSelected(); // } // // super.onSelectedChanged(viewHolder, actionState); // } // // @Override // public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // super.clearView(recyclerView, viewHolder); // // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemClear(); // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/CanBeCreatedListener.java // public abstract class CanBeCreatedListener { // private int requiredCondition; // // public abstract void onCanBeCreated(); // // public boolean ifConditionsAreMet(int key) { // return key == requiredCondition; // } // // public void setRequestCallbackReturnCode(int condition) { // this.requiredCondition = condition; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // }
import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.OvershootInterpolator; import com.afollestad.materialdialogs.MaterialDialog; import com.google.android.gms.cast.framework.CastSession; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgetList.SimpleItemTouchHelperCallback; import com.silver.dan.castdemo.widgets.CanBeCreatedListener; import com.silver.dan.castdemo.widgets.UIWidget; import java.util.ArrayList; import java.util.Iterator; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import jp.wasabeef.recyclerview.animators.SlideInUpAnimator;
widget.setType(widgetTypes.get(which)); widget.position = widgetList.getAdapter().getItemCount(); /* * * The idea here is to have a callback for when the widget can be created. * If there are no widget creation requirements, such as extra app runtime permissions, * create it right away. Otherwise save the callback so it can be executed when the widget * can be created. * */ CanBeCreatedListener listener = new CanBeCreatedListener() { @Override public void onCanBeCreated() { widget.save(); widget.initWidgetSettings(getContext()); adapter.addWidget(widget); CastSession session = MainActivity.mCastSession; if (session != null) { (new CastCommunicator(session)).sendWidget(widget, getContext()); } } };
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/SimpleItemTouchHelperCallback.java // public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback { // // private final ItemTouchHelperAdapter mAdapter; // // public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) { // mAdapter = adapter; // } // // @Override // public boolean isLongPressDragEnabled() { // return false; // } // // @Override // public boolean isItemViewSwipeEnabled() { // return false; // } // // @Override // public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // final int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN; // final int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; // return makeMovementFlags(dragFlags, swipeFlags); // } // // @Override // public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { // if (source.getItemViewType() != target.getItemViewType()) { // return false; // } // // mAdapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); // return true; // } // // @Override // public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) { // mAdapter.onItemDismiss(viewHolder.getAdapterPosition()); // } // // @Override // public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { // if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) { // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemSelected(); // } // // super.onSelectedChanged(viewHolder, actionState); // } // // @Override // public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { // super.clearView(recyclerView, viewHolder); // // ItemTouchHelperViewHolder itemViewHolder = (ItemTouchHelperViewHolder) viewHolder; // itemViewHolder.onItemClear(); // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/CanBeCreatedListener.java // public abstract class CanBeCreatedListener { // private int requiredCondition; // // public abstract void onCanBeCreated(); // // public boolean ifConditionsAreMet(int key) { // return key == requiredCondition; // } // // public void setRequestCallbackReturnCode(int condition) { // this.requiredCondition = condition; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetList.java import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.OvershootInterpolator; import com.afollestad.materialdialogs.MaterialDialog; import com.google.android.gms.cast.framework.CastSession; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgetList.SimpleItemTouchHelperCallback; import com.silver.dan.castdemo.widgets.CanBeCreatedListener; import com.silver.dan.castdemo.widgets.UIWidget; import java.util.ArrayList; import java.util.Iterator; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import jp.wasabeef.recyclerview.animators.SlideInUpAnimator; widget.setType(widgetTypes.get(which)); widget.position = widgetList.getAdapter().getItemCount(); /* * * The idea here is to have a callback for when the widget can be created. * If there are no widget creation requirements, such as extra app runtime permissions, * create it right away. Otherwise save the callback so it can be executed when the widget * can be created. * */ CanBeCreatedListener listener = new CanBeCreatedListener() { @Override public void onCanBeCreated() { widget.save(); widget.initWidgetSettings(getContext()); adapter.addWidget(widget); CastSession session = MainActivity.mCastSession; if (session != null) { (new CastCommunicator(session)).sendWidget(widget, getContext()); } } };
UIWidget uiWidget = widget.getUIWidget(getContext());
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/AppSettingsTheme.java
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java // public class TwoLineSettingItem extends SettingItem { // @BindView(R.id.two_line_settings_item_header) // TextView header; // // @BindView(R.id.two_line_settings_item_sub_header) // TextView subHeader; // // @BindView(R.id.two_line_settings_item_icon) // ImageView icon; // // public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // private void init(AttributeSet attrs) { // TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem); // // // header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText)); // subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText)); // // a.recycle(); // } // // public TwoLineSettingItem(Context context, AttributeSet attrs) { // super(context, attrs); // // LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflater.inflate(R.layout.two_line_settings_item, this, true); // ButterKnife.bind(this); // init(attrs); // } // // public void setIcon(Drawable drawable) { // if (drawable == null) { // icon.setVisibility(View.GONE); // return; // } // // icon.setImageDrawable(drawable); // } // // public void setHeaderText(String text) { // header.setText(text); // } // // public void setSubHeaderText(String text) { // subHeader.setText(text); // } // // public void setHeaderText(int resId) { // setHeaderText(getResources().getString(resId)); // } // // public void setSubHeaderText(int resId) { // setSubHeaderText(getResources().getString(resId)); // } // // }
import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.SeekBar; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Scope; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding; import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.silver.dan.castdemo; public class AppSettingsTheme extends AppSettingsHelperFragment { @BindView(R.id.background_type)
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java // public class TwoLineSettingItem extends SettingItem { // @BindView(R.id.two_line_settings_item_header) // TextView header; // // @BindView(R.id.two_line_settings_item_sub_header) // TextView subHeader; // // @BindView(R.id.two_line_settings_item_icon) // ImageView icon; // // public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // private void init(AttributeSet attrs) { // TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem); // // // header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText)); // subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText)); // // a.recycle(); // } // // public TwoLineSettingItem(Context context, AttributeSet attrs) { // super(context, attrs); // // LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflater.inflate(R.layout.two_line_settings_item, this, true); // ButterKnife.bind(this); // init(attrs); // } // // public void setIcon(Drawable drawable) { // if (drawable == null) { // icon.setVisibility(View.GONE); // return; // } // // icon.setImageDrawable(drawable); // } // // public void setHeaderText(String text) { // header.setText(text); // } // // public void setSubHeaderText(String text) { // subHeader.setText(text); // } // // public void setHeaderText(int resId) { // setHeaderText(getResources().getString(resId)); // } // // public void setSubHeaderText(int resId) { // setSubHeaderText(getResources().getString(resId)); // } // // } // Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsTheme.java import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.SeekBar; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Scope; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding; import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.silver.dan.castdemo; public class AppSettingsTheme extends AppSettingsHelperFragment { @BindView(R.id.background_type)
TwoLineSettingItem backgroundType;
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/AppSettingsTheme.java
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java // public class TwoLineSettingItem extends SettingItem { // @BindView(R.id.two_line_settings_item_header) // TextView header; // // @BindView(R.id.two_line_settings_item_sub_header) // TextView subHeader; // // @BindView(R.id.two_line_settings_item_icon) // ImageView icon; // // public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // private void init(AttributeSet attrs) { // TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem); // // // header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText)); // subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText)); // // a.recycle(); // } // // public TwoLineSettingItem(Context context, AttributeSet attrs) { // super(context, attrs); // // LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflater.inflate(R.layout.two_line_settings_item, this, true); // ButterKnife.bind(this); // init(attrs); // } // // public void setIcon(Drawable drawable) { // if (drawable == null) { // icon.setVisibility(View.GONE); // return; // } // // icon.setImageDrawable(drawable); // } // // public void setHeaderText(String text) { // header.setText(text); // } // // public void setSubHeaderText(String text) { // subHeader.setText(text); // } // // public void setHeaderText(int resId) { // setHeaderText(getResources().getString(resId)); // } // // public void setSubHeaderText(int resId) { // setSubHeaderText(getResources().getString(resId)); // } // // }
import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.SeekBar; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Scope; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding; import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
.load("https://picasaweb.google.com/data/feed/api/user/default?alt=json") .setHeader("Authorization", "Bearer " + googleAccessToken) .asJsonObject() .setCallback(new FutureCallback<JsonObject>() { @Override public void onCompleted(Exception e, JsonObject result) { if (e != null) { // todo error to firebase CharSequence text = "Hit a problem finding your albums"; Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show(); return; } final List<String> titles = new ArrayList<>(); final List<String> albumIds = new ArrayList<>(); JsonArray albums = result.get("feed").getAsJsonObject().get("entry").getAsJsonArray(); for (int i=0;i<albums.size();i++) { JsonObject album = albums.get(i).getAsJsonObject(); titles.add(album.get("title").getAsJsonObject().get("$t").getAsString()); albumIds.add(album.get("id").getAsJsonObject().get("$t").getAsString()); } new MaterialDialog.Builder(getContext()) .title(R.string.google_photos_album) .items(titles) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { bindings.setBackgroundGooglePhotosAlbum(titles.get(which), albumIds.get(which));
// Path: app/src/main/java/com/silver/dan/castdemo/SettingEnums/BackgroundType.java // public enum BackgroundType { // SLIDESHOW(0, R.string.slideshow), // SOLID_COLOR(1, R.string.solid_color), // @Deprecated // PICTURE(2, R.string.picture), // PICASA_ALBUM(3, R.string.google_photos_album); // // private int value; // private int humanNameRes; // // BackgroundType(int value, int humanNameRes) { // this.value = value; // this.humanNameRes = humanNameRes; // } // // public int getValue() { // return value; // } // // public int getHumanNameRes() { // return humanNameRes; // } // } // // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/TwoLineSettingItem.java // public class TwoLineSettingItem extends SettingItem { // @BindView(R.id.two_line_settings_item_header) // TextView header; // // @BindView(R.id.two_line_settings_item_sub_header) // TextView subHeader; // // @BindView(R.id.two_line_settings_item_icon) // ImageView icon; // // public TwoLineSettingItem(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // } // // private void init(AttributeSet attrs) { // TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TwoLineSettingItem); // // // header.setText(a.getString(R.styleable.TwoLineSettingItem_headerText)); // subHeader.setText(a.getString(R.styleable.TwoLineSettingItem_subHeaderText)); // // a.recycle(); // } // // public TwoLineSettingItem(Context context, AttributeSet attrs) { // super(context, attrs); // // LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // inflater.inflate(R.layout.two_line_settings_item, this, true); // ButterKnife.bind(this); // init(attrs); // } // // public void setIcon(Drawable drawable) { // if (drawable == null) { // icon.setVisibility(View.GONE); // return; // } // // icon.setImageDrawable(drawable); // } // // public void setHeaderText(String text) { // header.setText(text); // } // // public void setSubHeaderText(String text) { // subHeader.setText(text); // } // // public void setHeaderText(int resId) { // setHeaderText(getResources().getString(resId)); // } // // public void setSubHeaderText(int resId) { // setSubHeaderText(getResources().getString(resId)); // } // // } // Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsTheme.java import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.SeekBar; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Scope; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.koushikdutta.async.future.FutureCallback; import com.koushikdutta.ion.Ion; import com.silver.dan.castdemo.SettingEnums.BackgroundType; import com.silver.dan.castdemo.databinding.FragmentAppSettingsThemeBinding; import com.silver.dan.castdemo.settingsFragments.TwoLineSettingItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; .load("https://picasaweb.google.com/data/feed/api/user/default?alt=json") .setHeader("Authorization", "Bearer " + googleAccessToken) .asJsonObject() .setCallback(new FutureCallback<JsonObject>() { @Override public void onCompleted(Exception e, JsonObject result) { if (e != null) { // todo error to firebase CharSequence text = "Hit a problem finding your albums"; Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show(); return; } final List<String> titles = new ArrayList<>(); final List<String> albumIds = new ArrayList<>(); JsonArray albums = result.get("feed").getAsJsonObject().get("entry").getAsJsonArray(); for (int i=0;i<albums.size();i++) { JsonObject album = albums.get(i).getAsJsonObject(); titles.add(album.get("title").getAsJsonObject().get("$t").getAsString()); albumIds.add(album.get("id").getAsJsonObject().get("$t").getAsString()); } new MaterialDialog.Builder(getContext()) .title(R.string.google_photos_album) .items(titles) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { bindings.setBackgroundGooglePhotosAlbum(titles.get(which), albumIds.get(which));
bindings.setBackgroundType(BackgroundType.PICASA_ALBUM.getValue());
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/settingsFragments/CountdownSettings.java
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // }
import android.os.Bundle; import android.support.annotation.NonNull; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.afollestad.materialdialogs.MaterialDialog; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick;
package com.silver.dan.castdemo.settingsFragments; /** * Created by dan on 5/26/16. */ public class CountdownSettings extends WidgetSettingsFragment { @BindView(R.id.countdown_date) TwoLineSettingItem countdownDate; @BindView(R.id.countdown_time) TwoLineSettingItem countdownTime; @BindView(R.id.countdown_text) TwoLineSettingItem countdownText;
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/CountdownSettings.java import android.os.Bundle; import android.support.annotation.NonNull; import android.text.InputType; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.afollestad.materialdialogs.MaterialDialog; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; package com.silver.dan.castdemo.settingsFragments; /** * Created by dan on 5/26/16. */ public class CountdownSettings extends WidgetSettingsFragment { @BindView(R.id.countdown_date) TwoLineSettingItem countdownDate; @BindView(R.id.countdown_time) TwoLineSettingItem countdownTime; @BindView(R.id.countdown_text) TwoLineSettingItem countdownText;
WidgetOption dateOption, textOption;
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/settingsFragments/GetStockSuggestionsAdapter.java
// Path: app/src/main/java/com/silver/dan/castdemo/StockInfo.java // public class StockInfo implements Serializable { // private String ticker; // private String name; // // public StockInfo(String ticker, String name) { // this.ticker = ticker; // this.name = name; // } // // public String getTicker() { // return ticker; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return name; // } // // }
import android.content.Context; import android.os.AsyncTask; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.StockInfo; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List;
package com.silver.dan.castdemo.settingsFragments; /** * Created by dan on 1/16/17. */ public class GetStockSuggestionsAdapter extends BaseAdapter implements Filterable { private Context mContext;
// Path: app/src/main/java/com/silver/dan/castdemo/StockInfo.java // public class StockInfo implements Serializable { // private String ticker; // private String name; // // public StockInfo(String ticker, String name) { // this.ticker = ticker; // this.name = name; // } // // public String getTicker() { // return ticker; // } // // public String getName() { // return name; // } // // @Override // public String toString() { // return name; // } // // } // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/GetStockSuggestionsAdapter.java import android.content.Context; import android.os.AsyncTask; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.StockInfo; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; package com.silver.dan.castdemo.settingsFragments; /** * Created by dan on 1/16/17. */ public class GetStockSuggestionsAdapter extends BaseAdapter implements Filterable { private Context mContext;
private List<StockInfo> resultList = new ArrayList<>();
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetOption.java
// Path: app/src/main/java/com/silver/dan/castdemo/Widget.java // @Exclude // static DatabaseReference getFirebaseDashboardWidgetsRef() { // DatabaseReference ref = Dashboard.getFirebaseUserDashboardReference(); // if (ref == null) { // return null; // } // return ref.child("widgets"); // }
import android.text.TextUtils; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.IgnoreExtraProperties; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.silver.dan.castdemo.Widget.getFirebaseDashboardWidgetsRef;
package com.silver.dan.castdemo; @IgnoreExtraProperties public class WidgetOption { @Exclude Widget widgetRef; @Exclude String key; public String value; public WidgetOption() { } @Exclude private DatabaseReference getOptionsRef() {
// Path: app/src/main/java/com/silver/dan/castdemo/Widget.java // @Exclude // static DatabaseReference getFirebaseDashboardWidgetsRef() { // DatabaseReference ref = Dashboard.getFirebaseUserDashboardReference(); // if (ref == null) { // return null; // } // return ref.child("widgets"); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java import android.text.TextUtils; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.Exclude; import com.google.firebase.database.IgnoreExtraProperties; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.silver.dan.castdemo.Widget.getFirebaseDashboardWidgetsRef; package com.silver.dan.castdemo; @IgnoreExtraProperties public class WidgetOption { @Exclude Widget widgetRef; @Exclude String key; public String value; public WidgetOption() { } @Exclude private DatabaseReference getOptionsRef() {
return getFirebaseDashboardWidgetsRef()
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/settingsFragments/ClockSettings.java
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // }
import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.Switch; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife;
package com.silver.dan.castdemo.settingsFragments; public class ClockSettings extends WidgetSettingsFragment { @BindView(R.id.clock_show_seconds) Switch showSeconds;
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/ClockSettings.java import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.Switch; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife; package com.silver.dan.castdemo.settingsFragments; public class ClockSettings extends WidgetSettingsFragment { @BindView(R.id.clock_show_seconds) Switch showSeconds;
WidgetOption showSecondsOption;
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/AppSettingsHelperFragment.java
// Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // }
import android.os.Bundle; import android.support.v4.app.Fragment; import com.flask.colorpicker.ColorPickerView; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.flask.colorpicker.builder.ColorPickerDialogBuilder; import com.silver.dan.castdemo.Util.ColorConverter;
package com.silver.dan.castdemo; public class AppSettingsHelperFragment extends Fragment { public static final int PERMISSION_RESULT_CODE_GOOGLE_ALBUMS = 4445; OnSettingChangedListener mCallback; android.databinding.ViewDataBinding viewModel; AppSettingsBindings bindings; public AppSettingsHelperFragment() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { mCallback = (OnSettingChangedListener) getActivity(); } catch (ClassCastException e) { throw new ClassCastException(getActivity().toString() + " must implement OnSettingChangedListener"); } } public void createColorPickerDialog(String initialColor, ColorPickerClickListener onResult) {
// Path: app/src/main/java/com/silver/dan/castdemo/Util/ColorConverter.java // public class ColorConverter { // public static String intToString(int color) { // return Integer.toHexString(color).substring(2); // } // // public static Integer stringToInt(String color) { // return Color.parseColor("#" + color); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/AppSettingsHelperFragment.java import android.os.Bundle; import android.support.v4.app.Fragment; import com.flask.colorpicker.ColorPickerView; import com.flask.colorpicker.builder.ColorPickerClickListener; import com.flask.colorpicker.builder.ColorPickerDialogBuilder; import com.silver.dan.castdemo.Util.ColorConverter; package com.silver.dan.castdemo; public class AppSettingsHelperFragment extends Fragment { public static final int PERMISSION_RESULT_CODE_GOOGLE_ALBUMS = 4445; OnSettingChangedListener mCallback; android.databinding.ViewDataBinding viewModel; AppSettingsBindings bindings; public AppSettingsHelperFragment() { } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { mCallback = (OnSettingChangedListener) getActivity(); } catch (ClassCastException e) { throw new ClassCastException(getActivity().toString() + " must implement OnSettingChangedListener"); } } public void createColorPickerDialog(String initialColor, ColorPickerClickListener onResult) {
createColorPickerDialog(ColorConverter.stringToInt(initialColor), onResult);
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // }
import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List;
package com.silver.dan.castdemo; class WidgetListAdapter extends RecyclerView.Adapter<WidgetListAdapter.WidgetViewHolder> implements ItemTouchHelperAdapter { private final MainActivity mainActivity; private List<Widget> widgetList = new ArrayList<>();
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List; package com.silver.dan.castdemo; class WidgetListAdapter extends RecyclerView.Adapter<WidgetListAdapter.WidgetViewHolder> implements ItemTouchHelperAdapter { private final MainActivity mainActivity; private List<Widget> widgetList = new ArrayList<>();
private final OnDragListener mDragStartListener;
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // }
import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List;
int i = 0; for (Widget widget : widgetList) { widget.position = i; widget.savePosition(); i++; } } void addWidget(Widget widget) { this.widgetList.add(widget); notifyItemInserted(widgetList.indexOf(widget)); } void deleteWidget(Widget widget) { int index = widgetList.indexOf(widget); this.widgetList.remove(widget); notifyItemRemoved(index); widget.delete(); } public void refreshSecondaryTitles() { notifyDataSetChanged(); // http://stackoverflow.com/a/38132573/2517012 } public void setWidgets(List<Widget> widgets) { widgetList = widgets; }
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List; int i = 0; for (Widget widget : widgetList) { widget.position = i; widget.savePosition(); i++; } } void addWidget(Widget widget) { this.widgetList.add(widget); notifyItemInserted(widgetList.indexOf(widget)); } void deleteWidget(Widget widget) { int index = widgetList.indexOf(widget); this.widgetList.remove(widget); notifyItemRemoved(index); widget.delete(); } public void refreshSecondaryTitles() { notifyDataSetChanged(); // http://stackoverflow.com/a/38132573/2517012 } public void setWidgets(List<Widget> widgets) { widgetList = widgets; }
class WidgetViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder {
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // }
import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List;
this.topHeader = (TextView) view.findViewById(R.id.widget_name); this.bottomHeader = (TextView) view.findViewById(R.id.widget_type); this.typeIcon = (ImageView) view.findViewById(R.id.widget_type_icon); handleView = (ImageView) itemView.findViewById(R.id.widget_handle); this.listItemView = view; } @Override public void onItemSelected() { int color = ContextCompat.getColor(listItemView.getContext(), R.color.list_item_drag_highlight); itemView.setBackgroundColor(color); } @Override public void onItemClear() { itemView.setBackgroundColor(0); } } @Override public WidgetViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.list_row, viewGroup, false); return new WidgetViewHolder(view); } @Override public void onBindViewHolder(final WidgetViewHolder customViewHolder, int i) { final Widget widget = widgetList.get(i);
// Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperAdapter.java // public interface ItemTouchHelperAdapter { // // /** // * Called when an item has been dragged far enough to trigger a move. This is called every time // * an item is shifted, and not at the end of a "drop" event. // * // * @param fromPosition The start position of the moved item. // * @param toPosition Then end position of the moved item. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemMove(int fromPosition, int toPosition); // // // /** // * Called when an item has been dismissed by a swipe. // * // * @param position The position of the item dismissed. // * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder) // * @see RecyclerView.ViewHolder#getAdapterPosition() // */ // void onItemDismiss(int position); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/ItemTouchHelperViewHolder.java // public interface ItemTouchHelperViewHolder { // // /** // * Called when the {@link ItemTouchHelper} first registers an item as being moved or swiped. // * Implementations should update the item view to indicate it's active state. // */ // void onItemSelected(); // // // /** // * Called when the {@link ItemTouchHelper} has completed the move or swipe, and the active item // * state should be cleared. // */ // void onItemClear(); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgetList/OnDragListener.java // public interface OnDragListener { // // /** // * Called when a view is requesting a start of a drag. // * // * @param viewHolder The holder of the view to drag. // */ // void onStartDrag(RecyclerView.ViewHolder viewHolder); // } // // Path: app/src/main/java/com/silver/dan/castdemo/widgets/UIWidget.java // abstract public class UIWidget { // public Widget widget; // public Context context; // // public abstract JSONObject getContent() throws JSONException; // // public int requestPermissions(Activity activity) { // return -1; // } // // public abstract WidgetSettingsFragment createSettingsFragment(); // // // /* // * This method should return true if there are no prerequisites to the widget being created. // * Return false if the widget needs special permissions before it's created. // */ // public boolean canBeCreated() { // return true; // } // // public abstract String getWidgetPreviewSecondaryHeader(); // // public UIWidget(Context context, Widget widget) { // this.widget = widget; // this.context = context; // } // // public abstract void init(); // } // Path: app/src/main/java/com/silver/dan/castdemo/WidgetListAdapter.java import android.content.Intent; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.silver.dan.castdemo.widgetList.ItemTouchHelperAdapter; import com.silver.dan.castdemo.widgetList.ItemTouchHelperViewHolder; import com.silver.dan.castdemo.widgetList.OnDragListener; import com.silver.dan.castdemo.widgets.UIWidget; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.Collections; import java.util.List; this.topHeader = (TextView) view.findViewById(R.id.widget_name); this.bottomHeader = (TextView) view.findViewById(R.id.widget_type); this.typeIcon = (ImageView) view.findViewById(R.id.widget_type_icon); handleView = (ImageView) itemView.findViewById(R.id.widget_handle); this.listItemView = view; } @Override public void onItemSelected() { int color = ContextCompat.getColor(listItemView.getContext(), R.color.list_item_drag_highlight); itemView.setBackgroundColor(color); } @Override public void onItemClear() { itemView.setBackgroundColor(0); } } @Override public WidgetViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.list_row, viewGroup, false); return new WidgetViewHolder(view); } @Override public void onBindViewHolder(final WidgetViewHolder customViewHolder, int i) { final Widget widget = widgetList.get(i);
final UIWidget uiWidget = widget.getUIWidget(mainActivity);
dan-silver/cast-dashboard-android-app
app/src/main/java/com/silver/dan/castdemo/settingsFragments/FreeTextSetting.java
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // }
import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.richeditor.RichEditor;
package com.silver.dan.castdemo.settingsFragments; public class FreeTextSetting extends WidgetSettingsFragment { @BindView(R.id.rich_editor) RichEditor richEditor;
// Path: app/src/main/java/com/silver/dan/castdemo/WidgetOption.java // @IgnoreExtraProperties // public class WidgetOption { // // @Exclude // Widget widgetRef; // // @Exclude // String key; // // public String value; // // public WidgetOption() { // } // // // @Exclude // private DatabaseReference getOptionsRef() { // return getFirebaseDashboardWidgetsRef() // .child(widgetRef.guid) // .child("optionsMap"); // } // // @Exclude // private Map<String, String> toMap() { // HashMap<String, String> result = new HashMap<>(); // result.put("value", value); // // return result; // } // // // @Exclude // void associateWidget(Widget widget) { // this.widgetRef = widget; // } // // @Exclude // public boolean getBooleanValue() { // return value.equals("1"); // } // // @Exclude // public void setValue(boolean booleanValue) { // this.value = booleanValue ? "1" : "0"; // } // // @Exclude // public void setValue(int value) { // this.value = Integer.toString(value); // } // // @Exclude // public int getIntValue() { // return Integer.valueOf(value); // } // // @Exclude // public void setValue(Date datetime) { // this.value = Long.toString(datetime.getTime()); // } // // @Exclude // public Date getDate() { // return new Date(Long.parseLong(this.value)); // } // // @Exclude // public void save() { // getOptionsRef() // .child(this.key) // .setValue(this.toMap()); // } // // @Exclude // public void update(int value) { // setValue(value); // save(); // } // // @Exclude // public void update(boolean value) { // setValue(value); // save(); // } // // @Exclude // public void update(String str) { // setValue(str); // save(); // } // // @Exclude // public void update(double n) { // setValue(n); // save(); // } // // @Exclude // private void setValue(double n) { // this.value = Double.toString(n); // } // // @Exclude // public void setValue(long l) { // this.value = Long.toString(l); // } // // @Exclude // public void setValue(String str) { // this.value = str; // } // // // @Exclude // public List<String> getList() { // String[] stringArray = this.value.split(","); // List<String> items = new ArrayList<>(); // Collections.addAll(items, stringArray); // // items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings // // // if (items.size() == 1 && items.get(0).length() == 0) // return new ArrayList<>(); // // return items; // } // // @Exclude // public void update(List<String> enabledIds) { // setValue(enabledIds); // save(); // } // // @Exclude // protected void setValue(List<String> enabledIds) { // setValue(TextUtils.join(",", enabledIds)); // } // } // Path: app/src/main/java/com/silver/dan/castdemo/settingsFragments/FreeTextSetting.java import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.silver.dan.castdemo.R; import com.silver.dan.castdemo.WidgetOption; import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.richeditor.RichEditor; package com.silver.dan.castdemo.settingsFragments; public class FreeTextSetting extends WidgetSettingsFragment { @BindView(R.id.rich_editor) RichEditor richEditor;
WidgetOption customText;
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // }
import java.lang.reflect.Method; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.util.ReflectTools;
package org.mpilone.vaadin.timeline; /** * Listener for double-click events on the timeline. */ public interface DoubleClickListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(DoubleClickListener.class, "doubleClick", DoubleClickEvent.class); /** * The handler method called when the timeline is double left-clicked. * * @param evt the event details */ void doubleClick(DoubleClickEvent evt); public static class DoubleClickEvent extends ClickListener.ClickEvent { public DoubleClickEvent(Timeline source, Object itemId,
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java import java.lang.reflect.Method; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.util.ReflectTools; package org.mpilone.vaadin.timeline; /** * Listener for double-click events on the timeline. */ public interface DoubleClickListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(DoubleClickListener.class, "doubleClick", DoubleClickEvent.class); /** * The handler method called when the timeline is double left-clicked. * * @param evt the event details */ void doubleClick(DoubleClickEvent evt); public static class DoubleClickEvent extends ClickListener.ClickEvent { public DoubleClickEvent(Timeline source, Object itemId,
EventProperties props) {
mpilone/timeline-vaadin
demo/src/main/java/org/mpilone/vaadin/Demo.java
// Path: demo/src/main/java/org/mpilone/vaadin/StyleConstants.java // public final static String FULL_WIDTH = "100%";
import static org.mpilone.vaadin.StyleConstants.FULL_WIDTH; import com.vaadin.annotations.*; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.*;
package org.mpilone.vaadin; /** * Demo for the various Vaadin components by Mike Pilone. * * @author mpilone */ @Theme("valo") @Push(value = PushMode.DISABLED) public class Demo extends UI { @Override protected void init(VaadinRequest request) { //setPollInterval(3000);
// Path: demo/src/main/java/org/mpilone/vaadin/StyleConstants.java // public final static String FULL_WIDTH = "100%"; // Path: demo/src/main/java/org/mpilone/vaadin/Demo.java import static org.mpilone.vaadin.StyleConstants.FULL_WIDTH; import com.vaadin.annotations.*; import com.vaadin.server.VaadinRequest; import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.*; package org.mpilone.vaadin; /** * Demo for the various Vaadin components by Mike Pilone. * * @author mpilone */ @Theme("valo") @Push(value = PushMode.DISABLED) public class Demo extends UI { @Override protected void init(VaadinRequest request) { //setPollInterval(3000);
setWidth(FULL_WIDTH);
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineMethodOptions.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineClientRpc.java // public interface TimelineClientRpc extends ClientRpc { // // /** // * Sets the current time. This can be used for example to ensure that a // * client's time is synchronized with a shared server time. // * // * @param time the current time in milliseconds past the epoch // */ // void setCurrentTime(long time); // // /** // * Sets the custom time to be displayed on the client. // * // * @param time the custom time in milliseconds past the epoch // * @param id the id of the time bar // */ // void setCustomTime(long time, String id); // // /** // * Add a new vertical bar representing a custom time that can be dragged by // * the user. // * // * @param time the custom time in milliseconds past the epoch // * @param id the id of the time bar // */ // void addCustomTime(long time, String id); // // /** // * Remove vertical bars previously added to the timeline via addCustomTime // * method. // * // * @param id the id of the time bar // */ // void removeCustomTime(String id); // // /** // * Sets the visible range (zoom) to the specified range. Accepts two // * parameters of type Date that represent the first and last times of the // * wanted selected visible range. // * // * @param start the start time // * @param end the end time // * @param options the options for the method // */ // void setWindow(long start, long end, MethodOptions.SetWindow options); // // /** // * Select one or multiple items by their id. The currently selected items will // * be unselected. To unselect all selected items, call `setSelection([])`. // * // * @param ids the ids of the items to select // * @param options the options for the method // */ // void setSelection(Object[] ids, MethodOptions.SetSelection options); // // /** // * Adjust the visible window such that it fits all items. // * // * @param options the options for the method // */ // void fit(MethodOptions.Fit options); // // /** // * Adjust the visible window such that the selected item (or multiple items) // * are centered on screen. // * // * @param ids the ids of the items to focus on // * @param options the options for the method // */ // void focus(Object[] ids, MethodOptions.Focus options); // // /** // * Move the window such that given time is centered on screen. // * // * @param time the time to center on // * @param options the options for the method // */ // void moveTo(long time, MethodOptions.MoveTo options); // // /** // * Sets the items to be displayed in the timeline. // * // * @param items the items to display // */ // void setItems(Item[] items); // // /** // * Sets the groups to be displayed in the timeline. // * // * @param groups the groups to display // */ // void setGroups(Group[] groups); // // /** // * Options that can be passed to specific methods on the timeline. // */ // public static class MethodOptions { // // public static class Fit { // // public Animation animation; // } // // public static class Focus { // // public Animation animation; // } // // public static class MoveTo { // // public Animation animation; // } // // public static class SetSelection { // // public boolean focus; // public Animation animation; // } // // public static class SetWindow { // // public Animation animation; // } // } // // public static class Animation { // // public Integer duration; // public String easingFunction; // } // // public static class Group { // // public String className; // public String content; // public String id; // public String style; // public String order; // public String subgroupOrder; // public String title; // } // // public static class Item { // // public String className; // public String content; // public long end; // public String group; // public String id; // public long start; // public String style; // public String subgroup; // public String title; // public String type; // public Boolean editable; // } // }
import org.mpilone.vaadin.timeline.shared.TimelineClientRpc;
private final Animation animation; /** * Constructs the options. * * @param animation the animation options or null for no animation */ public Fit(Animation animation) { this.animation = animation; } /** * Returns the animation to use for the operation. If null, no animation * will be used. * * @return the animation for the operation */ public Animation getAnimation() { return animation; } } /** * Maps an {@link Animation} to a {@link TimelineClientRpc.Animation}. * * @param animation the animation to map or null * * @return the client RPC animation or null */
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineClientRpc.java // public interface TimelineClientRpc extends ClientRpc { // // /** // * Sets the current time. This can be used for example to ensure that a // * client's time is synchronized with a shared server time. // * // * @param time the current time in milliseconds past the epoch // */ // void setCurrentTime(long time); // // /** // * Sets the custom time to be displayed on the client. // * // * @param time the custom time in milliseconds past the epoch // * @param id the id of the time bar // */ // void setCustomTime(long time, String id); // // /** // * Add a new vertical bar representing a custom time that can be dragged by // * the user. // * // * @param time the custom time in milliseconds past the epoch // * @param id the id of the time bar // */ // void addCustomTime(long time, String id); // // /** // * Remove vertical bars previously added to the timeline via addCustomTime // * method. // * // * @param id the id of the time bar // */ // void removeCustomTime(String id); // // /** // * Sets the visible range (zoom) to the specified range. Accepts two // * parameters of type Date that represent the first and last times of the // * wanted selected visible range. // * // * @param start the start time // * @param end the end time // * @param options the options for the method // */ // void setWindow(long start, long end, MethodOptions.SetWindow options); // // /** // * Select one or multiple items by their id. The currently selected items will // * be unselected. To unselect all selected items, call `setSelection([])`. // * // * @param ids the ids of the items to select // * @param options the options for the method // */ // void setSelection(Object[] ids, MethodOptions.SetSelection options); // // /** // * Adjust the visible window such that it fits all items. // * // * @param options the options for the method // */ // void fit(MethodOptions.Fit options); // // /** // * Adjust the visible window such that the selected item (or multiple items) // * are centered on screen. // * // * @param ids the ids of the items to focus on // * @param options the options for the method // */ // void focus(Object[] ids, MethodOptions.Focus options); // // /** // * Move the window such that given time is centered on screen. // * // * @param time the time to center on // * @param options the options for the method // */ // void moveTo(long time, MethodOptions.MoveTo options); // // /** // * Sets the items to be displayed in the timeline. // * // * @param items the items to display // */ // void setItems(Item[] items); // // /** // * Sets the groups to be displayed in the timeline. // * // * @param groups the groups to display // */ // void setGroups(Group[] groups); // // /** // * Options that can be passed to specific methods on the timeline. // */ // public static class MethodOptions { // // public static class Fit { // // public Animation animation; // } // // public static class Focus { // // public Animation animation; // } // // public static class MoveTo { // // public Animation animation; // } // // public static class SetSelection { // // public boolean focus; // public Animation animation; // } // // public static class SetWindow { // // public Animation animation; // } // } // // public static class Animation { // // public Integer duration; // public String easingFunction; // } // // public static class Group { // // public String className; // public String content; // public String id; // public String style; // public String order; // public String subgroupOrder; // public String title; // } // // public static class Item { // // public String className; // public String content; // public long end; // public String group; // public String id; // public long start; // public String style; // public String subgroup; // public String title; // public String type; // public Boolean editable; // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineMethodOptions.java import org.mpilone.vaadin.timeline.shared.TimelineClientRpc; private final Animation animation; /** * Constructs the options. * * @param animation the animation options or null for no animation */ public Fit(Animation animation) { this.animation = animation; } /** * Returns the animation to use for the operation. If null, no animation * will be used. * * @return the animation for the operation */ public Animation getAnimation() { return animation; } } /** * Maps an {@link Animation} to a {@link TimelineClientRpc.Animation}. * * @param animation the animation to map or null * * @return the client RPC animation or null */
static TimelineClientRpc.Animation map(Animation animation) {
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // }
import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent;
/** * Constructs the timeline. The timeline will default to showing an 8 hour * period starting "now" unless {@link #setWindow(java.util.Date, java.util.Date, org.mpilone.vaadin.timeline.TimelineMethodOptions.SetWindow) * } is called. * * @param caption the caption of the component * @param provider the provider of timeline items */ public Timeline(String caption, TimelineItemProvider provider) { setWidth("100%"); setCaption(caption); setItemProvider(provider); registerRpc(serverRpc); clientRpc = getRpcProxy(TimelineClientRpc.class); keyMapper = new DataProviderKeyMapper(); selection = new HashSet<>(); options = new StateMappingOptions(this); groups = new ArrayList<>(); window = new DateRange(new Date(0), new Date(0)); } /** * Adds the listener to receive single left-click events on the timeline. * * @param listener the listener to add */ public void addClickListener(ClickListener listener) {
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent; /** * Constructs the timeline. The timeline will default to showing an 8 hour * period starting "now" unless {@link #setWindow(java.util.Date, java.util.Date, org.mpilone.vaadin.timeline.TimelineMethodOptions.SetWindow) * } is called. * * @param caption the caption of the component * @param provider the provider of timeline items */ public Timeline(String caption, TimelineItemProvider provider) { setWidth("100%"); setCaption(caption); setItemProvider(provider); registerRpc(serverRpc); clientRpc = getRpcProxy(TimelineClientRpc.class); keyMapper = new DataProviderKeyMapper(); selection = new HashSet<>(); options = new StateMappingOptions(this); groups = new ArrayList<>(); window = new DateRange(new Date(0), new Date(0)); } /** * Adds the listener to receive single left-click events on the timeline. * * @param listener the listener to add */ public void addClickListener(ClickListener listener) {
addListener(ClickEvent.class, listener, ClickListener.METHOD);
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // }
import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent;
selection = new HashSet<>(); options = new StateMappingOptions(this); groups = new ArrayList<>(); window = new DateRange(new Date(0), new Date(0)); } /** * Adds the listener to receive single left-click events on the timeline. * * @param listener the listener to add */ public void addClickListener(ClickListener listener) { addListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Removes the listener to receive single left-click events on the timeline. * * @param listener the listener to remove */ public void removeClickListener(ClickListener listener) { removeListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Adds the listener to receive double left-click events on the timeline. * * @param listener the listener to add */ public void addDoubleClickListener(DoubleClickListener listener) {
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent; selection = new HashSet<>(); options = new StateMappingOptions(this); groups = new ArrayList<>(); window = new DateRange(new Date(0), new Date(0)); } /** * Adds the listener to receive single left-click events on the timeline. * * @param listener the listener to add */ public void addClickListener(ClickListener listener) { addListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Removes the listener to receive single left-click events on the timeline. * * @param listener the listener to remove */ public void removeClickListener(ClickListener listener) { removeListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Adds the listener to receive double left-click events on the timeline. * * @param listener the listener to add */ public void addDoubleClickListener(DoubleClickListener listener) {
addListener(DoubleClickEvent.class, listener, DoubleClickListener.METHOD);
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // }
import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent;
* @param listener the listener to remove */ public void removeClickListener(ClickListener listener) { removeListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Adds the listener to receive double left-click events on the timeline. * * @param listener the listener to add */ public void addDoubleClickListener(DoubleClickListener listener) { addListener(DoubleClickEvent.class, listener, DoubleClickListener.METHOD); } /** * Removes the listener to receive double left-click events on the timeline. * * @param listener the listener to remove */ public void removeClickListener(DoubleClickListener listener) { removeListener(DoubleClickEvent.class, listener, DoubleClickListener.METHOD); } /** * Adds the listener to receive right-click events on the timeline. * * @param listener the listener to add */ public void addContextMenuListener(ContextMenuListener listener) {
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java // public static class ClickEvent extends Component.Event { // // private final EventProperties props; // private final Object itemId; // // /** // * Constructs the event. // * // * @param source the source component // * @param itemId the ID of the item clicked or null // * @param props the event properties relayed from the client side // */ // public ClickEvent(Timeline source, Object itemId, EventProperties props) { // super(source); // this.props = props; // this.itemId = itemId; // } // // public Date getSnappedTime() { // return props.snappedTime; // } // // public Date getTime() { // return props.time; // } // // public String getWhat() { // return props.what; // } // // public Object getItem() { // return itemId; // } // // public String getGroup() { // return props.group; // } // // public int getY() { // return props.y; // } // // public int getX() { // return props.x; // } // // public int getPageY() { // return props.pageY; // } // // public int getPageX() { // return props.pageX; // } // // public Timeline getTimeline() { // return (Timeline) getSource(); // } // // @Override // public String toString() { // return props.toString(); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java // public static class ContextMenuEvent extends ClickListener.ClickEvent { // // public ContextMenuEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/DoubleClickListener.java // public static class DoubleClickEvent extends ClickListener.ClickEvent { // // public DoubleClickEvent(Timeline source, Object itemId, // EventProperties props) { // super(source, itemId, props); // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/Timeline.java import java.util.*; import org.mpilone.vaadin.timeline.ClickListener.ClickEvent; import org.mpilone.vaadin.timeline.ContextMenuListener.ContextMenuEvent; import org.mpilone.vaadin.timeline.DoubleClickListener.DoubleClickEvent; import org.mpilone.vaadin.timeline.shared.*; import com.vaadin.annotations.JavaScript; import com.vaadin.annotations.StyleSheet; import com.vaadin.ui.AbstractJavaScriptComponent; * @param listener the listener to remove */ public void removeClickListener(ClickListener listener) { removeListener(ClickEvent.class, listener, ClickListener.METHOD); } /** * Adds the listener to receive double left-click events on the timeline. * * @param listener the listener to add */ public void addDoubleClickListener(DoubleClickListener listener) { addListener(DoubleClickEvent.class, listener, DoubleClickListener.METHOD); } /** * Removes the listener to receive double left-click events on the timeline. * * @param listener the listener to remove */ public void removeClickListener(DoubleClickListener listener) { removeListener(DoubleClickEvent.class, listener, DoubleClickListener.METHOD); } /** * Adds the listener to receive right-click events on the timeline. * * @param listener the listener to add */ public void addContextMenuListener(ContextMenuListener listener) {
addListener(ContextMenuEvent.class, listener, ContextMenuListener.METHOD);
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/BasicTimelineItem.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java // public enum ItemType { // // BOX, // POINT, // RANGE, // BACKGROUND // }
import java.util.*; import org.mpilone.vaadin.timeline.TimelineOptions.ItemType;
package org.mpilone.vaadin.timeline; /** * A timeline event implementation that stores all the data as a simple Java * bean. * * @author mpilone */ public class BasicTimelineItem implements TimelineItem { private String styleName; private String content; private Date end; private String groupId; private Object id; private Date start; private String style; private String subgroupId; private String title;
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java // public enum ItemType { // // BOX, // POINT, // RANGE, // BACKGROUND // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/BasicTimelineItem.java import java.util.*; import org.mpilone.vaadin.timeline.TimelineOptions.ItemType; package org.mpilone.vaadin.timeline; /** * A timeline event implementation that stores all the data as a simple Java * bean. * * @author mpilone */ public class BasicTimelineItem implements TimelineItem { private String styleName; private String content; private Date end; private String groupId; private Object id; private Date start; private String style; private String subgroupId; private String title;
private ItemType type;
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineState.java // public class TimelineState extends JavaScriptComponentState { // // public Options options; // // public static class TimeAxis { // // public String scale; // public int step; // } // // public static class Editable { // // public boolean add; // public boolean remove; // public boolean updateGroup; // public boolean updateTime; // } // // public static class Format { // // public FormatLabels majorLabels; // public FormatLabels minorLabels; // } // // public static class FormatLabels { // // public String millisecond; // public String second; // public String minute; // public String hour; // public String weekday; // public String day; // public String month; // public String year; // } // // public static class Margin { // // public int axis; // public MarginItem item; // } // // public static class MarginItem { // // public int vertical; // public int horizontal; // } // // public static class Orientation { // // public String axis; // public String item; // } // // public static class Options { // // public String align; // public boolean autoResize; // public boolean clickToUse; // public Editable editable; // public Long end; // public Format format; // public String groupOrder; // public Margin margin; // public Long max; // public Long min; // public String moment; // public boolean moveable; // public boolean multiselect; // public Orientation orientation; // public boolean selectable; // public boolean showCurrentTime; // public boolean showMajorLabels; // public boolean showMinorLabels; // public boolean stack; // public Long start; // public TimeAxis timeAxis; // public String type; // public boolean zoomable; // public int zoomMax; // public int zoomMin; // } // // }
import java.util.Date; import org.mpilone.vaadin.timeline.shared.TimelineState;
package org.mpilone.vaadin.timeline; /** * The various options that can be configured on the timeline. Refer to * http://visjs.org/docs/timeline.html#Configuration_Options for detailed * documentation. * * @author mpilone */ public interface TimelineOptions { /** * When a Timeline is configured to be clickToUse, it will react to mouse and * touch events only when active. When active, a blue shadow border is * displayed around the Timeline. The Timeline is set active by clicking on * it, and is changed to inactive again by clicking outside the Timeline or by * pressing the ESC key. * * @return true if enabled */ public boolean isClickToUse(); /** * When a Timeline is configured to be clickToUse, it will react to mouse and * touch events only when active. * * @param enabled true to enable, false to disable */ public void setClickToUse(boolean enabled); public boolean isMoveable(); public void setMoveable(boolean moveable); public boolean isZoomable(); public void setZoomable(boolean zoomable); public boolean isSelectable(); public void setSelectable(boolean selectable); public ItemAlignment getAlign(); public void setAlign(ItemAlignment align); public boolean isAutoResize(); public void setAutoResize(boolean autoResize);
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineState.java // public class TimelineState extends JavaScriptComponentState { // // public Options options; // // public static class TimeAxis { // // public String scale; // public int step; // } // // public static class Editable { // // public boolean add; // public boolean remove; // public boolean updateGroup; // public boolean updateTime; // } // // public static class Format { // // public FormatLabels majorLabels; // public FormatLabels minorLabels; // } // // public static class FormatLabels { // // public String millisecond; // public String second; // public String minute; // public String hour; // public String weekday; // public String day; // public String month; // public String year; // } // // public static class Margin { // // public int axis; // public MarginItem item; // } // // public static class MarginItem { // // public int vertical; // public int horizontal; // } // // public static class Orientation { // // public String axis; // public String item; // } // // public static class Options { // // public String align; // public boolean autoResize; // public boolean clickToUse; // public Editable editable; // public Long end; // public Format format; // public String groupOrder; // public Margin margin; // public Long max; // public Long min; // public String moment; // public boolean moveable; // public boolean multiselect; // public Orientation orientation; // public boolean selectable; // public boolean showCurrentTime; // public boolean showMajorLabels; // public boolean showMinorLabels; // public boolean stack; // public Long start; // public TimeAxis timeAxis; // public String type; // public boolean zoomable; // public int zoomMax; // public int zoomMin; // } // // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java import java.util.Date; import org.mpilone.vaadin.timeline.shared.TimelineState; package org.mpilone.vaadin.timeline; /** * The various options that can be configured on the timeline. Refer to * http://visjs.org/docs/timeline.html#Configuration_Options for detailed * documentation. * * @author mpilone */ public interface TimelineOptions { /** * When a Timeline is configured to be clickToUse, it will react to mouse and * touch events only when active. When active, a blue shadow border is * displayed around the Timeline. The Timeline is set active by clicking on * it, and is changed to inactive again by clicking outside the Timeline or by * pressing the ESC key. * * @return true if enabled */ public boolean isClickToUse(); /** * When a Timeline is configured to be clickToUse, it will react to mouse and * touch events only when active. * * @param enabled true to enable, false to disable */ public void setClickToUse(boolean enabled); public boolean isMoveable(); public void setMoveable(boolean moveable); public boolean isZoomable(); public void setZoomable(boolean zoomable); public boolean isSelectable(); public void setSelectable(boolean selectable); public ItemAlignment getAlign(); public void setAlign(ItemAlignment align); public boolean isAutoResize(); public void setAutoResize(boolean autoResize);
public TimelineState.Editable getEditable();
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineItem.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java // public enum ItemType { // // BOX, // POINT, // RANGE, // BACKGROUND // }
import java.util.Date; import org.mpilone.vaadin.timeline.TimelineOptions.ItemType;
package org.mpilone.vaadin.timeline; /** * A timeline item that defines the required properties for events on the * timeline. * * @author mpilone */ public interface TimelineItem { /** * Returns the unique ID of this item. * * @return the unique ID of the item */ public Object getId(); /** * Returns the ID of the group that the event belongs to. All events with the * same group ID will be displayed together on the timeline in a single group * row. * * @return the name of the group or null if not in a group */ public String getGroupId(); /** * Gets start date of event. * * @return Start date. */ public Date getStart(); /** * Get end date of event. * * @return End date; */ public Date getEnd(); /** * Gets content text of event. * * @return content text */ public String getContent(); /** * Returns the type of the item. The item type determines how the item will be * rendered on the timeline. * * @return the item type or null for the timeline default */
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineOptions.java // public enum ItemType { // // BOX, // POINT, // RANGE, // BACKGROUND // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/TimelineItem.java import java.util.Date; import org.mpilone.vaadin.timeline.TimelineOptions.ItemType; package org.mpilone.vaadin.timeline; /** * A timeline item that defines the required properties for events on the * timeline. * * @author mpilone */ public interface TimelineItem { /** * Returns the unique ID of this item. * * @return the unique ID of the item */ public Object getId(); /** * Returns the ID of the group that the event belongs to. All events with the * same group ID will be displayed together on the timeline in a single group * row. * * @return the name of the group or null if not in a group */ public String getGroupId(); /** * Gets start date of event. * * @return Start date. */ public Date getStart(); /** * Get end date of event. * * @return End date; */ public Date getEnd(); /** * Gets content text of event. * * @return content text */ public String getContent(); /** * Returns the type of the item. The item type determines how the item will be * rendered on the timeline. * * @return the item type or null for the timeline default */
public ItemType getType();
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // }
import java.lang.reflect.Method; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.util.ReflectTools;
package org.mpilone.vaadin.timeline; /** * Listener for right-click events on the timeline. */ public interface ContextMenuListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(ContextMenuListener.class, "contextMenu", ContextMenuEvent.class); /** * The handler method called when the timeline is right-clicked. * * @param evt the event details */ void contextMenu(ContextMenuEvent evt); public static class ContextMenuEvent extends ClickListener.ClickEvent { public ContextMenuEvent(Timeline source, Object itemId,
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ContextMenuListener.java import java.lang.reflect.Method; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.util.ReflectTools; package org.mpilone.vaadin.timeline; /** * Listener for right-click events on the timeline. */ public interface ContextMenuListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(ContextMenuListener.class, "contextMenu", ContextMenuEvent.class); /** * The handler method called when the timeline is right-clicked. * * @param evt the event details */ void contextMenu(ContextMenuEvent evt); public static class ContextMenuEvent extends ClickListener.ClickEvent { public ContextMenuEvent(Timeline source, Object itemId,
EventProperties props) {
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // }
import java.lang.reflect.Method; import java.util.Date; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.ui.Component; import com.vaadin.util.ReflectTools;
package org.mpilone.vaadin.timeline; /** * Listener for click events on the timeline. */ public interface ClickListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(ClickListener.class, "click", ClickEvent.class); /** * The handler method called when the timeline is left-clicked. * * @param evt the event details */ void click(ClickEvent evt); /** * Event details for a click on the timeline. */ public static class ClickEvent extends Component.Event {
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/EventProperties.java // public class EventProperties { // // /** // * group (String, Number, or null): the id of the clicked group. // */ // public String group; // // /** // * item (String, Number, or null): the id of the clicked item. // */ // public String item; // // /** // * pageX (Number): absolute horizontal position of the click event. // */ // public int pageX; // // /** // * pageY (Number): absolute vertical position of the click event. // */ // public int pageY; // // /** // * x (Number): relative horizontal position of the click event. // */ // public int x; // // /** // * y (Number): relative vertical position of the click event. // */ // public int y; // // /** // * time (Date): Date of the clicked event. // */ // public Date time; // // /** // * snappedTime (Date): Date of the clicked event, snapped to a nice value. // */ // public Date snappedTime; // // /** // * what (String or null): name of the clicked thing: item, background, axis, // * group-label, custom-time, or current-time. // */ // public String what; // // // event (Object): the original click event. // @Override // public String toString() { // return "EventProperties{" + "group=" + group + ", item=" + item + ", pageX=" // + pageX + ", pageY=" + pageY + ", x=" + x + ", y=" + y + ", time=" // + time + ", snappedTime=" + snappedTime + ", what=" + what + '}'; // } // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/ClickListener.java import java.lang.reflect.Method; import java.util.Date; import org.mpilone.vaadin.timeline.shared.EventProperties; import com.vaadin.ui.Component; import com.vaadin.util.ReflectTools; package org.mpilone.vaadin.timeline; /** * Listener for click events on the timeline. */ public interface ClickListener { /** * The handler method in the listener. */ static final Method METHOD = ReflectTools.findMethod(ClickListener.class, "click", ClickEvent.class); /** * The handler method called when the timeline is left-clicked. * * @param evt the event details */ void click(ClickEvent evt); /** * Event details for a click on the timeline. */ public static class ClickEvent extends Component.Event {
private final EventProperties props;
mpilone/timeline-vaadin
timeline/src/main/java/org/mpilone/vaadin/timeline/StateMappingOptions.java
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineState.java // public class TimelineState extends JavaScriptComponentState { // // public Options options; // // public static class TimeAxis { // // public String scale; // public int step; // } // // public static class Editable { // // public boolean add; // public boolean remove; // public boolean updateGroup; // public boolean updateTime; // } // // public static class Format { // // public FormatLabels majorLabels; // public FormatLabels minorLabels; // } // // public static class FormatLabels { // // public String millisecond; // public String second; // public String minute; // public String hour; // public String weekday; // public String day; // public String month; // public String year; // } // // public static class Margin { // // public int axis; // public MarginItem item; // } // // public static class MarginItem { // // public int vertical; // public int horizontal; // } // // public static class Orientation { // // public String axis; // public String item; // } // // public static class Options { // // public String align; // public boolean autoResize; // public boolean clickToUse; // public Editable editable; // public Long end; // public Format format; // public String groupOrder; // public Margin margin; // public Long max; // public Long min; // public String moment; // public boolean moveable; // public boolean multiselect; // public Orientation orientation; // public boolean selectable; // public boolean showCurrentTime; // public boolean showMajorLabels; // public boolean showMinorLabels; // public boolean stack; // public Long start; // public TimeAxis timeAxis; // public String type; // public boolean zoomable; // public int zoomMax; // public int zoomMin; // } // // }
import java.util.Date; import org.mpilone.vaadin.timeline.shared.TimelineState;
package org.mpilone.vaadin.timeline; /** * An implementation of timeline options that maps all the options into the * {@link TimelineState}. This class is normally instantiated and used * internally by the {@link Timeline}. * * @author mpilone */ class StateMappingOptions implements TimelineOptions { private final Timeline timeline; /** * Constructs the options which will map all state changes to the state of the * given timeline. * * @param timeline the timeline to modify */ public StateMappingOptions(Timeline timeline) { this.timeline = timeline;
// Path: timeline/src/main/java/org/mpilone/vaadin/timeline/shared/TimelineState.java // public class TimelineState extends JavaScriptComponentState { // // public Options options; // // public static class TimeAxis { // // public String scale; // public int step; // } // // public static class Editable { // // public boolean add; // public boolean remove; // public boolean updateGroup; // public boolean updateTime; // } // // public static class Format { // // public FormatLabels majorLabels; // public FormatLabels minorLabels; // } // // public static class FormatLabels { // // public String millisecond; // public String second; // public String minute; // public String hour; // public String weekday; // public String day; // public String month; // public String year; // } // // public static class Margin { // // public int axis; // public MarginItem item; // } // // public static class MarginItem { // // public int vertical; // public int horizontal; // } // // public static class Orientation { // // public String axis; // public String item; // } // // public static class Options { // // public String align; // public boolean autoResize; // public boolean clickToUse; // public Editable editable; // public Long end; // public Format format; // public String groupOrder; // public Margin margin; // public Long max; // public Long min; // public String moment; // public boolean moveable; // public boolean multiselect; // public Orientation orientation; // public boolean selectable; // public boolean showCurrentTime; // public boolean showMajorLabels; // public boolean showMinorLabels; // public boolean stack; // public Long start; // public TimeAxis timeAxis; // public String type; // public boolean zoomable; // public int zoomMax; // public int zoomMin; // } // // } // Path: timeline/src/main/java/org/mpilone/vaadin/timeline/StateMappingOptions.java import java.util.Date; import org.mpilone.vaadin.timeline.shared.TimelineState; package org.mpilone.vaadin.timeline; /** * An implementation of timeline options that maps all the options into the * {@link TimelineState}. This class is normally instantiated and used * internally by the {@link Timeline}. * * @author mpilone */ class StateMappingOptions implements TimelineOptions { private final Timeline timeline; /** * Constructs the options which will map all state changes to the state of the * given timeline. * * @param timeline the timeline to modify */ public StateMappingOptions(Timeline timeline) { this.timeline = timeline;
TimelineState.Options o = new TimelineState.Options();
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/consumer/AbstractConsumerTest.java
// Path: src/test/java/com/hubrick/vertx/kafka/AbstractVertxTest.java // @RunWith(VertxUnitRunner.class) // public abstract class AbstractVertxTest { // protected Vertx vertx; // // @Before // public final void init(TestContext testContext) throws Exception { // vertx = Vertx.vertx(); // } // // @After // public final void destroy() throws Exception { // vertx.close(); // } // // protected abstract String getServiceName(); // // protected void deploy(TestContext testContext, DeploymentOptions deploymentOptions) throws InterruptedException { // CountDownLatch latch = new CountDownLatch(1); // vertx.deployVerticle(getServiceName(), deploymentOptions, result -> { // if (result.failed()) { // result.cause().printStackTrace(); // testContext.fail(); // } // latch.countDown(); // }); // // latch.await(30, TimeUnit.SECONDS); // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/consumer/property/KafkaConsumerProperties.java // public final class KafkaConsumerProperties { // // // private KafkaConsumerProperties() {} // // // public static final String KEY_VERTX_ADDRESS = "address"; // // public static final String KEY_CLIENT_ID = "clientId"; // public static final String KEY_GROUP_ID = "groupId"; // public static final String KEY_KAFKA_TOPIC = "kafkaTopic"; // public static final String KEY_BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String KEY_OFFSET_RESET = "offsetReset"; // public static final String KEY_MAX_UNACKNOWLEDGED = "maxUnacknowledged"; // public static final String KEY_MAX_UNCOMMITTED_OFFSETS = "maxUncommitted"; // public static final String KEY_ACK_TIMEOUT_SECONDS = "ackTimeoutSeconds"; // public static final String KEY_COMMIT_TIMEOUT_MS = "commitTimeoutMs"; // public static final String KEY_MAX_RETRIES = "maxRetries"; // public static final String KEY_INITIAL_RETRY_DELAY_SECONDS = "initialRetryDelaySeconds"; // public static final String KEY_MAX_RETRY_DELAY_SECONDS = "maxRetryDelaySeconds"; // public static final String KEY_EVENT_BUS_SEND_TIMEOUT = "eventBusSendTimeout"; // public static final String KEY_MESSAGES_PER_SECOND = "messagesPerSecond"; // public static final String KEY_COMMIT_ON_PARTITION_CHANGE = "commitOnPartitionChange"; // public static final String KEY_STRICT_ORDERING = "strictOrdering"; // public static final String KEY_MAX_POLL_RECORDS = "maxPollRecords"; // public static final String KEY_MAX_POLL_INTERVAL_MS = "maxPollIntervalMs"; // public static final String KEY_METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String KEY_METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // }
import com.hubrick.vertx.kafka.AbstractVertxTest; import com.hubrick.vertx.kafka.consumer.property.KafkaConsumerProperties; import io.vertx.core.json.JsonObject;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.consumer; public abstract class AbstractConsumerTest extends AbstractVertxTest { protected static String SERVICE_NAME = "service:com.hubrick.services.kafka-consumer"; static JsonObject makeDefaultConfig() { JsonObject config = new JsonObject();
// Path: src/test/java/com/hubrick/vertx/kafka/AbstractVertxTest.java // @RunWith(VertxUnitRunner.class) // public abstract class AbstractVertxTest { // protected Vertx vertx; // // @Before // public final void init(TestContext testContext) throws Exception { // vertx = Vertx.vertx(); // } // // @After // public final void destroy() throws Exception { // vertx.close(); // } // // protected abstract String getServiceName(); // // protected void deploy(TestContext testContext, DeploymentOptions deploymentOptions) throws InterruptedException { // CountDownLatch latch = new CountDownLatch(1); // vertx.deployVerticle(getServiceName(), deploymentOptions, result -> { // if (result.failed()) { // result.cause().printStackTrace(); // testContext.fail(); // } // latch.countDown(); // }); // // latch.await(30, TimeUnit.SECONDS); // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/consumer/property/KafkaConsumerProperties.java // public final class KafkaConsumerProperties { // // // private KafkaConsumerProperties() {} // // // public static final String KEY_VERTX_ADDRESS = "address"; // // public static final String KEY_CLIENT_ID = "clientId"; // public static final String KEY_GROUP_ID = "groupId"; // public static final String KEY_KAFKA_TOPIC = "kafkaTopic"; // public static final String KEY_BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String KEY_OFFSET_RESET = "offsetReset"; // public static final String KEY_MAX_UNACKNOWLEDGED = "maxUnacknowledged"; // public static final String KEY_MAX_UNCOMMITTED_OFFSETS = "maxUncommitted"; // public static final String KEY_ACK_TIMEOUT_SECONDS = "ackTimeoutSeconds"; // public static final String KEY_COMMIT_TIMEOUT_MS = "commitTimeoutMs"; // public static final String KEY_MAX_RETRIES = "maxRetries"; // public static final String KEY_INITIAL_RETRY_DELAY_SECONDS = "initialRetryDelaySeconds"; // public static final String KEY_MAX_RETRY_DELAY_SECONDS = "maxRetryDelaySeconds"; // public static final String KEY_EVENT_BUS_SEND_TIMEOUT = "eventBusSendTimeout"; // public static final String KEY_MESSAGES_PER_SECOND = "messagesPerSecond"; // public static final String KEY_COMMIT_ON_PARTITION_CHANGE = "commitOnPartitionChange"; // public static final String KEY_STRICT_ORDERING = "strictOrdering"; // public static final String KEY_MAX_POLL_RECORDS = "maxPollRecords"; // public static final String KEY_MAX_POLL_INTERVAL_MS = "maxPollIntervalMs"; // public static final String KEY_METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String KEY_METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // } // Path: src/test/java/com/hubrick/vertx/kafka/consumer/AbstractConsumerTest.java import com.hubrick.vertx.kafka.AbstractVertxTest; import com.hubrick.vertx.kafka.consumer.property.KafkaConsumerProperties; import io.vertx.core.json.JsonObject; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.consumer; public abstract class AbstractConsumerTest extends AbstractVertxTest { protected static String SERVICE_NAME = "service:com.hubrick.services.kafka-consumer"; static JsonObject makeDefaultConfig() { JsonObject config = new JsonObject();
config.put(KafkaConsumerProperties.KEY_VERTX_ADDRESS, "kafkaConsumer");
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/StatsDProperties.java // public final class StatsDProperties { // // /* Non-instantiable class */ // private StatsDProperties() {} // // public static final String PREFIX = "prefix"; // public static final String HOST = "host"; // public static final String PORT = "port"; // // public static final String PREFIX_DEFAULT = "vertx.kafka"; // public static final String HOST_DEFAULT = "localhost"; // public static final int PORT_DEFAULT = 8125; // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.hubrick.vertx.kafka.producer.property.StatsDProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with enabled StatsD configuration. The deployment should be successfull and * the executor call of StatsD should not fail. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithStatsdEnabledConfigIT!"; private static final String TOPIC = "some-topic"; @Test // The deployment should be successfull and StatsD executor call should also be successful public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/StatsDProperties.java // public final class StatsDProperties { // // /* Non-instantiable class */ // private StatsDProperties() {} // // public static final String PREFIX = "prefix"; // public static final String HOST = "host"; // public static final String PORT = "port"; // // public static final String PREFIX_DEFAULT = "vertx.kafka"; // public static final String HOST_DEFAULT = "localhost"; // public static final int PORT_DEFAULT = 8125; // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.hubrick.vertx.kafka.producer.property.StatsDProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with enabled StatsD configuration. The deployment should be successfull and * the executor call of StatsD should not fail. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithStatsdEnabledConfigIT!"; private static final String TOPIC = "some-topic"; @Test // The deployment should be successfull and StatsD executor call should also be successful public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/StatsDProperties.java // public final class StatsDProperties { // // /* Non-instantiable class */ // private StatsDProperties() {} // // public static final String PREFIX = "prefix"; // public static final String HOST = "host"; // public static final String PORT = "port"; // // public static final String PREFIX_DEFAULT = "vertx.kafka"; // public static final String HOST_DEFAULT = "localhost"; // public static final int PORT_DEFAULT = 8125; // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.hubrick.vertx.kafka.producer.property.StatsDProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with enabled StatsD configuration. The deployment should be successfull and * the executor call of StatsD should not fail. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithStatsdEnabledConfigIT!"; private static final String TOPIC = "some-topic"; @Test // The deployment should be successfull and StatsD executor call should also be successful public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); JsonObject statsDConfig = new JsonObject();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/StatsDProperties.java // public final class StatsDProperties { // // /* Non-instantiable class */ // private StatsDProperties() {} // // public static final String PREFIX = "prefix"; // public static final String HOST = "host"; // public static final String PORT = "port"; // // public static final String PREFIX_DEFAULT = "vertx.kafka"; // public static final String HOST_DEFAULT = "localhost"; // public static final int PORT_DEFAULT = 8125; // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.hubrick.vertx.kafka.producer.property.StatsDProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with enabled StatsD configuration. The deployment should be successfull and * the executor call of StatsD should not fail. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithStatsdEnabledConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithStatsdEnabledConfigIT!"; private static final String TOPIC = "some-topic"; @Test // The deployment should be successfull and StatsD executor call should also be successful public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); JsonObject statsDConfig = new JsonObject();
statsDConfig.put(StatsDProperties.HOST, "localhost");
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithCorrectConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying correct configuration with all required parameters. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithCorrectConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithCorrectConfigIT!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithCorrectConfigIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying correct configuration with all required parameters. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithCorrectConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithCorrectConfigIT!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithCorrectConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying correct configuration with all required parameters. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithCorrectConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithCorrectConfigIT!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { sendMessage(testContext, async); } catch (Exception e) { testContext.fail(e); } } public void sendMessage(TestContext testContext, Async async) throws Exception { final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS);
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithCorrectConfigIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying correct configuration with all required parameters. * <p/> * This test sends an event to Vert.x EventBus, then registers a handler to handle that event * and send it to Kafka broker, by creating Kafka Producer. It checks that the flow works correctly * until the point, where message is sent to Kafka. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithCorrectConfigIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test message from KafkaModuleDeployWithCorrectConfigIT!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { sendMessage(testContext, async); } catch (Exception e) { testContext.fail(e); } } public void sendMessage(TestContext testContext, Async async) throws Exception { final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS);
kafkaProducerService.sendString(new StringKafkaMessage(MESSAGE), (Handler<AsyncResult<Void>>) message -> {
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/consumer/KafkaConsumerDeployWithIncorrectConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/consumer/property/KafkaConsumerProperties.java // public final class KafkaConsumerProperties { // // // private KafkaConsumerProperties() {} // // // public static final String KEY_VERTX_ADDRESS = "address"; // // public static final String KEY_CLIENT_ID = "clientId"; // public static final String KEY_GROUP_ID = "groupId"; // public static final String KEY_KAFKA_TOPIC = "kafkaTopic"; // public static final String KEY_BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String KEY_OFFSET_RESET = "offsetReset"; // public static final String KEY_MAX_UNACKNOWLEDGED = "maxUnacknowledged"; // public static final String KEY_MAX_UNCOMMITTED_OFFSETS = "maxUncommitted"; // public static final String KEY_ACK_TIMEOUT_SECONDS = "ackTimeoutSeconds"; // public static final String KEY_COMMIT_TIMEOUT_MS = "commitTimeoutMs"; // public static final String KEY_MAX_RETRIES = "maxRetries"; // public static final String KEY_INITIAL_RETRY_DELAY_SECONDS = "initialRetryDelaySeconds"; // public static final String KEY_MAX_RETRY_DELAY_SECONDS = "maxRetryDelaySeconds"; // public static final String KEY_EVENT_BUS_SEND_TIMEOUT = "eventBusSendTimeout"; // public static final String KEY_MESSAGES_PER_SECOND = "messagesPerSecond"; // public static final String KEY_COMMIT_ON_PARTITION_CHANGE = "commitOnPartitionChange"; // public static final String KEY_STRICT_ORDERING = "strictOrdering"; // public static final String KEY_MAX_POLL_RECORDS = "maxPollRecords"; // public static final String KEY_MAX_POLL_INTERVAL_MS = "maxPollIntervalMs"; // public static final String KEY_METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String KEY_METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // }
import com.hubrick.vertx.kafka.consumer.property.KafkaConsumerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import org.junit.Test;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.consumer; public class KafkaConsumerDeployWithIncorrectConfigIntegrationTest extends AbstractConsumerTest { @Test public void testMissingAddressFailure(TestContext testContext) throws Exception { final JsonObject config = makeDefaultConfig();
// Path: src/main/java/com/hubrick/vertx/kafka/consumer/property/KafkaConsumerProperties.java // public final class KafkaConsumerProperties { // // // private KafkaConsumerProperties() {} // // // public static final String KEY_VERTX_ADDRESS = "address"; // // public static final String KEY_CLIENT_ID = "clientId"; // public static final String KEY_GROUP_ID = "groupId"; // public static final String KEY_KAFKA_TOPIC = "kafkaTopic"; // public static final String KEY_BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String KEY_OFFSET_RESET = "offsetReset"; // public static final String KEY_MAX_UNACKNOWLEDGED = "maxUnacknowledged"; // public static final String KEY_MAX_UNCOMMITTED_OFFSETS = "maxUncommitted"; // public static final String KEY_ACK_TIMEOUT_SECONDS = "ackTimeoutSeconds"; // public static final String KEY_COMMIT_TIMEOUT_MS = "commitTimeoutMs"; // public static final String KEY_MAX_RETRIES = "maxRetries"; // public static final String KEY_INITIAL_RETRY_DELAY_SECONDS = "initialRetryDelaySeconds"; // public static final String KEY_MAX_RETRY_DELAY_SECONDS = "maxRetryDelaySeconds"; // public static final String KEY_EVENT_BUS_SEND_TIMEOUT = "eventBusSendTimeout"; // public static final String KEY_MESSAGES_PER_SECOND = "messagesPerSecond"; // public static final String KEY_COMMIT_ON_PARTITION_CHANGE = "commitOnPartitionChange"; // public static final String KEY_STRICT_ORDERING = "strictOrdering"; // public static final String KEY_MAX_POLL_RECORDS = "maxPollRecords"; // public static final String KEY_MAX_POLL_INTERVAL_MS = "maxPollIntervalMs"; // public static final String KEY_METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String KEY_METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // } // Path: src/test/java/com/hubrick/vertx/kafka/consumer/KafkaConsumerDeployWithIncorrectConfigIntegrationTest.java import com.hubrick.vertx.kafka.consumer.property.KafkaConsumerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import org.junit.Test; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.consumer; public class KafkaConsumerDeployWithIncorrectConfigIntegrationTest extends AbstractConsumerTest { @Test public void testMissingAddressFailure(TestContext testContext) throws Exception { final JsonObject config = makeDefaultConfig();
config.put(KafkaConsumerProperties.KEY_VERTX_ADDRESS, (String) null);
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithIncorrectConfigIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying incorrect configuration with missing required parameter. * Then verifies that deployment of module fails with a message, that missing parameter should be specified. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithIncorrectConfigIntegrationTest extends AbstractProducerTest { private static final String TOPIC = "some-topic"; @Test // The test should fail to start the deployment public void sendMessage(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaModuleDeployWithIncorrectConfigIntegrationTest.java import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module specifying incorrect configuration with missing required parameter. * Then verifies that deployment of module fails with a message, that missing parameter should be specified. */ @RunWith(VertxUnitRunner.class) public class KafkaModuleDeployWithIncorrectConfigIntegrationTest extends AbstractProducerTest { private static final String TOPIC = "some-topic"; @Test // The test should fail to start the deployment public void sendMessage(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC);
hubrick/vertx-kafka-service
src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // Path: src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore
default void sendString(StringKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) {
hubrick/vertx-kafka-service
src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore default void sendString(StringKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) {
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // Path: src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore default void sendString(StringKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) {
sendString(message, new KafkaOptions(), resultHandler);
hubrick/vertx-kafka-service
src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore default void sendString(StringKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) { sendString(message, new KafkaOptions(), resultHandler); } void sendString(StringKafkaMessage message, KafkaOptions options, Handler<AsyncResult<Void>> resultHandler); @ProxyIgnore @GenIgnore
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/KafkaOptions.java // @DataObject // public class KafkaOptions { // // public static final String TOPIC = "topic"; // // private String topic; // // public KafkaOptions() {} // // public KafkaOptions(KafkaOptions kafkaOptions) { // this.topic = kafkaOptions.getTopic(); // } // // public KafkaOptions(JsonObject jsonObject) { // this.topic = jsonObject.getString(TOPIC); // } // // public String getTopic() { // return topic; // } // // @Fluent // public KafkaOptions setTopic(String topic) { // this.topic = topic; // return this; // } // // public JsonObject toJson() { // final JsonObject jsonObject = new JsonObject(); // if(topic != null) { // jsonObject.put(TOPIC, topic); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // Path: src/main/java/com/hubrick/vertx/kafka/producer/KafkaProducerService.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.model.KafkaOptions; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import io.vertx.codegen.annotations.GenIgnore; import io.vertx.codegen.annotations.ProxyGen; import io.vertx.codegen.annotations.ProxyIgnore; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.eventbus.DeliveryOptions; import io.vertx.serviceproxy.ProxyHelper; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ @ProxyGen public interface KafkaProducerService { static KafkaProducerService createProxy(Vertx vertx, String address) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address); } static KafkaProducerService createProxyWithTimeout(Vertx vertx, String address, Long timeout) { return ProxyHelper.createProxy(KafkaProducerService.class, vertx, address, new DeliveryOptions().setSendTimeout(timeout)); } @ProxyIgnore void start(); @ProxyIgnore void stop(); @ProxyIgnore @GenIgnore default void sendString(StringKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) { sendString(message, new KafkaOptions(), resultHandler); } void sendString(StringKafkaMessage message, KafkaOptions options, Handler<AsyncResult<Void>> resultHandler); @ProxyIgnore @GenIgnore
default void sendBytes(ByteKafkaMessage message, Handler<AsyncResult<Void>> resultHandler) {
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/ByteArraySerializerIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with byte array serializer configuration. */ @RunWith(VertxUnitRunner.class) public class ByteArraySerializerIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test bytes message!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/ByteArraySerializerIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with byte array serializer configuration. */ @RunWith(VertxUnitRunner.class) public class ByteArraySerializerIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test bytes message!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig();
config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/ByteArraySerializerIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with byte array serializer configuration. */ @RunWith(VertxUnitRunner.class) public class ByteArraySerializerIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test bytes message!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS);
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/ByteArraySerializerIntegrationTest.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import org.junit.Test; import org.junit.runner.RunWith; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * Tests mod-kafka module with byte array serializer configuration. */ @RunWith(VertxUnitRunner.class) public class ByteArraySerializerIntegrationTest extends AbstractProducerTest { private static final String ADDRESS = "default-address"; private static final String MESSAGE = "Test bytes message!"; private static final String TOPIC = "some-topic"; @Test public void test(TestContext testContext) throws Exception { JsonObject config = makeDefaultConfig(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { final KafkaProducerService kafkaProducerService = KafkaProducerService.createProxy(vertx, ADDRESS);
kafkaProducerService.sendBytes(new ByteKafkaMessage(Buffer.buffer(MESSAGE.getBytes())), (Handler<AsyncResult<Void>>) message -> {
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/AbstractProducerTest.java
// Path: src/test/java/com/hubrick/vertx/kafka/AbstractVertxTest.java // @RunWith(VertxUnitRunner.class) // public abstract class AbstractVertxTest { // protected Vertx vertx; // // @Before // public final void init(TestContext testContext) throws Exception { // vertx = Vertx.vertx(); // } // // @After // public final void destroy() throws Exception { // vertx.close(); // } // // protected abstract String getServiceName(); // // protected void deploy(TestContext testContext, DeploymentOptions deploymentOptions) throws InterruptedException { // CountDownLatch latch = new CountDownLatch(1); // vertx.deployVerticle(getServiceName(), deploymentOptions, result -> { // if (result.failed()) { // result.cause().printStackTrace(); // testContext.fail(); // } // latch.countDown(); // }); // // latch.await(30, TimeUnit.SECONDS); // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.AbstractVertxTest; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.json.JsonObject;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ public abstract class AbstractProducerTest extends AbstractVertxTest { protected static String SERVICE_NAME = "service:com.hubrick.services.kafka-producer"; static JsonObject makeDefaultConfig() { JsonObject config = new JsonObject();
// Path: src/test/java/com/hubrick/vertx/kafka/AbstractVertxTest.java // @RunWith(VertxUnitRunner.class) // public abstract class AbstractVertxTest { // protected Vertx vertx; // // @Before // public final void init(TestContext testContext) throws Exception { // vertx = Vertx.vertx(); // } // // @After // public final void destroy() throws Exception { // vertx.close(); // } // // protected abstract String getServiceName(); // // protected void deploy(TestContext testContext, DeploymentOptions deploymentOptions) throws InterruptedException { // CountDownLatch latch = new CountDownLatch(1); // vertx.deployVerticle(getServiceName(), deploymentOptions, result -> { // if (result.failed()) { // result.cause().printStackTrace(); // testContext.fail(); // } // latch.countDown(); // }); // // latch.await(30, TimeUnit.SECONDS); // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/AbstractProducerTest.java import com.hubrick.vertx.kafka.AbstractVertxTest; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.json.JsonObject; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ public abstract class AbstractProducerTest extends AbstractVertxTest { protected static String SERVICE_NAME = "service:com.hubrick.services.kafka-producer"; static JsonObject makeDefaultConfig() { JsonObject config = new JsonObject();
config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT);
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/KafkaProducerServiceIntegrationTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.google.common.collect.Lists; import com.googlecode.junittoolbox.PollingWait; import com.googlecode.junittoolbox.RunnableAssert; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.netflix.curator.test.TestingServer; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import kafka.admin.AdminUtils; import kafka.admin.RackAwareMode; import kafka.consumer.ConsumerConfig; import kafka.consumer.ConsumerIterator; import kafka.consumer.KafkaStream; import kafka.javaapi.consumer.ConsumerConnector; import kafka.serializer.StringDecoder; import kafka.server.KafkaConfig; import kafka.server.KafkaServer; import kafka.utils.TestUtils; import kafka.utils.VerifiableProperties; import kafka.utils.ZKStringSerializer$; import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.apache.kafka.common.security.auth.SecurityProtocol; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import scala.Option; import scala.collection.JavaConversions; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.TimeUnit; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
private void startZookeeper() { try { zookeeper = new TestingServer(); } catch (Exception e) { throw new RuntimeException(e); } } @Test public void test(TestContext testContext) throws Exception { JsonObject config = new JsonObject(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { shouldReceiveMessage(testContext, async); } catch (Exception e) { testContext.fail(e); } } public void shouldReceiveMessage(TestContext testContext, Async async) throws Exception {
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java // @DataObject // public class StringKafkaMessage extends AbstractKafkaMessage { // // private String payload; // // public StringKafkaMessage() { // } // // public StringKafkaMessage(String payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(String payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) { // super(stringKafkaMessage.getPartKey()); // this.payload = stringKafkaMessage.getPayload(); // } // // public StringKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getString(PAYLOAD); // } // // public String getPayload() { // return payload; // } // // public void setPayload(String payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, getPayload()); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaProducerServiceIntegrationTest.java import com.google.common.collect.Lists; import com.googlecode.junittoolbox.PollingWait; import com.googlecode.junittoolbox.RunnableAssert; import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import com.netflix.curator.test.TestingServer; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import kafka.admin.AdminUtils; import kafka.admin.RackAwareMode; import kafka.consumer.ConsumerConfig; import kafka.consumer.ConsumerIterator; import kafka.consumer.KafkaStream; import kafka.javaapi.consumer.ConsumerConnector; import kafka.serializer.StringDecoder; import kafka.server.KafkaConfig; import kafka.server.KafkaServer; import kafka.utils.TestUtils; import kafka.utils.VerifiableProperties; import kafka.utils.ZKStringSerializer$; import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.ZkConnection; import org.apache.kafka.common.security.auth.SecurityProtocol; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import scala.Option; import scala.collection.JavaConversions; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.TimeUnit; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; private void startZookeeper() { try { zookeeper = new TestingServer(); } catch (Exception e) { throw new RuntimeException(e); } } @Test public void test(TestContext testContext) throws Exception { JsonObject config = new JsonObject(); config.put(KafkaProducerProperties.ADDRESS, ADDRESS); config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT); config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC); config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT); final DeploymentOptions deploymentOptions = new DeploymentOptions(); deploymentOptions.setConfig(config); deploy(testContext, deploymentOptions); final Async async = testContext.async(); try { shouldReceiveMessage(testContext, async); } catch (Exception e) { testContext.fail(e); } } public void shouldReceiveMessage(TestContext testContext, Async async) throws Exception {
final StringKafkaMessage stringKafkaMessage = new StringKafkaMessage("foobar", "bar");
hubrick/vertx-kafka-service
src/test/java/com/hubrick/vertx/kafka/producer/ManualTest.java
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // }
import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject;
/** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ public class ManualTest { public static void main(String[] args) { JsonObject config = new JsonObject();
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/ByteKafkaMessage.java // @DataObject(generateConverter = true) // public class ByteKafkaMessage extends AbstractKafkaMessage { // // private Buffer payload; // // public ByteKafkaMessage() { // } // // public ByteKafkaMessage(Buffer payload) { // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(Buffer payload, String partKey) { // super(partKey); // checkNotNull(payload, "payload must not be null"); // // this.payload = payload; // } // // public ByteKafkaMessage(ByteKafkaMessage byteKafkaMessage) { // super(byteKafkaMessage.getPartKey()); // checkNotNull(payload, "payload must not be null"); // // this.payload = byteKafkaMessage.getPayload(); // } // // public ByteKafkaMessage(JsonObject jsonObject) { // super(jsonObject.getString(PART_KEY)); // this.payload = jsonObject.getBinary(PAYLOAD) != null ? Buffer.buffer(jsonObject.getBinary(PAYLOAD)) : null; // } // // public Buffer getPayload() { // return payload; // } // // public void setPayload(Buffer payload) { // this.payload = payload; // } // // public JsonObject toJson() { // final JsonObject jsonObject = super.asJson(); // if (getPayload() != null) { // jsonObject.put(PAYLOAD, payload != null ? payload.getBytes() : null); // } // return jsonObject; // } // } // // Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java // public final class KafkaProducerProperties { // // /* Non-instantiable class */ // private KafkaProducerProperties() {} // // public static final String ADDRESS = "address"; // public static final String BOOTSTRAP_SERVERS = "bootstrapServers"; // public static final String ACKS = "acks"; // public static final String DEFAULT_TOPIC = "defaultTopic"; // public static final String TYPE = "type"; // public static final String MAX_RETRIES = "maxRetries"; // public static final String RETRY_BACKOFF_MS = "retryBackoffMs"; // public static final String BUFFERING_MAX_MS = "bufferingMaxMs"; // public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages"; // public static final String ENQUEUE_TIMEOUT = "enqueueTimeout"; // public static final String BATCH_MESSAGE_NUM = "batchMessageNum"; // public static final String RETRIES = "retries"; // public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs"; // public static final String MAX_BLOCK_MS = "maxBlockMs"; // public static final String STATSD = "statsD"; // public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses"; // public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName"; // // public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092"; // public static final String ACKS_DEFAULT = "1"; // // public static final int RETRIES_DEFAULT = 0; // public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000; // public static final int MAX_BLOCK_MS_DEFAULT = 60000; // // } // Path: src/test/java/com/hubrick/vertx/kafka/producer/ManualTest.java import com.hubrick.vertx.kafka.producer.model.ByteKafkaMessage; import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties; import io.vertx.core.DeploymentOptions; import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; /** * Copyright (C) 2016 Etaia AS (oss@hubrick.com) * * 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 com.hubrick.vertx.kafka.producer; /** * @author Emir Dizdarevic * @since 1.0.0 */ public class ManualTest { public static void main(String[] args) { JsonObject config = new JsonObject();
config.put(KafkaProducerProperties.ADDRESS, "test-address");