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
rla/while
language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override
public Void visitDiv(Div div, Void e1, Void e2) {
rla/while
language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override
public Void visitGt(Gt gt, Void e1, Void e2) {
rla/while
language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override public Void visitGt(Gt gt, Void e1, Void e2) { setId(gt); return null; } @Override
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Expression visitor that gives each expression an unique identifier. * Identifiers start from 0. * * @author Raivo Laanemets */ public class ExpressionNumberingVisitor extends AbstractExpressionVisitor<Void> { private int expressionId = 0; @Override public Void visitConstant(Constant constant) { setId(constant); return null; } @Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override public Void visitGt(Gt gt, Void e1, Void e2) { setId(gt); return null; } @Override
public Void visitIdentifier(Identifier identifier) {
rla/while
language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
@Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override public Void visitGt(Gt gt, Void e1, Void e2) { setId(gt); return null; } @Override public Void visitIdentifier(Identifier identifier) { setId(identifier); return null; } @Override public Void visitInput(Input input) { setId(input); return null; } @Override public Void visitSub(Sub sub, Void e1, Void e2) { setId(sub); return null; }
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/ExpressionNumberingVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; @Override public Void visitDiv(Div div, Void e1, Void e2) { setId(div); return null; } @Override public Void visitGt(Gt gt, Void e1, Void e2) { setId(gt); return null; } @Override public Void visitIdentifier(Identifier identifier) { setId(identifier); return null; } @Override public Void visitInput(Input input) { setId(input); return null; } @Override public Void visitSub(Sub sub, Void e1, Void e2) { setId(sub); return null; }
private void setId(Expression e) {
rla/while
src/com/infdot/analysis/solver/lattice/map/AllJoinOperation.java
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/ElementJoinOperation.java // public interface ElementJoinOperation<V> { // V join(V e1, V e2); // } // // Path: src/com/infdot/analysis/util/StringUtil.java // public class StringUtil { // // public static String join(Collection<?> col, String separator) { // StringBuilder builder = new StringBuilder(); // // boolean first = true; // for (Object o : col) { // if (first) { // first = false; // } else { // builder.append(separator); // } // builder.append(o); // } // // return builder.toString(); // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.ElementJoinOperation; import com.infdot.analysis.util.StringUtil;
package com.infdot.analysis.solver.lattice.map; /** * Join (least upper bound) for map lattices. * * @author Raivo Laanemets * * @param <K> type of map key * @param <V> type of map value */ public class AllJoinOperation<K, V> implements DataflowExpression<Map<K, V>> { private List<DataflowExpression<Map<K, V>>> expressions;
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/ElementJoinOperation.java // public interface ElementJoinOperation<V> { // V join(V e1, V e2); // } // // Path: src/com/infdot/analysis/util/StringUtil.java // public class StringUtil { // // public static String join(Collection<?> col, String separator) { // StringBuilder builder = new StringBuilder(); // // boolean first = true; // for (Object o : col) { // if (first) { // first = false; // } else { // builder.append(separator); // } // builder.append(o); // } // // return builder.toString(); // } // } // Path: src/com/infdot/analysis/solver/lattice/map/AllJoinOperation.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.ElementJoinOperation; import com.infdot.analysis.util.StringUtil; package com.infdot.analysis.solver.lattice.map; /** * Join (least upper bound) for map lattices. * * @author Raivo Laanemets * * @param <K> type of map key * @param <V> type of map value */ public class AllJoinOperation<K, V> implements DataflowExpression<Map<K, V>> { private List<DataflowExpression<Map<K, V>>> expressions;
private ElementJoinOperation<V> elementJoin;
rla/while
src/com/infdot/analysis/solver/lattice/map/AllJoinOperation.java
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/ElementJoinOperation.java // public interface ElementJoinOperation<V> { // V join(V e1, V e2); // } // // Path: src/com/infdot/analysis/util/StringUtil.java // public class StringUtil { // // public static String join(Collection<?> col, String separator) { // StringBuilder builder = new StringBuilder(); // // boolean first = true; // for (Object o : col) { // if (first) { // first = false; // } else { // builder.append(separator); // } // builder.append(o); // } // // return builder.toString(); // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.ElementJoinOperation; import com.infdot.analysis.util.StringUtil;
Map<K, V> result = new HashMap<K, V>(expressions.get(0).eval(values)); for (DataflowExpression<Map<K, V>> e : expressions.subList(1, expressions.size())) { joinInto(result, e.eval(values)); } return result; } private void joinInto(Map<K, V> result, Map<K, V> joinable) { for (K k : result.keySet()) { result.put(k, elementJoin.join(result.get(k), joinable.get(k))); } for (K k : joinable.keySet()) { if (!result.containsKey(k)) { result.put(k, elementJoin.join(result.get(k), joinable.get(k))); } } } @Override public void collectVariables(Set<Integer> variables) { for (DataflowExpression<Map<K, V>> e : expressions) { e.collectVariables(variables); } } @Override public String toString() {
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/ElementJoinOperation.java // public interface ElementJoinOperation<V> { // V join(V e1, V e2); // } // // Path: src/com/infdot/analysis/util/StringUtil.java // public class StringUtil { // // public static String join(Collection<?> col, String separator) { // StringBuilder builder = new StringBuilder(); // // boolean first = true; // for (Object o : col) { // if (first) { // first = false; // } else { // builder.append(separator); // } // builder.append(o); // } // // return builder.toString(); // } // } // Path: src/com/infdot/analysis/solver/lattice/map/AllJoinOperation.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.ElementJoinOperation; import com.infdot.analysis.util.StringUtil; Map<K, V> result = new HashMap<K, V>(expressions.get(0).eval(values)); for (DataflowExpression<Map<K, V>> e : expressions.subList(1, expressions.size())) { joinInto(result, e.eval(values)); } return result; } private void joinInto(Map<K, V> result, Map<K, V> joinable) { for (K k : result.keySet()) { result.put(k, elementJoin.join(result.get(k), joinable.get(k))); } for (K k : joinable.keySet()) { if (!result.containsKey(k)) { result.put(k, elementJoin.join(result.get(k), joinable.get(k))); } } } @Override public void collectVariables(Set<Integer> variables) { for (DataflowExpression<Map<K, V>> e : expressions) { e.collectVariables(variables); } } @Override public String toString() {
return "ALLJOIN(" + StringUtil.join(expressions, ",") + ")";
rla/while
src/com/infdot/analysis/solver/lattice/map/ModifyWithEvalOperation.java
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/util/Transform.java // public interface Transform<T1, T2> { // T2 apply(T1 o); // }
import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.util.Transform;
package com.infdot.analysis.solver.lattice.map; /** * Implements map modification where value depends * on dataflow variable values. * * @author Raivo Laanemets */ public class ModifyWithEvalOperation<K, V> implements DataflowExpression<Map<K, V>> { private DataflowExpression<Map<K, V>> map; private K key;
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/util/Transform.java // public interface Transform<T1, T2> { // T2 apply(T1 o); // } // Path: src/com/infdot/analysis/solver/lattice/map/ModifyWithEvalOperation.java import java.util.Map; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.util.Transform; package com.infdot.analysis.solver.lattice.map; /** * Implements map modification where value depends * on dataflow variable values. * * @author Raivo Laanemets */ public class ModifyWithEvalOperation<K, V> implements DataflowExpression<Map<K, V>> { private DataflowExpression<Map<K, V>> map; private K key;
private Transform<Map<K, V>, V> exp;
rla/while
src/com/infdot/analysis/cfg/node/AbstractNode.java
// Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java // public abstract class AbstractNodeVisitor<V> { // // private Map<AbstractNode, DataflowExpression<V>> visited = // new HashMap<AbstractNode, DataflowExpression<V>>(); // // private int currentVarId = 0; // private Map<AbstractNode, Integer> variables = // new HashMap<AbstractNode, Integer>(); // // public abstract void visitAssignment(AssignmentNode node); // // public abstract void visitDeclaration(DeclarationNode node); // // public abstract void visitExit(ExitNode node); // // public abstract void visitOutput(OutputNode node); // // public abstract void visitCondition(ConditionNode node); // // public abstract void visitEntry(EntryNode node); // // public boolean hasVisited(AbstractNode node) { // return visited.containsKey(node); // } // // public void markVisited(AbstractNode node) { // visited.put(node, null); // } // // protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) { // visited.put(node, expression); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // // for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) { // builder.append("[[").append(e.getKey()).append("]]") // .append(" = ").append(e.getValue()).append('\n'); // } // // return builder.toString(); // } // // /** // * Returns collected dataflow expressions. // */ // public Map<AbstractNode, DataflowExpression<V>> getExpressions() { // return visited; // } // // /** // * Helper method to generate variable id from given node. // * For this analysis each node is a variable. // */ // protected int getVariableId(AbstractNode node) { // Integer id = variables.get(node); // if (id == null) { // id = currentVarId++; // variables.put(node, id); // } // // return id; // } // // /** // * Creates constraint set from found expressions. // */ // public DataflowConstraintSet<V, AbstractNode> getConstraints() { // // DataflowConstraintSet<V, AbstractNode> set = // new DataflowConstraintSet<V, AbstractNode>(); // // for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) { // // // Ignore if there is no constraint // // for the node. // if (e.getValue() == null) { // continue; // } // // set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey()); // } // // return set; // } // // }
import java.util.HashSet; import java.util.Set; import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor;
package com.infdot.analysis.cfg.node; public abstract class AbstractNode { private Set<AbstractNode> successors = new HashSet<AbstractNode>(); private Set<AbstractNode> predecessors = new HashSet<AbstractNode>(); /** * Adds given successor to this node. This node will be * automatically added to the given node's predecessors. */ public void addSuccessor(AbstractNode n) { successors.add(n); n.predecessors.add(this); } /** * Returns all successors of this node. */ public Set<AbstractNode> getSuccessors() { return successors; } public Set<AbstractNode> getPredecessors() { return predecessors; }
// Path: src/com/infdot/analysis/cfg/node/visitor/AbstractNodeVisitor.java // public abstract class AbstractNodeVisitor<V> { // // private Map<AbstractNode, DataflowExpression<V>> visited = // new HashMap<AbstractNode, DataflowExpression<V>>(); // // private int currentVarId = 0; // private Map<AbstractNode, Integer> variables = // new HashMap<AbstractNode, Integer>(); // // public abstract void visitAssignment(AssignmentNode node); // // public abstract void visitDeclaration(DeclarationNode node); // // public abstract void visitExit(ExitNode node); // // public abstract void visitOutput(OutputNode node); // // public abstract void visitCondition(ConditionNode node); // // public abstract void visitEntry(EntryNode node); // // public boolean hasVisited(AbstractNode node) { // return visited.containsKey(node); // } // // public void markVisited(AbstractNode node) { // visited.put(node, null); // } // // protected void setConstraint(AbstractNode node, DataflowExpression<V> expression) { // visited.put(node, expression); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // // for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) { // builder.append("[[").append(e.getKey()).append("]]") // .append(" = ").append(e.getValue()).append('\n'); // } // // return builder.toString(); // } // // /** // * Returns collected dataflow expressions. // */ // public Map<AbstractNode, DataflowExpression<V>> getExpressions() { // return visited; // } // // /** // * Helper method to generate variable id from given node. // * For this analysis each node is a variable. // */ // protected int getVariableId(AbstractNode node) { // Integer id = variables.get(node); // if (id == null) { // id = currentVarId++; // variables.put(node, id); // } // // return id; // } // // /** // * Creates constraint set from found expressions. // */ // public DataflowConstraintSet<V, AbstractNode> getConstraints() { // // DataflowConstraintSet<V, AbstractNode> set = // new DataflowConstraintSet<V, AbstractNode>(); // // for (Entry<AbstractNode, DataflowExpression<V>> e : visited.entrySet()) { // // // Ignore if there is no constraint // // for the node. // if (e.getValue() == null) { // continue; // } // // set.addConstraint(getVariableId(e.getKey()), e.getValue(), e.getKey()); // } // // return set; // } // // } // Path: src/com/infdot/analysis/cfg/node/AbstractNode.java import java.util.HashSet; import java.util.Set; import com.infdot.analysis.cfg.node.visitor.AbstractNodeVisitor; package com.infdot.analysis.cfg.node; public abstract class AbstractNode { private Set<AbstractNode> successors = new HashSet<AbstractNode>(); private Set<AbstractNode> predecessors = new HashSet<AbstractNode>(); /** * Adds given successor to this node. This node will be * automatically added to the given node's predecessors. */ public void addSuccessor(AbstractNode n) { successors.add(n); n.predecessors.add(this); } /** * Returns all successors of this node. */ public Set<AbstractNode> getSuccessors() { return successors; } public Set<AbstractNode> getPredecessors() { return predecessors; }
public <V> void visitNodes(AbstractNodeVisitor<V> visitor) {
rla/while
language/src/com/infdot/analysis/language/expression/Sub.java
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // }
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression; public class Sub extends AbstractBinaryOperator { public Sub(String name, int value) { super("-", name, value); } public Sub(String name1, String name2) { super("-", name1, name2); } public Sub(Expression e1, Expression e2) { super("-", e1, e2); } @Override
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // } // Path: language/src/com/infdot/analysis/language/expression/Sub.java import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; package com.infdot.analysis.language.expression; public class Sub extends AbstractBinaryOperator { public Sub(String name, int value) { super("-", name, value); } public Sub(String name1, String name2) { super("-", name1, name2); } public Sub(Expression e1, Expression e2) { super("-", e1, e2); } @Override
protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
rla/while
src/com/infdot/analysis/solver/DataflowVariable.java
// Path: src/com/infdot/analysis/cfg/node/AbstractNode.java // public abstract class AbstractNode { // private Set<AbstractNode> successors = new HashSet<AbstractNode>(); // private Set<AbstractNode> predecessors = new HashSet<AbstractNode>(); // // /** // * Adds given successor to this node. This node will be // * automatically added to the given node's predecessors. // */ // public void addSuccessor(AbstractNode n) { // successors.add(n); // n.predecessors.add(this); // } // // /** // * Returns all successors of this node. // */ // public Set<AbstractNode> getSuccessors() { // return successors; // } // // public Set<AbstractNode> getPredecessors() { // return predecessors; // } // // public <V> void visitNodes(AbstractNodeVisitor<V> visitor) { // if (!visitor.hasVisited(this)) { // visit(visitor); // // for (AbstractNode node : predecessors) { // node.visitNodes(visitor); // } // // for (AbstractNode node : successors) { // node.visitNodes(visitor); // } // } // } // // protected abstract <V> void visit(AbstractNodeVisitor<V> visitor); // // @Override // public boolean equals(Object obj) { // throw new UnsupportedOperationException("Subclasses of AbstractNode must implement equals method"); // } // // @Override // public int hashCode() { // throw new UnsupportedOperationException("Subclasses of AbstractNode must implement hashCode method"); // } // // }
import java.util.Set; import com.infdot.analysis.cfg.node.AbstractNode;
package com.infdot.analysis.solver; /** * Dataflow variable. Assumes that each variable can have * unique integer identificator defined by specific analysis. * * @author Raivo Laanemets */ public class DataflowVariable<V> implements DataflowExpression<V> { private int id;
// Path: src/com/infdot/analysis/cfg/node/AbstractNode.java // public abstract class AbstractNode { // private Set<AbstractNode> successors = new HashSet<AbstractNode>(); // private Set<AbstractNode> predecessors = new HashSet<AbstractNode>(); // // /** // * Adds given successor to this node. This node will be // * automatically added to the given node's predecessors. // */ // public void addSuccessor(AbstractNode n) { // successors.add(n); // n.predecessors.add(this); // } // // /** // * Returns all successors of this node. // */ // public Set<AbstractNode> getSuccessors() { // return successors; // } // // public Set<AbstractNode> getPredecessors() { // return predecessors; // } // // public <V> void visitNodes(AbstractNodeVisitor<V> visitor) { // if (!visitor.hasVisited(this)) { // visit(visitor); // // for (AbstractNode node : predecessors) { // node.visitNodes(visitor); // } // // for (AbstractNode node : successors) { // node.visitNodes(visitor); // } // } // } // // protected abstract <V> void visit(AbstractNodeVisitor<V> visitor); // // @Override // public boolean equals(Object obj) { // throw new UnsupportedOperationException("Subclasses of AbstractNode must implement equals method"); // } // // @Override // public int hashCode() { // throw new UnsupportedOperationException("Subclasses of AbstractNode must implement hashCode method"); // } // // } // Path: src/com/infdot/analysis/solver/DataflowVariable.java import java.util.Set; import com.infdot.analysis.cfg.node.AbstractNode; package com.infdot.analysis.solver; /** * Dataflow variable. Assumes that each variable can have * unique integer identificator defined by specific analysis. * * @author Raivo Laanemets */ public class DataflowVariable<V> implements DataflowExpression<V> { private int id;
private AbstractNode node;
rla/while
language/src/com/infdot/analysis/language/expression/Identifier.java
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // }
import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression; public class Identifier extends Expression { private String name; public Identifier(String name) { this.name = name; } @Override public String toString() { return name; } @Override public void collectVariables(Set<Identifier> variables) { variables.add(this); } @Override
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // } // Path: language/src/com/infdot/analysis/language/expression/Identifier.java import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; package com.infdot.analysis.language.expression; public class Identifier extends Expression { private String name; public Identifier(String name) { this.name = name; } @Override public String toString() { return name; } @Override public void collectVariables(Set<Identifier> variables) { variables.add(this); } @Override
public <V> V visit(AbstractExpressionVisitor<V> visitor) {
rla/while
language/src/com/infdot/analysis/language/expression/AbstractBinaryOperator.java
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // }
import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
this.e1 = e1; this.e2 = e2; } public AbstractBinaryOperator(String op, String name1, String name2) { this.op = op; this.e1 = new Identifier(name1); this.e2 = new Identifier(name2); } public final Expression getE1() { return e1; } public final Expression getE2() { return e2; } @Override public final void collectVariables(Set<Identifier> variables) { e1.collectVariables(variables); e2.collectVariables(variables); } @Override public final String toString() { return e1 + op + e2; } @Override
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // } // Path: language/src/com/infdot/analysis/language/expression/AbstractBinaryOperator.java import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; this.e1 = e1; this.e2 = e2; } public AbstractBinaryOperator(String op, String name1, String name2) { this.op = op; this.e1 = new Identifier(name1); this.e2 = new Identifier(name2); } public final Expression getE1() { return e1; } public final Expression getE2() { return e2; } @Override public final void collectVariables(Set<Identifier> variables) { e1.collectVariables(variables); e2.collectVariables(variables); } @Override public final String toString() { return e1 + op + e2; } @Override
public final <V> V visit(AbstractExpressionVisitor<V> visitor) {
rla/while
src/com/infdot/analysis/solver/DataflowConstraintSet.java
// Path: src/com/infdot/analysis/solver/lattice/Domain.java // public interface Domain<V> { // public V bottom(); // // /** // * Factory method to create analysis state of given size. // */ // public V[] createStartState(int size); // }
import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import com.infdot.analysis.solver.lattice.Domain;
package com.infdot.analysis.solver; /** * Helper class to keep set of all dataflow constraints * of some specific analysis. * * @author Raivo Laanemets * * @param <V> type of dataflow values. * @param <M> type of metainfo associated with dataflow variables. */ public class DataflowConstraintSet<V, M> { private Map<Integer, DataflowContraint<V>> constraints = new HashMap<Integer, DataflowContraint<V>>(); /** * Associates variable to node where it belongs. * Used for interpreting results later. */ private Map<Integer, M> metainfo = new HashMap<Integer, M>(); /** * Adds constraint xi = F(x1, ..., xn) to the constraint set. */ public void addConstraint(int variable, DataflowExpression<V> expression, M metainfo) { constraints.put(variable, new DataflowContraint<V>(variable, expression)); this.metainfo.put(variable, metainfo); } /** * Recalculates dependency sets for each constraints. Constraint * Cd depends on constraint xi = ... when xi occurs as variable * in Cd and thus Cd has to be recalculated. */ public void recalculateDependencies() { for (DataflowContraint<V> constraint : constraints.values()) { constraint.clearDependencies(); } for (DataflowContraint<V> constraint : constraints.values()) { for (int i : constraint.getVariables()) { constraints.get(i).addDependent(constraint); } } } /** * Creates start state for analysis. */
// Path: src/com/infdot/analysis/solver/lattice/Domain.java // public interface Domain<V> { // public V bottom(); // // /** // * Factory method to create analysis state of given size. // */ // public V[] createStartState(int size); // } // Path: src/com/infdot/analysis/solver/DataflowConstraintSet.java import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import com.infdot.analysis.solver.lattice.Domain; package com.infdot.analysis.solver; /** * Helper class to keep set of all dataflow constraints * of some specific analysis. * * @author Raivo Laanemets * * @param <V> type of dataflow values. * @param <M> type of metainfo associated with dataflow variables. */ public class DataflowConstraintSet<V, M> { private Map<Integer, DataflowContraint<V>> constraints = new HashMap<Integer, DataflowContraint<V>>(); /** * Associates variable to node where it belongs. * Used for interpreting results later. */ private Map<Integer, M> metainfo = new HashMap<Integer, M>(); /** * Adds constraint xi = F(x1, ..., xn) to the constraint set. */ public void addConstraint(int variable, DataflowExpression<V> expression, M metainfo) { constraints.put(variable, new DataflowContraint<V>(variable, expression)); this.metainfo.put(variable, metainfo); } /** * Recalculates dependency sets for each constraints. Constraint * Cd depends on constraint xi = ... when xi occurs as variable * in Cd and thus Cd has to be recalculated. */ public void recalculateDependencies() { for (DataflowContraint<V> constraint : constraints.values()) { constraint.clearDependencies(); } for (DataflowContraint<V> constraint : constraints.values()) { for (int i : constraint.getVariables()) { constraints.get(i).addDependent(constraint); } } } /** * Creates start state for analysis. */
public V[] createStartState(Domain<V> domain) {
rla/while
src/com/infdot/analysis/solver/lattice/powerset/PowersetDomain.java
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/Domain.java // public interface Domain<V> { // public V bottom(); // // /** // * Factory method to create analysis state of given size. // */ // public V[] createStartState(int size); // }
import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.Domain;
package com.infdot.analysis.solver.lattice.powerset; /** * Standard powerset domain with empty set as bottom * and set union as join operator. * * @author Raivo Laanemets * * @param <T> type of set values. */ public class PowersetDomain<T> implements Domain<Set<T>> { @Override public Set<T> bottom() { return Collections.<T>emptySet(); } @Override public Set<T>[] createStartState(int size) { @SuppressWarnings("unchecked") Set<T>[] s = new Set[size]; for (int i = 0; i < size; i++) { s[i] = bottom(); } return s; } /** * Helper method to construct set expression from concrete set. */
// Path: src/com/infdot/analysis/solver/DataflowExpression.java // public interface DataflowExpression<V> { // /** // * Evaluates expression using the given variable values. // */ // V eval(V[] values); // // /** // * Helper to collect all variables, // */ // void collectVariables(Set<Integer> variables); // } // // Path: src/com/infdot/analysis/solver/lattice/Domain.java // public interface Domain<V> { // public V bottom(); // // /** // * Factory method to create analysis state of given size. // */ // public V[] createStartState(int size); // } // Path: src/com/infdot/analysis/solver/lattice/powerset/PowersetDomain.java import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import com.infdot.analysis.solver.DataflowExpression; import com.infdot.analysis.solver.lattice.Domain; package com.infdot.analysis.solver.lattice.powerset; /** * Standard powerset domain with empty set as bottom * and set union as join operator. * * @author Raivo Laanemets * * @param <T> type of set values. */ public class PowersetDomain<T> implements Domain<Set<T>> { @Override public Set<T> bottom() { return Collections.<T>emptySet(); } @Override public Set<T>[] createStartState(int size) { @SuppressWarnings("unchecked") Set<T>[] s = new Set[size]; for (int i = 0; i < size; i++) { s[i] = bottom(); } return s; } /** * Helper method to construct set expression from concrete set. */
public static <V> DataflowExpression<Set<V>> set(Collection<V> set) {
rla/while
language/src/com/infdot/analysis/language/expression/Constant.java
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // }
import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression; public class Constant extends Expression { private int value; public Constant(int value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } @Override public void collectVariables(Set<Identifier> variables) {} @Override
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // } // Path: language/src/com/infdot/analysis/language/expression/Constant.java import java.util.Set; import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; package com.infdot.analysis.language.expression; public class Constant extends Expression { private int value; public Constant(int value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } @Override public void collectVariables(Set<Identifier> variables) {} @Override
public <V> V visit(AbstractExpressionVisitor<V> visitor) {
rla/while
language/src/com/infdot/analysis/language/statement/Compound.java
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // }
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
public static Statement makeCompound(Statement... statements) { Statement ret = statements[0]; for (int i = 1; i < statements.length; i++) { ret = new Compound(ret, statements[i]); } return ret; } @Override public boolean equals(Object obj) { return obj instanceof Compound && ((Compound) obj).statement1.equals(statement1) && ((Compound) obj).statement2.equals(statement2); } @Override public int hashCode() { return statement1.hashCode() ^ statement2.hashCode(); } public Statement getStatement1() { return statement1; } public Statement getStatement2() { return statement2; } @Override
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // } // Path: language/src/com/infdot/analysis/language/statement/Compound.java import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; public static Statement makeCompound(Statement... statements) { Statement ret = statements[0]; for (int i = 1; i < statements.length; i++) { ret = new Compound(ret, statements[i]); } return ret; } @Override public boolean equals(Object obj) { return obj instanceof Compound && ((Compound) obj).statement1.equals(statement1) && ((Compound) obj).statement2.equals(statement2); } @Override public int hashCode() { return statement1.hashCode() ^ statement2.hashCode(); } public Statement getStatement1() { return statement1; } public Statement getStatement2() { return statement2; } @Override
public <T> T visit(AbstractStatementVisitor<T> visitor) {
rla/while
language/src/com/infdot/analysis/language/statement/If.java
// Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // }
import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
} @Override public void toCodeString(StringBuilder builder, String ident) { builder.append(ident).append("if (").append(condition).append(") {\n"); statement.toCodeString(builder, ident + " "); builder.append('\n').append(ident).append("}"); } @Override public boolean equals(Object obj) { return obj instanceof If && ((If) obj).condition.equals(condition) && ((If) obj).statement.equals(statement); } @Override public int hashCode() { return condition.hashCode() ^ statement.hashCode(); } public Statement getStatement() { return statement; } public Expression getCondition() { return condition; } @Override
// Path: language/src/com/infdot/analysis/language/expression/Expression.java // public abstract class Expression { // /** // * Unique identifier for each expression. // * @see {@link ExpressionNumberingVisitor} // */ // private int id = -1; // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // /** // * Helper method to collect variables. // */ // public abstract void collectVariables(Set<Identifier> variables); // // /** // * Method to accept visitor. // */ // public abstract <V> V visit(AbstractExpressionVisitor<V> visitor); // // @Override // public final boolean equals(Object obj) { // checkId(); // return obj instanceof Expression // && ((Expression) obj).id == id; // } // // @Override // public final int hashCode() { // checkId(); // return id; // } // // private void checkId() { // if (id < 0) { // throw new IllegalStateException("Expression " + this + " has no id set"); // } // } // // } // // Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // } // Path: language/src/com/infdot/analysis/language/statement/If.java import com.infdot.analysis.language.expression.Expression; import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; } @Override public void toCodeString(StringBuilder builder, String ident) { builder.append(ident).append("if (").append(condition).append(") {\n"); statement.toCodeString(builder, ident + " "); builder.append('\n').append(ident).append("}"); } @Override public boolean equals(Object obj) { return obj instanceof If && ((If) obj).condition.equals(condition) && ((If) obj).statement.equals(statement); } @Override public int hashCode() { return condition.hashCode() ^ statement.hashCode(); } public Statement getStatement() { return statement; } public Expression getCondition() { return condition; } @Override
public <T> T visit(AbstractStatementVisitor<T> visitor) {
rla/while
language/src/com/infdot/analysis/language/statement/Statement.java
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // }
import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor;
package com.infdot.analysis.language.statement; public interface Statement { /** * Method to build string representation of code. */ void toCodeString(StringBuilder builder, String ident); /** * Method for accepting statement visitor. */
// Path: language/src/com/infdot/analysis/language/statement/visitor/AbstractStatementVisitor.java // public abstract class AbstractStatementVisitor<T> { // // public abstract T visitAssignment(Assignment assignment); // // public abstract T visitCompound(Compound compound, T s1, T s2); // // public abstract T visitDeclaration(Declaration declaration); // // public abstract T visitIf(If ifStatement, T body); // // public abstract T visitOutput(Output output); // // public abstract T visitWhile(While whileStatement, T body); // } // Path: language/src/com/infdot/analysis/language/statement/Statement.java import com.infdot.analysis.language.statement.visitor.AbstractStatementVisitor; package com.infdot.analysis.language.statement; public interface Statement { /** * Method to build string representation of code. */ void toCodeString(StringBuilder builder, String ident); /** * Method for accepting statement visitor. */
<T> T visit(AbstractStatementVisitor<T> visitor);
rla/while
language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant);
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant);
public abstract V visitDiv(Div div, V e1, V e2);
rla/while
language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2);
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2);
public abstract V visitGt(Gt gt, V e1, V e2);
rla/while
language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2);
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2);
public abstract V visitIdentifier(Identifier identifier);
rla/while
language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2); public abstract V visitIdentifier(Identifier identifier);
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2); public abstract V visitIdentifier(Identifier identifier);
public abstract V visitInput(Input input);
rla/while
language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // }
import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub;
package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2); public abstract V visitIdentifier(Identifier identifier); public abstract V visitInput(Input input);
// Path: language/src/com/infdot/analysis/language/expression/Constant.java // public class Constant extends Expression { // private int value; // // public Constant(int value) { // this.value = value; // } // // @Override // public String toString() { // return String.valueOf(value); // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitConstant(this); // } // // public int getValue() { // return value; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Div.java // public class Div extends AbstractBinaryOperator { // // public Div(Expression e1, Expression e2) { // super("/", e1, e2); // } // // public Div(String name, int value) { // super("/", name, value); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitDiv(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Gt.java // public class Gt extends AbstractBinaryOperator { // // public Gt(String name, int value) { // super(">", name, value); // } // // public Gt(Expression e1, Expression e2) { // super(">", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitGt(this, e1, e2); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Identifier.java // public class Identifier extends Expression { // private String name; // // public Identifier(String name) { // this.name = name; // } // // @Override // public String toString() { // return name; // } // // @Override // public void collectVariables(Set<Identifier> variables) { // variables.add(this); // } // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitIdentifier(this); // } // // public String getName() { // return name; // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Input.java // public class Input extends Expression { // // @Override // public String toString() { // return "input"; // } // // @Override // public void collectVariables(Set<Identifier> variables) {} // // @Override // public <V> V visit(AbstractExpressionVisitor<V> visitor) { // return visitor.visitInput(this); // } // // } // // Path: language/src/com/infdot/analysis/language/expression/Sub.java // public class Sub extends AbstractBinaryOperator { // // public Sub(String name, int value) { // super("-", name, value); // } // // public Sub(String name1, String name2) { // super("-", name1, name2); // } // // public Sub(Expression e1, Expression e2) { // super("-", e1, e2); // } // // @Override // protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) { // return visitor.visitSub(this, e1, e2); // } // // } // Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java import com.infdot.analysis.language.expression.Constant; import com.infdot.analysis.language.expression.Div; import com.infdot.analysis.language.expression.Gt; import com.infdot.analysis.language.expression.Identifier; import com.infdot.analysis.language.expression.Input; import com.infdot.analysis.language.expression.Sub; package com.infdot.analysis.language.expression.visitor; /** * Base class for expression visitors. Assumes that there are no loops * in expression (trees). Has no cycle detection. * * @author Raivo Laanemets */ public abstract class AbstractExpressionVisitor<V> { public abstract V visitConstant(Constant constant); public abstract V visitDiv(Div div, V e1, V e2); public abstract V visitGt(Gt gt, V e1, V e2); public abstract V visitIdentifier(Identifier identifier); public abstract V visitInput(Input input);
public abstract V visitSub(Sub sub, V e1, V e2);
rla/while
language/src/com/infdot/analysis/language/expression/Gt.java
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // }
import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor;
package com.infdot.analysis.language.expression; public class Gt extends AbstractBinaryOperator { public Gt(String name, int value) { super(">", name, value); } public Gt(Expression e1, Expression e2) { super(">", e1, e2); } @Override
// Path: language/src/com/infdot/analysis/language/expression/visitor/AbstractExpressionVisitor.java // public abstract class AbstractExpressionVisitor<V> { // // public abstract V visitConstant(Constant constant); // // public abstract V visitDiv(Div div, V e1, V e2); // // public abstract V visitGt(Gt gt, V e1, V e2); // // public abstract V visitIdentifier(Identifier identifier); // // public abstract V visitInput(Input input); // // public abstract V visitSub(Sub sub, V e1, V e2); // } // Path: language/src/com/infdot/analysis/language/expression/Gt.java import com.infdot.analysis.language.expression.visitor.AbstractExpressionVisitor; package com.infdot.analysis.language.expression; public class Gt extends AbstractBinaryOperator { public Gt(String name, int value) { super(">", name, value); } public Gt(Expression e1, Expression e2) { super(">", e1, e2); } @Override
protected <V> V visitOperator(AbstractExpressionVisitor<V> visitor, V e1, V e2) {
CagataySonmez/EdgeCloudSim
src/edu/boun/edgecloudsim/network/NetworkModel.java
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // } // // Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // }
import edu.boun.edgecloudsim.utils.Location; import edu.boun.edgecloudsim.edge_client.Task;
/* * Title: EdgeCloudSim - Network Model * * Description: * NetworkModel is an abstract class which is used for calculating the * network delay from device to device. For those who wants to add a * custom Network Model to EdgeCloudSim should extend this class and * provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.network; public abstract class NetworkModel { protected int numberOfMobileDevices; protected String simScenario; public NetworkModel(int _numberOfMobileDevices, String _simScenario){ numberOfMobileDevices=_numberOfMobileDevices; simScenario = _simScenario; }; /** * initializes custom network model */ public abstract void initialize(); /** * calculates the upload delay from source to destination device */
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // } // // Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // } // Path: src/edu/boun/edgecloudsim/network/NetworkModel.java import edu.boun.edgecloudsim.utils.Location; import edu.boun.edgecloudsim.edge_client.Task; /* * Title: EdgeCloudSim - Network Model * * Description: * NetworkModel is an abstract class which is used for calculating the * network delay from device to device. For those who wants to add a * custom Network Model to EdgeCloudSim should extend this class and * provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.network; public abstract class NetworkModel { protected int numberOfMobileDevices; protected String simScenario; public NetworkModel(int _numberOfMobileDevices, String _simScenario){ numberOfMobileDevices=_numberOfMobileDevices; simScenario = _simScenario; }; /** * initializes custom network model */ public abstract void initialize(); /** * calculates the upload delay from source to destination device */
public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, Task task);
CagataySonmez/EdgeCloudSim
src/edu/boun/edgecloudsim/network/NetworkModel.java
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // } // // Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // }
import edu.boun.edgecloudsim.utils.Location; import edu.boun.edgecloudsim.edge_client.Task;
/* * Title: EdgeCloudSim - Network Model * * Description: * NetworkModel is an abstract class which is used for calculating the * network delay from device to device. For those who wants to add a * custom Network Model to EdgeCloudSim should extend this class and * provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.network; public abstract class NetworkModel { protected int numberOfMobileDevices; protected String simScenario; public NetworkModel(int _numberOfMobileDevices, String _simScenario){ numberOfMobileDevices=_numberOfMobileDevices; simScenario = _simScenario; }; /** * initializes custom network model */ public abstract void initialize(); /** * calculates the upload delay from source to destination device */ public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, Task task); /** * calculates the download delay from source to destination device */ public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId, Task task); /** * Mobile device manager should inform network manager about the network operation * This information may be important for some network delay models */
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // } // // Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // } // Path: src/edu/boun/edgecloudsim/network/NetworkModel.java import edu.boun.edgecloudsim.utils.Location; import edu.boun.edgecloudsim.edge_client.Task; /* * Title: EdgeCloudSim - Network Model * * Description: * NetworkModel is an abstract class which is used for calculating the * network delay from device to device. For those who wants to add a * custom Network Model to EdgeCloudSim should extend this class and * provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.network; public abstract class NetworkModel { protected int numberOfMobileDevices; protected String simScenario; public NetworkModel(int _numberOfMobileDevices, String _simScenario){ numberOfMobileDevices=_numberOfMobileDevices; simScenario = _simScenario; }; /** * initializes custom network model */ public abstract void initialize(); /** * calculates the upload delay from source to destination device */ public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, Task task); /** * calculates the download delay from source to destination device */ public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId, Task task); /** * Mobile device manager should inform network manager about the network operation * This information may be important for some network delay models */
public abstract void uploadStarted(Location accessPointLocation, int destDeviceId);
CagataySonmez/EdgeCloudSim
src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // }
import org.cloudbus.cloudsim.core.SimEntity; import edu.boun.edgecloudsim.edge_client.Task; import org.cloudbus.cloudsim.Vm;
/* * Title: EdgeCloudSim - Edge Orchestrator * * Description: * EdgeOrchestrator is an abstract class which is used for selecting VM * for each client requests. For those who wants to add a custom * Edge Orchestrator to EdgeCloudSim should extend this class and provide * a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.edge_orchestrator; public abstract class EdgeOrchestrator extends SimEntity{ protected String policy; protected String simScenario; public EdgeOrchestrator(String _policy, String _simScenario){ super("EdgeOrchestrator"); policy = _policy; simScenario = _simScenario; } /* * Default Constructor: Creates an empty EdgeOrchestrator */ public EdgeOrchestrator() { super("EdgeOrchestrator"); } /* * initialize edge orchestrator if needed */ public abstract void initialize(); /* * decides where to offload */
// Path: src/edu/boun/edgecloudsim/edge_client/Task.java // public class Task extends Cloudlet { // private Location submittedLocation; // private double creationTime; // private int type; // private int mobileDeviceId; // private int hostIndex; // private int vmIndex; // private int datacenterId; // // public Task(int _mobileDeviceId, int cloudletId, long cloudletLength, int pesNumber, // long cloudletFileSize, long cloudletOutputSize, // UtilizationModel utilizationModelCpu, // UtilizationModel utilizationModelRam, // UtilizationModel utilizationModelBw) { // super(cloudletId, cloudletLength, pesNumber, cloudletFileSize, // cloudletOutputSize, utilizationModelCpu, utilizationModelRam, // utilizationModelBw); // // mobileDeviceId = _mobileDeviceId; // creationTime = CloudSim.clock(); // } // // // public void setSubmittedLocation(Location _submittedLocation){ // submittedLocation =_submittedLocation; // } // // public void setAssociatedDatacenterId(int _datacenterId){ // datacenterId=_datacenterId; // } // // public void setAssociatedHostId(int _hostIndex){ // hostIndex=_hostIndex; // } // // public void setAssociatedVmId(int _vmIndex){ // vmIndex=_vmIndex; // } // // public void setTaskType(int _type){ // type=_type; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // // public Location getSubmittedLocation(){ // return submittedLocation; // } // // public int getAssociatedDatacenterId(){ // return datacenterId; // } // // public int getAssociatedHostId(){ // return hostIndex; // } // // public int getAssociatedVmId(){ // return vmIndex; // } // // public int getTaskType(){ // return type; // } // // public double getCreationTime() { // return creationTime; // } // } // Path: src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java import org.cloudbus.cloudsim.core.SimEntity; import edu.boun.edgecloudsim.edge_client.Task; import org.cloudbus.cloudsim.Vm; /* * Title: EdgeCloudSim - Edge Orchestrator * * Description: * EdgeOrchestrator is an abstract class which is used for selecting VM * for each client requests. For those who wants to add a custom * Edge Orchestrator to EdgeCloudSim should extend this class and provide * a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.edge_orchestrator; public abstract class EdgeOrchestrator extends SimEntity{ protected String policy; protected String simScenario; public EdgeOrchestrator(String _policy, String _simScenario){ super("EdgeOrchestrator"); policy = _policy; simScenario = _simScenario; } /* * Default Constructor: Creates an empty EdgeOrchestrator */ public EdgeOrchestrator() { super("EdgeOrchestrator"); } /* * initialize edge orchestrator if needed */ public abstract void initialize(); /* * decides where to offload */
public abstract int getDeviceToOffload(Task task);
CagataySonmez/EdgeCloudSim
src/edu/boun/edgecloudsim/mobility/MobilityModel.java
// Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // }
import edu.boun.edgecloudsim.utils.Location;
/* * Title: EdgeCloudSim - Mobility Model * * Description: * MobilityModel is an abstract class which is used for calculating the * location of each mobile devices with respect to the time. For those who * wants to add a custom Mobility Model to EdgeCloudSim should extend * this class and provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.mobility; public abstract class MobilityModel { protected int numberOfMobileDevices; protected double simulationTime; public MobilityModel(int _numberOfMobileDevices, double _simulationTime){ numberOfMobileDevices=_numberOfMobileDevices; simulationTime=_simulationTime; }; /* * Default Constructor: Creates an empty MobilityModel */ public MobilityModel() { } /* * calculate location of the devices according to related mobility model */ public abstract void initialize(); /* * returns location of a device at a certain time */
// Path: src/edu/boun/edgecloudsim/utils/Location.java // public class Location { // private int xPos; // private int yPos; // private int servingWlanId; // private int placeTypeIndex; // public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){ // servingWlanId = _servingWlanId; // placeTypeIndex=_placeTypeIndex; // xPos = _xPos; // yPos = _yPos; // } // // /* // * Default Constructor: Creates an empty Location // */ // public Location() { // } // // @Override // public boolean equals(Object other){ // boolean result = false; // if (other == null) return false; // if (!(other instanceof Location))return false; // if (other == this) return true; // // Location otherLocation = (Location)other; // if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos) // result = true; // // return result; // } // // public int getServingWlanId(){ // return servingWlanId; // } // // public int getPlaceTypeIndex(){ // return placeTypeIndex; // } // // public int getXPos(){ // return xPos; // } // // public int getYPos(){ // return yPos; // } // } // Path: src/edu/boun/edgecloudsim/mobility/MobilityModel.java import edu.boun.edgecloudsim.utils.Location; /* * Title: EdgeCloudSim - Mobility Model * * Description: * MobilityModel is an abstract class which is used for calculating the * location of each mobile devices with respect to the time. For those who * wants to add a custom Mobility Model to EdgeCloudSim should extend * this class and provide a concrete instance via ScenarioFactory * * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Copyright (c) 2017, Bogazici University, Istanbul, Turkey */ package edu.boun.edgecloudsim.mobility; public abstract class MobilityModel { protected int numberOfMobileDevices; protected double simulationTime; public MobilityModel(int _numberOfMobileDevices, double _simulationTime){ numberOfMobileDevices=_numberOfMobileDevices; simulationTime=_simulationTime; }; /* * Default Constructor: Creates an empty MobilityModel */ public MobilityModel() { } /* * calculate location of the devices according to related mobility model */ public abstract void initialize(); /* * returns location of a device at a certain time */
public abstract Location getLocation(int deviceId, double time);
CagataySonmez/EdgeCloudSim
src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java
// Path: src/edu/boun/edgecloudsim/utils/TaskProperty.java // public class TaskProperty { // private double startTime; // private long length, inputFileSize, outputFileSize; // private int taskType; // private int pesNumber; // private int mobileDeviceId; // // public TaskProperty(double _startTime, int _mobileDeviceId, int _taskType, int _pesNumber, long _length, long _inputFileSize, long _outputFileSize) { // startTime=_startTime; // mobileDeviceId=_mobileDeviceId; // taskType=_taskType; // pesNumber = _pesNumber; // length = _length; // outputFileSize = _inputFileSize; // inputFileSize = _outputFileSize; // } // // public TaskProperty(int _mobileDeviceId, int _taskType, double _startTime, ExponentialDistribution[][] expRngList) { // mobileDeviceId=_mobileDeviceId; // startTime=_startTime; // taskType=_taskType; // // inputFileSize = (long)expRngList[_taskType][0].sample(); // outputFileSize =(long)expRngList[_taskType][1].sample(); // length = (long)expRngList[_taskType][2].sample(); // // pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType][8]; // } // // public TaskProperty(int mobileDeviceId, double startTime, ExponentialDistribution[] expRngList) { // this.mobileDeviceId = mobileDeviceId; // this.startTime = startTime; // taskType = 0; // inputFileSize = (long)expRngList[0].sample(); // outputFileSize = (long)expRngList[1].sample(); // length = (long) expRngList[2].sample(); // pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[0][8]; // } // // public double getStartTime(){ // return startTime; // } // // public long getLength(){ // return length; // } // // public long getInputFileSize(){ // return inputFileSize; // } // // public long getOutputFileSize(){ // return outputFileSize; // } // // public int getTaskType(){ // return taskType; // } // // public int getPesNumber(){ // return pesNumber; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // }
import org.cloudbus.cloudsim.DatacenterBroker; import org.cloudbus.cloudsim.UtilizationModel; import edu.boun.edgecloudsim.utils.TaskProperty;
package edu.boun.edgecloudsim.edge_client; public abstract class MobileDeviceManager extends DatacenterBroker { public MobileDeviceManager() throws Exception { super("Global_Broker"); } /* * initialize mobile device manager if needed */ public abstract void initialize(); /* * provides abstract CPU Utilization Model */ public abstract UtilizationModel getCpuUtilizationModel();
// Path: src/edu/boun/edgecloudsim/utils/TaskProperty.java // public class TaskProperty { // private double startTime; // private long length, inputFileSize, outputFileSize; // private int taskType; // private int pesNumber; // private int mobileDeviceId; // // public TaskProperty(double _startTime, int _mobileDeviceId, int _taskType, int _pesNumber, long _length, long _inputFileSize, long _outputFileSize) { // startTime=_startTime; // mobileDeviceId=_mobileDeviceId; // taskType=_taskType; // pesNumber = _pesNumber; // length = _length; // outputFileSize = _inputFileSize; // inputFileSize = _outputFileSize; // } // // public TaskProperty(int _mobileDeviceId, int _taskType, double _startTime, ExponentialDistribution[][] expRngList) { // mobileDeviceId=_mobileDeviceId; // startTime=_startTime; // taskType=_taskType; // // inputFileSize = (long)expRngList[_taskType][0].sample(); // outputFileSize =(long)expRngList[_taskType][1].sample(); // length = (long)expRngList[_taskType][2].sample(); // // pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType][8]; // } // // public TaskProperty(int mobileDeviceId, double startTime, ExponentialDistribution[] expRngList) { // this.mobileDeviceId = mobileDeviceId; // this.startTime = startTime; // taskType = 0; // inputFileSize = (long)expRngList[0].sample(); // outputFileSize = (long)expRngList[1].sample(); // length = (long) expRngList[2].sample(); // pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[0][8]; // } // // public double getStartTime(){ // return startTime; // } // // public long getLength(){ // return length; // } // // public long getInputFileSize(){ // return inputFileSize; // } // // public long getOutputFileSize(){ // return outputFileSize; // } // // public int getTaskType(){ // return taskType; // } // // public int getPesNumber(){ // return pesNumber; // } // // public int getMobileDeviceId(){ // return mobileDeviceId; // } // } // Path: src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java import org.cloudbus.cloudsim.DatacenterBroker; import org.cloudbus.cloudsim.UtilizationModel; import edu.boun.edgecloudsim.utils.TaskProperty; package edu.boun.edgecloudsim.edge_client; public abstract class MobileDeviceManager extends DatacenterBroker { public MobileDeviceManager() throws Exception { super("Global_Broker"); } /* * initialize mobile device manager if needed */ public abstract void initialize(); /* * provides abstract CPU Utilization Model */ public abstract UtilizationModel getCpuUtilizationModel();
public abstract void submitTask(TaskProperty edgeTask);
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/ui/imagezoom/ImageZoomFragment.java
// Path: app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java // public class BaseActivity extends AppCompatActivity { // // private ActivityComponent activityComponent; // // // public ActivityComponent getActivityComponent() { // if (activityComponent == null) { // activityComponent = DaggerActivityComponent.builder() // .activityModule(new ActivityModule(this)) // .applicationComponent(TavernaApplication.get(this).getComponent()) // .build(); // } // return activityComponent; // } // }
import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.Request; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SizeReadyCallback; import com.bumptech.glide.request.target.Target; import org.apache.taverna.mobile.R; import org.apache.taverna.mobile.ui.base.BaseActivity; import org.apache.taverna.mobile.utils.ConnectionInfo; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import uk.co.senab.photoview.PhotoViewAttacher;
ImageView close; PhotoViewAttacher mAttacher; private String svgURI; private String jpgURI; public static ImageZoomFragment newInstance(String jpgURI, String svgURI) { Bundle args = new Bundle(); args.putString(JPG_URI, jpgURI); args.putString(SVG_URI, svgURI); ImageZoomFragment fragment = new ImageZoomFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); svgURI = getArguments().getString(SVG_URI); jpgURI = getArguments().getString(JPG_URI); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_image_zoom, container, false);
// Path: app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java // public class BaseActivity extends AppCompatActivity { // // private ActivityComponent activityComponent; // // // public ActivityComponent getActivityComponent() { // if (activityComponent == null) { // activityComponent = DaggerActivityComponent.builder() // .activityModule(new ActivityModule(this)) // .applicationComponent(TavernaApplication.get(this).getComponent()) // .build(); // } // return activityComponent; // } // } // Path: app/src/main/java/org/apache/taverna/mobile/ui/imagezoom/ImageZoomFragment.java import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.Request; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SizeReadyCallback; import com.bumptech.glide.request.target.Target; import org.apache.taverna.mobile.R; import org.apache.taverna.mobile.ui.base.BaseActivity; import org.apache.taverna.mobile.utils.ConnectionInfo; import javax.inject.Inject; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import uk.co.senab.photoview.PhotoViewAttacher; ImageView close; PhotoViewAttacher mAttacher; private String svgURI; private String jpgURI; public static ImageZoomFragment newInstance(String jpgURI, String svgURI) { Bundle args = new Bundle(); args.putString(JPG_URI, jpgURI); args.putString(SVG_URI, svgURI); ImageZoomFragment fragment = new ImageZoomFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); svgURI = getArguments().getString(SVG_URI); jpgURI = getArguments().getString(JPG_URI); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_image_zoom, container, false);
((BaseActivity) getActivity()).getActivityComponent().inject(this);
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/ui/imagezoom/ImageZoomPresenter.java
// Path: app/src/main/java/org/apache/taverna/mobile/utils/SvgDrawableTranscoder.java // public class SvgDrawableTranscoder implements ResourceTranscoder<SVG, PictureDrawable> { // @Override // public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) { // SVG svg = toTranscode.get(); // Picture picture = svg.renderToPicture(); // PictureDrawable drawable = new PictureDrawable(picture); // return new SimpleResource<PictureDrawable>(drawable); // } // // @Override // public String getId() { // return ""; // } // }
import android.graphics.drawable.Drawable; import android.graphics.drawable.PictureDrawable; import android.net.Uri; import android.os.Build; import android.widget.ImageView; import com.bumptech.glide.GenericRequestBuilder; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.model.StreamEncoder; import com.bumptech.glide.load.resource.file.FileToStreamDecoder; import com.bumptech.glide.request.Request; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SizeReadyCallback; import com.bumptech.glide.request.target.Target; import com.caverock.androidsvg.SVG; import org.apache.taverna.mobile.R; import org.apache.taverna.mobile.ui.base.BasePresenter; import org.apache.taverna.mobile.utils.SvgDecoder; import org.apache.taverna.mobile.utils.SvgDrawableTranscoder; import java.io.InputStream; import javax.inject.Inject;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.imagezoom; public class ImageZoomPresenter extends BasePresenter<ImageZoomMvpView> { private GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> requestBuilder; @Inject public ImageZoomPresenter() { } @Override public void attachView(ImageZoomMvpView mvpView) { super.attachView(mvpView); requestBuilder = Glide.with(getMvpView().getAppContext()) .using(Glide.buildStreamModelLoader(Uri.class, getMvpView().getAppContext()), InputStream.class) .from(Uri.class) .as(SVG.class)
// Path: app/src/main/java/org/apache/taverna/mobile/utils/SvgDrawableTranscoder.java // public class SvgDrawableTranscoder implements ResourceTranscoder<SVG, PictureDrawable> { // @Override // public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) { // SVG svg = toTranscode.get(); // Picture picture = svg.renderToPicture(); // PictureDrawable drawable = new PictureDrawable(picture); // return new SimpleResource<PictureDrawable>(drawable); // } // // @Override // public String getId() { // return ""; // } // } // Path: app/src/main/java/org/apache/taverna/mobile/ui/imagezoom/ImageZoomPresenter.java import android.graphics.drawable.Drawable; import android.graphics.drawable.PictureDrawable; import android.net.Uri; import android.os.Build; import android.widget.ImageView; import com.bumptech.glide.GenericRequestBuilder; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.model.StreamEncoder; import com.bumptech.glide.load.resource.file.FileToStreamDecoder; import com.bumptech.glide.request.Request; import com.bumptech.glide.request.animation.GlideAnimation; import com.bumptech.glide.request.target.SizeReadyCallback; import com.bumptech.glide.request.target.Target; import com.caverock.androidsvg.SVG; import org.apache.taverna.mobile.R; import org.apache.taverna.mobile.ui.base.BasePresenter; import org.apache.taverna.mobile.utils.SvgDecoder; import org.apache.taverna.mobile.utils.SvgDrawableTranscoder; import java.io.InputStream; import javax.inject.Inject; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.imagezoom; public class ImageZoomPresenter extends BasePresenter<ImageZoomMvpView> { private GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> requestBuilder; @Inject public ImageZoomPresenter() { } @Override public void attachView(ImageZoomMvpView mvpView) { super.attachView(mvpView); requestBuilder = Glide.with(getMvpView().getAppContext()) .using(Glide.buildStreamModelLoader(Uri.class, getMvpView().getAppContext()), InputStream.class) .from(Uri.class) .as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java
// Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // // @ApplicationContext // Context context(); // Application application(); // DataManager dataManager(); // PreferencesHelper preferencesHelper(); // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ApplicationModule.java // @Module // public class ApplicationModule { // protected final Application mApplication; // // public ApplicationModule(Application application) { // mApplication = application; // } // // @Provides // Application provideApplication() { // return mApplication; // } // // @Provides // @ApplicationContext // Context provideContext() { // return mApplication; // } // // }
import com.facebook.stetho.Stetho; import com.raizlabs.android.dbflow.config.FlowConfig; import com.raizlabs.android.dbflow.config.FlowManager; import com.squareup.leakcanary.LeakCanary; import org.apache.taverna.mobile.injection.component.ApplicationComponent; import org.apache.taverna.mobile.injection.component.DaggerApplicationComponent; import org.apache.taverna.mobile.injection.module.ApplicationModule; import android.app.Application; import android.content.Context;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile; public class TavernaApplication extends Application { ApplicationComponent mApplicationComponent; public static TavernaApplication get(Context context) { return (TavernaApplication) context.getApplicationContext(); } @Override public void onCreate() { super.onCreate(); FlowManager.init(new FlowConfig.Builder(this).build()); if (BuildConfig.DEBUG) { Stetho.initializeWithDefaults(this); } if (LeakCanary.isInAnalyzerProcess(this)) { return; } LeakCanary.install(this); } public ApplicationComponent getComponent() { if (mApplicationComponent == null) { mApplicationComponent = DaggerApplicationComponent.builder()
// Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ApplicationComponent.java // @Singleton // @Component(modules = ApplicationModule.class) // public interface ApplicationComponent { // // @ApplicationContext // Context context(); // Application application(); // DataManager dataManager(); // PreferencesHelper preferencesHelper(); // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ApplicationModule.java // @Module // public class ApplicationModule { // protected final Application mApplication; // // public ApplicationModule(Application application) { // mApplication = application; // } // // @Provides // Application provideApplication() { // return mApplication; // } // // @Provides // @ApplicationContext // Context provideContext() { // return mApplication; // } // // } // Path: app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java import com.facebook.stetho.Stetho; import com.raizlabs.android.dbflow.config.FlowConfig; import com.raizlabs.android.dbflow.config.FlowManager; import com.squareup.leakcanary.LeakCanary; import org.apache.taverna.mobile.injection.component.ApplicationComponent; import org.apache.taverna.mobile.injection.component.DaggerApplicationComponent; import org.apache.taverna.mobile.injection.module.ApplicationModule; import android.app.Application; import android.content.Context; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile; public class TavernaApplication extends Application { ApplicationComponent mApplicationComponent; public static TavernaApplication get(Context context) { return (TavernaApplication) context.getApplicationContext(); } @Override public void onCreate() { super.onCreate(); FlowManager.init(new FlowConfig.Builder(this).build()); if (BuildConfig.DEBUG) { Stetho.initializeWithDefaults(this); } if (LeakCanary.isInAnalyzerProcess(this)) { return; } LeakCanary.install(this); } public ApplicationComponent getComponent() { if (mApplicationComponent == null) { mApplicationComponent = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/ui/adapter/TutorialSliderAdapter.java
// Path: app/src/main/java/org/apache/taverna/mobile/data/model/TutorialSliderEnum.java // public enum TutorialSliderEnum { // // SLIDE1(R.layout.tutorial_slide1), // SLIDE2(R.layout.tutorial_slide2), // SLIDE3(R.layout.tutorial_slide3), // SLIDE4(R.layout.tutorial_slide4); // // private int layoutId; // // TutorialSliderEnum(int layout_Id) { // layoutId = layout_Id; // } // // public int getLayoutId() { // return layoutId; // } // // // }
import android.content.Context; import android.support.v4.view.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import org.apache.taverna.mobile.data.model.TutorialSliderEnum; import org.apache.taverna.mobile.injection.ApplicationContext; import javax.inject.Inject;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.adapter; public class TutorialSliderAdapter extends PagerAdapter { private Context context; @Inject public TutorialSliderAdapter(@ApplicationContext Context context) { this.context = context; } public Object instantiateItem(ViewGroup collection, int position) {
// Path: app/src/main/java/org/apache/taverna/mobile/data/model/TutorialSliderEnum.java // public enum TutorialSliderEnum { // // SLIDE1(R.layout.tutorial_slide1), // SLIDE2(R.layout.tutorial_slide2), // SLIDE3(R.layout.tutorial_slide3), // SLIDE4(R.layout.tutorial_slide4); // // private int layoutId; // // TutorialSliderEnum(int layout_Id) { // layoutId = layout_Id; // } // // public int getLayoutId() { // return layoutId; // } // // // } // Path: app/src/main/java/org/apache/taverna/mobile/ui/adapter/TutorialSliderAdapter.java import android.content.Context; import android.support.v4.view.PagerAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import org.apache.taverna.mobile.data.model.TutorialSliderEnum; import org.apache.taverna.mobile.injection.ApplicationContext; import javax.inject.Inject; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.adapter; public class TutorialSliderAdapter extends PagerAdapter { private Context context; @Inject public TutorialSliderAdapter(@ApplicationContext Context context) { this.context = context; } public Object instantiateItem(ViewGroup collection, int position) {
TutorialSliderEnum tutorialSliderEnum = TutorialSliderEnum.values()[position];
apache/incubator-taverna-mobile
app/src/androidTest/java/org/apache/taverna/mobile/runner/RxAndroidJUnitRunner.java
// Path: app/src/androidTest/java/org/apache/taverna/mobile/utils/RxEspressoScheduleHandler.java // public class RxEspressoScheduleHandler implements Function<Runnable, Runnable> { // // private final CountingIdlingResource mCountingIdlingResource = // new CountingIdlingResource("rxJava"); // // @Override // public Runnable apply(@NonNull final Runnable runnable) throws Exception { // return new Runnable() { // @Override // public void run() { // mCountingIdlingResource.increment(); // // try { // runnable.run(); // } finally { // mCountingIdlingResource.decrement(); // } // } // }; // } // // public IdlingResource getIdlingResource() { // return mCountingIdlingResource; // } // // }
import io.reactivex.plugins.RxJavaPlugins; import org.apache.taverna.mobile.utils.RxEspressoScheduleHandler; import android.os.Bundle; import android.support.test.espresso.Espresso;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.runner; public class RxAndroidJUnitRunner extends UnlockDeviceAndroidJUnitRunner { @Override public void onCreate(Bundle arguments) { super.onCreate(arguments);
// Path: app/src/androidTest/java/org/apache/taverna/mobile/utils/RxEspressoScheduleHandler.java // public class RxEspressoScheduleHandler implements Function<Runnable, Runnable> { // // private final CountingIdlingResource mCountingIdlingResource = // new CountingIdlingResource("rxJava"); // // @Override // public Runnable apply(@NonNull final Runnable runnable) throws Exception { // return new Runnable() { // @Override // public void run() { // mCountingIdlingResource.increment(); // // try { // runnable.run(); // } finally { // mCountingIdlingResource.decrement(); // } // } // }; // } // // public IdlingResource getIdlingResource() { // return mCountingIdlingResource; // } // // } // Path: app/src/androidTest/java/org/apache/taverna/mobile/runner/RxAndroidJUnitRunner.java import io.reactivex.plugins.RxJavaPlugins; import org.apache.taverna.mobile.utils.RxEspressoScheduleHandler; import android.os.Bundle; import android.support.test.espresso.Espresso; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.runner; public class RxAndroidJUnitRunner extends UnlockDeviceAndroidJUnitRunner { @Override public void onCreate(Bundle arguments) { super.onCreate(arguments);
RxEspressoScheduleHandler rxEspressoScheduleHandler = new RxEspressoScheduleHandler();
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java
// Path: app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java // public class TavernaApplication extends Application { // // ApplicationComponent mApplicationComponent; // // public static TavernaApplication get(Context context) { // return (TavernaApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // // FlowManager.init(new FlowConfig.Builder(this).build()); // if (BuildConfig.DEBUG) { // Stetho.initializeWithDefaults(this); // } // // if (LeakCanary.isInAnalyzerProcess(this)) { // return; // } // LeakCanary.install(this); // // } // // public ApplicationComponent getComponent() { // if (mApplicationComponent == null) { // mApplicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // return mApplicationComponent; // } // // // public void setComponent(ApplicationComponent applicationComponent) { // mApplicationComponent = applicationComponent; // } // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ActivityComponent.java // @PerActivity // @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) // public interface ActivityComponent { // // void inject(DashboardActivity dashboardActivity); // // void inject(FavouriteWorkflowsActivity favouriteWorkflowsActivity); // // void inject(FavouriteWorkflowDetailActivity favouriteWorkflowDetailActivity); // // void inject(ImageZoomActivity imageZoomActivity); // // void inject(LoginActivity loginActivity); // // void inject(MyWorkflowActivity myWorkflowActivity); // // void inject(TutorialActivity tutorialActivity); // // void inject(UsageActivity usageActivity); // // void inject(UserProfileActivity userProfileActivity); // // void inject(WorkflowDetailActivity workflowDetailActivity); // // void inject(AnnouncementFragment announcementFragment); // // void inject(FavouriteWorkflowsFragment favouriteWorkflowsFragment); // // void inject(FavouriteWorkflowDetailFragment favouriteWorkflowDetailFragment); // // void inject(ImageZoomFragment imageZoomFragment); // // void inject(LoginFragment loginFragment); // // void inject(MyWorkflowFragment myWorkflowFragment); // // void inject(PlayerLoginFragment playerLoginFragment); // // void inject(UserProfileFragment userProfileFragment); // // void inject(WorkflowFragment workflowFragment); // // void inject(WorkflowDetailFragment workflowDetailFragment); // // void inject(WorkflowRunActivity workflowRunActivity); // // void inject(FlashScreenActivity flashScreenActivity); // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ActivityModule.java // @Module // public class ActivityModule { // // private Activity mActivity; // // public ActivityModule(Activity activity) { // mActivity = activity; // } // // @Provides // Activity provideActivity() { // return mActivity; // } // // @Provides // @ActivityContext // Context providesContext() { // return mActivity; // } // }
import org.apache.taverna.mobile.TavernaApplication; import org.apache.taverna.mobile.injection.component.ActivityComponent; import org.apache.taverna.mobile.injection.component.DaggerActivityComponent; import org.apache.taverna.mobile.injection.module.ActivityModule; import android.support.v7.app.AppCompatActivity;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.base; /** * @author lusifer */ public class BaseActivity extends AppCompatActivity { private ActivityComponent activityComponent; public ActivityComponent getActivityComponent() { if (activityComponent == null) { activityComponent = DaggerActivityComponent.builder()
// Path: app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java // public class TavernaApplication extends Application { // // ApplicationComponent mApplicationComponent; // // public static TavernaApplication get(Context context) { // return (TavernaApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // // FlowManager.init(new FlowConfig.Builder(this).build()); // if (BuildConfig.DEBUG) { // Stetho.initializeWithDefaults(this); // } // // if (LeakCanary.isInAnalyzerProcess(this)) { // return; // } // LeakCanary.install(this); // // } // // public ApplicationComponent getComponent() { // if (mApplicationComponent == null) { // mApplicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // return mApplicationComponent; // } // // // public void setComponent(ApplicationComponent applicationComponent) { // mApplicationComponent = applicationComponent; // } // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ActivityComponent.java // @PerActivity // @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) // public interface ActivityComponent { // // void inject(DashboardActivity dashboardActivity); // // void inject(FavouriteWorkflowsActivity favouriteWorkflowsActivity); // // void inject(FavouriteWorkflowDetailActivity favouriteWorkflowDetailActivity); // // void inject(ImageZoomActivity imageZoomActivity); // // void inject(LoginActivity loginActivity); // // void inject(MyWorkflowActivity myWorkflowActivity); // // void inject(TutorialActivity tutorialActivity); // // void inject(UsageActivity usageActivity); // // void inject(UserProfileActivity userProfileActivity); // // void inject(WorkflowDetailActivity workflowDetailActivity); // // void inject(AnnouncementFragment announcementFragment); // // void inject(FavouriteWorkflowsFragment favouriteWorkflowsFragment); // // void inject(FavouriteWorkflowDetailFragment favouriteWorkflowDetailFragment); // // void inject(ImageZoomFragment imageZoomFragment); // // void inject(LoginFragment loginFragment); // // void inject(MyWorkflowFragment myWorkflowFragment); // // void inject(PlayerLoginFragment playerLoginFragment); // // void inject(UserProfileFragment userProfileFragment); // // void inject(WorkflowFragment workflowFragment); // // void inject(WorkflowDetailFragment workflowDetailFragment); // // void inject(WorkflowRunActivity workflowRunActivity); // // void inject(FlashScreenActivity flashScreenActivity); // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ActivityModule.java // @Module // public class ActivityModule { // // private Activity mActivity; // // public ActivityModule(Activity activity) { // mActivity = activity; // } // // @Provides // Activity provideActivity() { // return mActivity; // } // // @Provides // @ActivityContext // Context providesContext() { // return mActivity; // } // } // Path: app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java import org.apache.taverna.mobile.TavernaApplication; import org.apache.taverna.mobile.injection.component.ActivityComponent; import org.apache.taverna.mobile.injection.component.DaggerActivityComponent; import org.apache.taverna.mobile.injection.module.ActivityModule; import android.support.v7.app.AppCompatActivity; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.base; /** * @author lusifer */ public class BaseActivity extends AppCompatActivity { private ActivityComponent activityComponent; public ActivityComponent getActivityComponent() { if (activityComponent == null) { activityComponent = DaggerActivityComponent.builder()
.activityModule(new ActivityModule(this))
apache/incubator-taverna-mobile
app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java
// Path: app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java // public class TavernaApplication extends Application { // // ApplicationComponent mApplicationComponent; // // public static TavernaApplication get(Context context) { // return (TavernaApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // // FlowManager.init(new FlowConfig.Builder(this).build()); // if (BuildConfig.DEBUG) { // Stetho.initializeWithDefaults(this); // } // // if (LeakCanary.isInAnalyzerProcess(this)) { // return; // } // LeakCanary.install(this); // // } // // public ApplicationComponent getComponent() { // if (mApplicationComponent == null) { // mApplicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // return mApplicationComponent; // } // // // public void setComponent(ApplicationComponent applicationComponent) { // mApplicationComponent = applicationComponent; // } // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ActivityComponent.java // @PerActivity // @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) // public interface ActivityComponent { // // void inject(DashboardActivity dashboardActivity); // // void inject(FavouriteWorkflowsActivity favouriteWorkflowsActivity); // // void inject(FavouriteWorkflowDetailActivity favouriteWorkflowDetailActivity); // // void inject(ImageZoomActivity imageZoomActivity); // // void inject(LoginActivity loginActivity); // // void inject(MyWorkflowActivity myWorkflowActivity); // // void inject(TutorialActivity tutorialActivity); // // void inject(UsageActivity usageActivity); // // void inject(UserProfileActivity userProfileActivity); // // void inject(WorkflowDetailActivity workflowDetailActivity); // // void inject(AnnouncementFragment announcementFragment); // // void inject(FavouriteWorkflowsFragment favouriteWorkflowsFragment); // // void inject(FavouriteWorkflowDetailFragment favouriteWorkflowDetailFragment); // // void inject(ImageZoomFragment imageZoomFragment); // // void inject(LoginFragment loginFragment); // // void inject(MyWorkflowFragment myWorkflowFragment); // // void inject(PlayerLoginFragment playerLoginFragment); // // void inject(UserProfileFragment userProfileFragment); // // void inject(WorkflowFragment workflowFragment); // // void inject(WorkflowDetailFragment workflowDetailFragment); // // void inject(WorkflowRunActivity workflowRunActivity); // // void inject(FlashScreenActivity flashScreenActivity); // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ActivityModule.java // @Module // public class ActivityModule { // // private Activity mActivity; // // public ActivityModule(Activity activity) { // mActivity = activity; // } // // @Provides // Activity provideActivity() { // return mActivity; // } // // @Provides // @ActivityContext // Context providesContext() { // return mActivity; // } // }
import org.apache.taverna.mobile.TavernaApplication; import org.apache.taverna.mobile.injection.component.ActivityComponent; import org.apache.taverna.mobile.injection.component.DaggerActivityComponent; import org.apache.taverna.mobile.injection.module.ActivityModule; import android.support.v7.app.AppCompatActivity;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.base; /** * @author lusifer */ public class BaseActivity extends AppCompatActivity { private ActivityComponent activityComponent; public ActivityComponent getActivityComponent() { if (activityComponent == null) { activityComponent = DaggerActivityComponent.builder() .activityModule(new ActivityModule(this))
// Path: app/src/main/java/org/apache/taverna/mobile/TavernaApplication.java // public class TavernaApplication extends Application { // // ApplicationComponent mApplicationComponent; // // public static TavernaApplication get(Context context) { // return (TavernaApplication) context.getApplicationContext(); // } // // @Override // public void onCreate() { // super.onCreate(); // // FlowManager.init(new FlowConfig.Builder(this).build()); // if (BuildConfig.DEBUG) { // Stetho.initializeWithDefaults(this); // } // // if (LeakCanary.isInAnalyzerProcess(this)) { // return; // } // LeakCanary.install(this); // // } // // public ApplicationComponent getComponent() { // if (mApplicationComponent == null) { // mApplicationComponent = DaggerApplicationComponent.builder() // .applicationModule(new ApplicationModule(this)) // .build(); // } // return mApplicationComponent; // } // // // public void setComponent(ApplicationComponent applicationComponent) { // mApplicationComponent = applicationComponent; // } // // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/component/ActivityComponent.java // @PerActivity // @Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) // public interface ActivityComponent { // // void inject(DashboardActivity dashboardActivity); // // void inject(FavouriteWorkflowsActivity favouriteWorkflowsActivity); // // void inject(FavouriteWorkflowDetailActivity favouriteWorkflowDetailActivity); // // void inject(ImageZoomActivity imageZoomActivity); // // void inject(LoginActivity loginActivity); // // void inject(MyWorkflowActivity myWorkflowActivity); // // void inject(TutorialActivity tutorialActivity); // // void inject(UsageActivity usageActivity); // // void inject(UserProfileActivity userProfileActivity); // // void inject(WorkflowDetailActivity workflowDetailActivity); // // void inject(AnnouncementFragment announcementFragment); // // void inject(FavouriteWorkflowsFragment favouriteWorkflowsFragment); // // void inject(FavouriteWorkflowDetailFragment favouriteWorkflowDetailFragment); // // void inject(ImageZoomFragment imageZoomFragment); // // void inject(LoginFragment loginFragment); // // void inject(MyWorkflowFragment myWorkflowFragment); // // void inject(PlayerLoginFragment playerLoginFragment); // // void inject(UserProfileFragment userProfileFragment); // // void inject(WorkflowFragment workflowFragment); // // void inject(WorkflowDetailFragment workflowDetailFragment); // // void inject(WorkflowRunActivity workflowRunActivity); // // void inject(FlashScreenActivity flashScreenActivity); // } // // Path: app/src/main/java/org/apache/taverna/mobile/injection/module/ActivityModule.java // @Module // public class ActivityModule { // // private Activity mActivity; // // public ActivityModule(Activity activity) { // mActivity = activity; // } // // @Provides // Activity provideActivity() { // return mActivity; // } // // @Provides // @ActivityContext // Context providesContext() { // return mActivity; // } // } // Path: app/src/main/java/org/apache/taverna/mobile/ui/base/BaseActivity.java import org.apache.taverna.mobile.TavernaApplication; import org.apache.taverna.mobile.injection.component.ActivityComponent; import org.apache.taverna.mobile.injection.component.DaggerActivityComponent; import org.apache.taverna.mobile.injection.module.ActivityModule; import android.support.v7.app.AppCompatActivity; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.taverna.mobile.ui.base; /** * @author lusifer */ public class BaseActivity extends AppCompatActivity { private ActivityComponent activityComponent; public ActivityComponent getActivityComponent() { if (activityComponent == null) { activityComponent = DaggerActivityComponent.builder() .activityModule(new ActivityModule(this))
.applicationComponent(TavernaApplication.get(this).getComponent())
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/BeforeCallOrderTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.github.havarunner.beforeafter; public class BeforeCallOrderTest { static long grandParentBeforeCalled; static long parentBeforeCalled; static long childBeforeCalled; @Test public void HavaRunner_calls_the_ancestor_befores_first() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/beforeafter/BeforeCallOrderTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.github.havarunner.beforeafter; public class BeforeCallOrderTest { static long grandParentBeforeCalled; static long parentBeforeCalled; static long childBeforeCalled; @Test public void HavaRunner_calls_the_ancestor_befores_first() {
run(new HavaRunner(Child.class));
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/covariant/CovariantScenarioConstructorTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import org.junit.Test; import java.util.Collection; import static com.github.havarunner.TestHelper.run; import static java.util.Arrays.asList; import static java.util.Collections.synchronizedList; import static org.junit.Assert.assertEquals;
package com.github.havarunner.scenarios.covariant; public class CovariantScenarioConstructorTest { static final Collection<Planet> seenPlanets = synchronizedList(Lists.<Planet>newArrayList()); @Test public void havarunner_should_support_covariance_in_scenario_objects() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/scenarios/covariant/CovariantScenarioConstructorTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import org.junit.Test; import java.util.Collection; import static com.github.havarunner.TestHelper.run; import static java.util.Arrays.asList; import static java.util.Collections.synchronizedList; import static org.junit.Assert.assertEquals; package com.github.havarunner.scenarios.covariant; public class CovariantScenarioConstructorTest { static final Collection<Planet> seenPlanets = synchronizedList(Lists.<Planet>newArrayList()); @Test public void havarunner_should_support_covariance_in_scenario_objects() {
run(new HavaRunner(CovarianceInScenarioObject.class));
havarunner/havarunner
src/test/java/com/github/havarunner/example/suite/browser/BrowserTest.java
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.github.havarunner.example.suite.browser; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class BrowserTest {
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // } // Path: src/test/java/com/github/havarunner/example/suite/browser/BrowserTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.github.havarunner.example.suite.browser; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class BrowserTest {
private final WebServer webServer;
havarunner/havarunner
src/test/java/com/github/havarunner/suite/suitedefinedinparent/SuiteDefinedInParentTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.After; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue;
package com.github.havarunner.suite.suitedefinedinparent; public class SuiteDefinedInParentTest { static boolean suiteMethodCalled; static boolean innerSuiteMethodCalled; @After public void reset() { suiteMethodCalled = false; innerSuiteMethodCalled = false; } @Test public void abstract_classes_may_declare_suite_membership() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/suite/suitedefinedinparent/SuiteDefinedInParentTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.After; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue; package com.github.havarunner.suite.suitedefinedinparent; public class SuiteDefinedInParentTest { static boolean suiteMethodCalled; static boolean innerSuiteMethodCalled; @After public void reset() { suiteMethodCalled = false; innerSuiteMethodCalled = false; } @Test public void abstract_classes_may_declare_suite_membership() {
run(new HavaRunner(SuiteMember.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/suitedefinedinparent/SuiteDefinedInParentTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.After; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue;
suiteMethodCalled = false; innerSuiteMethodCalled = false; } @Test public void abstract_classes_may_declare_suite_membership() { run(new HavaRunner(SuiteMember.class)); assertTrue(suiteMethodCalled); } @Test public void abstract_classes_may_declare_suite_membership_for_static_inner_classes() { run(new HavaRunner(SuiteMember.class)); assertTrue(innerSuiteMethodCalled); } @Test public void the_suite_should_find_its_members_even_though_the_membership_is_declared_in_an_abstract_class_and_the_concrete_class_is_a_static_inner_class() { run(new HavaRunner(Suite.class)); assertTrue(innerSuiteMethodCalled); } @Test public void the_suite_should_find_its_members_even_though_the_membership_is_declared_in_an_abstract_class() { run(new HavaRunner(Suite.class)); assertTrue(suiteMethodCalled); } @Test public void HavaRunner_includes_suite_members_exactly_once() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/suite/suitedefinedinparent/SuiteDefinedInParentTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.After; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue; suiteMethodCalled = false; innerSuiteMethodCalled = false; } @Test public void abstract_classes_may_declare_suite_membership() { run(new HavaRunner(SuiteMember.class)); assertTrue(suiteMethodCalled); } @Test public void abstract_classes_may_declare_suite_membership_for_static_inner_classes() { run(new HavaRunner(SuiteMember.class)); assertTrue(innerSuiteMethodCalled); } @Test public void the_suite_should_find_its_members_even_though_the_membership_is_declared_in_an_abstract_class_and_the_concrete_class_is_a_static_inner_class() { run(new HavaRunner(Suite.class)); assertTrue(innerSuiteMethodCalled); } @Test public void the_suite_should_find_its_members_even_though_the_membership_is_declared_in_an_abstract_class() { run(new HavaRunner(Suite.class)); assertTrue(suiteMethodCalled); } @Test public void HavaRunner_includes_suite_members_exactly_once() {
assertTestClasses(Lists.<Class>newArrayList(SuiteMember.class, SuiteMember.InnerSuiteMember.class), Suite.class);
havarunner/havarunner
src/test/java/com/github/havarunner/enclosed/EnclosedStaticClassesTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.enclosed; public class EnclosedStaticClassesTest { static boolean parentCalled; static boolean childCalled; static boolean grandchildCalled; static boolean grandGrandchildCalled; @Test public void HavaRunner_supports_recursive_static_inner_classes() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/enclosed/EnclosedStaticClassesTest.java import com.github.havarunner.HavaRunner; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.enclosed; public class EnclosedStaticClassesTest { static boolean parentCalled; static boolean childCalled; static boolean grandchildCalled; static boolean grandGrandchildCalled; @Test public void HavaRunner_supports_recursive_static_inner_classes() {
run(new HavaRunner(Parent.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/afterall/SuiteMember2.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // }
import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import static com.github.havarunner.TestHelper.addHundredTimes;
package com.github.havarunner.sequentiality.afterall; @PartOf(SequentialSuite.class) class SuiteMember2 { SuiteMember2(String suiteObject) {} @Test void test() {} @AfterAll void shutdown() throws InterruptedException {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // Path: src/test/java/com/github/havarunner/sequentiality/afterall/SuiteMember2.java import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import static com.github.havarunner.TestHelper.addHundredTimes; package com.github.havarunner.sequentiality.afterall; @PartOf(SequentialSuite.class) class SuiteMember2 { SuiteMember2(String suiteObject) {} @Test void test() {} @AfterAll void shutdown() throws InterruptedException {
addHundredTimes(2, SequentialityWithAfterAllsTest.ints);
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals;
package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError {
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // } // Path: src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals; package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError {
int numberOfScenarios = Person.values().length;
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals;
package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError { int numberOfScenarios = Person.values().length;
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // } // Path: src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals; package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError { int numberOfScenarios = Person.values().length;
Iterable<TestAndParameters> children = new HavaRunner(RestaurantMenuTest.class).tests();
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals;
package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError { int numberOfScenarios = Person.values().length; Iterable<TestAndParameters> children = new HavaRunner(RestaurantMenuTest.class).tests(); assertEquals( numberOfScenarios * numberOfExamples(RestaurantMenuTest.class), Lists.newArrayList(children).size() ); } @Test public void HavaRunner_raises_an_exception_if_the_scenario_method_does_not_have_the_scenario_object_as_only_arg() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals(ConstructorNotFound.class, expectedFailure.get().getException().getClass()); } @Test public void HavaRunner_prints_a_helpful_error_message_if_the_scenario_method_is_missing() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals( "Class InvalidScenarioTest is missing the required constructor. Try adding the following constructor: InvalidScenarioTest(class java.lang.String)", expectedFailure.get().getMessage() ); } final static Collection<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_each_scenario_object_to_the_scenario_method() throws Exception {
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // } // Path: src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals; package com.github.havarunner.scenarios; public class MultipleScenariosTest { @Test public void it_constructs_an_example_for_each_scenario() throws InitializationError { int numberOfScenarios = Person.values().length; Iterable<TestAndParameters> children = new HavaRunner(RestaurantMenuTest.class).tests(); assertEquals( numberOfScenarios * numberOfExamples(RestaurantMenuTest.class), Lists.newArrayList(children).size() ); } @Test public void HavaRunner_raises_an_exception_if_the_scenario_method_does_not_have_the_scenario_object_as_only_arg() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals(ConstructorNotFound.class, expectedFailure.get().getException().getClass()); } @Test public void HavaRunner_prints_a_helpful_error_message_if_the_scenario_method_is_missing() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals( "Class InvalidScenarioTest is missing the required constructor. Try adding the following constructor: InvalidScenarioTest(class java.lang.String)", expectedFailure.get().getMessage() ); } final static Collection<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_each_scenario_object_to_the_scenario_method() throws Exception {
run(new HavaRunner(ValidScenarioTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals;
} @Test public void HavaRunner_raises_an_exception_if_the_scenario_method_does_not_have_the_scenario_object_as_only_arg() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals(ConstructorNotFound.class, expectedFailure.get().getException().getClass()); } @Test public void HavaRunner_prints_a_helpful_error_message_if_the_scenario_method_is_missing() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals( "Class InvalidScenarioTest is missing the required constructor. Try adding the following constructor: InvalidScenarioTest(class java.lang.String)", expectedFailure.get().getMessage() ); } final static Collection<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_each_scenario_object_to_the_scenario_method() throws Exception { run(new HavaRunner(ValidScenarioTest.class)); assertEquals( Sets.newHashSet("first", "second"), Sets.newHashSet(scenarios) ); } @Test public void HavaRunner_will_give_a_helpful_error_message_if_the_test_has_multiple_Scenario_annotations() {
// Path: src/test/java/com/github/havarunner/example/scenario/Person.java // public enum Person { // KID, // ADULT // } // // Path: src/test/java/com/github/havarunner/example/scenario/RestaurantMenuTest.java // @RunWith(HavaRunner.class) // public class RestaurantMenuTest { // // private final Person person; // // RestaurantMenuTest(Person person) { // // this.person = person; // } // // @Test // void it_is_cheaper_for_kids_than_adults() { // RestaurantMenu menu = new RestaurantMenu(person); // if (menu.person.equals(Person.KID)) { // assertEquals(5, menu.price()); // } else { // assertEquals(20, menu.price()); // } // } // // @Test // void it_contains_4_courses_for_kids_and_adults() { // assertEquals(4, new RestaurantMenu(person).courses()); // } // // @Test // void for_adults_it_suggests_coffee() { // if (person == Person.KID) { // assertEquals("ice cream", new RestaurantMenu(person).suggestions()); // } else { // assertEquals("coffee", new RestaurantMenu(person).suggestions()); // } // } // // @Scenarios // static Set<Person> scenarios() { // Set<Person> persons = new HashSet<>(); // Collections.addAll(persons, Person.values()); // return persons; // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Failure> runAndRecordFailures(HavaRunner havaRunner) { // final List<Failure> failures = Collections.synchronizedList(Lists.<Failure>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // failures.add(failure); // } // }; // run(havaRunner, runNotifier); // return failures; // } // Path: src/test/java/com/github/havarunner/scenarios/MultipleScenariosTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.scenario.Person; import com.github.havarunner.example.scenario.RestaurantMenuTest; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailures; import static org.junit.Assert.assertEquals; } @Test public void HavaRunner_raises_an_exception_if_the_scenario_method_does_not_have_the_scenario_object_as_only_arg() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals(ConstructorNotFound.class, expectedFailure.get().getException().getClass()); } @Test public void HavaRunner_prints_a_helpful_error_message_if_the_scenario_method_is_missing() throws Exception { final AtomicReference<Failure> expectedFailure = runInvalidScenarioTestMethod(); assertEquals( "Class InvalidScenarioTest is missing the required constructor. Try adding the following constructor: InvalidScenarioTest(class java.lang.String)", expectedFailure.get().getMessage() ); } final static Collection<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_each_scenario_object_to_the_scenario_method() throws Exception { run(new HavaRunner(ValidScenarioTest.class)); assertEquals( Sets.newHashSet("first", "second"), Sets.newHashSet(scenarios) ); } @Test public void HavaRunner_will_give_a_helpful_error_message_if_the_test_has_multiple_Scenario_annotations() {
List<Failure> failures = runAndRecordFailures(new HavaRunner(TwoScenarioMethodsTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/timeout/TimeoutTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue;
package com.github.havarunner.timeout; public class TimeoutTest { @Test public void HavaRunner_throws_an_exception_if_the_test_times_out() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/timeout/TimeoutTest.java import com.github.havarunner.HavaRunner; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertTrue; package com.github.havarunner.timeout; public class TimeoutTest { @Test public void HavaRunner_throws_an_exception_if_the_test_times_out() {
Failure failure = runAndRecordFailure(new HavaRunner(TimedOut.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/afterall/SequentialityWithAfterAllsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Test; import java.util.List; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run;
package com.github.havarunner.sequentiality.afterall; public class SequentialityWithAfterAllsTest { static List<Integer> ints = Lists.newArrayList(); @Test public void HavaRunner_synchronises_the_AfterAll_methods() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/afterall/SequentialityWithAfterAllsTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Test; import java.util.List; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; package com.github.havarunner.sequentiality.afterall; public class SequentialityWithAfterAllsTest { static List<Integer> ints = Lists.newArrayList(); @Test public void HavaRunner_synchronises_the_AfterAll_methods() {
run(new HavaRunner(SequentialSuite.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/afterall/SequentialityWithAfterAllsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Test; import java.util.List; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run;
package com.github.havarunner.sequentiality.afterall; public class SequentialityWithAfterAllsTest { static List<Integer> ints = Lists.newArrayList(); @Test public void HavaRunner_synchronises_the_AfterAll_methods() { run(new HavaRunner(SequentialSuite.class)); if (ints.get(0) == 1) {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/afterall/SequentialityWithAfterAllsTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Test; import java.util.List; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; package com.github.havarunner.sequentiality.afterall; public class SequentialityWithAfterAllsTest { static List<Integer> ints = Lists.newArrayList(); @Test public void HavaRunner_synchronises_the_AfterAll_methods() { run(new HavaRunner(SequentialSuite.class)); if (ints.get(0) == 1) {
assertAllEqual(1, ints.subList(0, 100));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
static class SequentialTest { @Test void examples_in_this_class_are_run_sequentially() { } } static class test_that_extends_a_sequential_test extends SequentialTest { @Test void examples_in_this_class_are_run_sequentially() { } } @RunSequentially(because = "this test does not thrive in the concurrent world") static class SequentialEnclosingTest { static class EnclosedTest { @Test void examples_in_this_class_are_run_sequentially() { } } } } public static class instantiation_sequentiality_when_using_scenarios { static final List<String> ints = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void constructors_should_be_called_sequentially() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; static class SequentialTest { @Test void examples_in_this_class_are_run_sequentially() { } } static class test_that_extends_a_sequential_test extends SequentialTest { @Test void examples_in_this_class_are_run_sequentially() { } } @RunSequentially(because = "this test does not thrive in the concurrent world") static class SequentialEnclosingTest { static class EnclosedTest { @Test void examples_in_this_class_are_run_sequentially() { } } } } public static class instantiation_sequentiality_when_using_scenarios { static final List<String> ints = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void constructors_should_be_called_sequentially() {
run(new HavaRunner(SequentialityAndScenariosTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/rules/WhenRuleFailsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runners.model.Statement; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals;
package com.github.havarunner.rules; public class WhenRuleFailsTest { @Test public void HavaRunner_will_give_a_helpful_error_message_if_a_rule_throws_an_exception() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/rules/WhenRuleFailsTest.java import com.github.havarunner.HavaRunner; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runners.model.Statement; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; package com.github.havarunner.rules; public class WhenRuleFailsTest { @Test public void HavaRunner_will_give_a_helpful_error_message_if_a_rule_throws_an_exception() {
Failure failure = runAndRecordFailure(new HavaRunner(TestWithRule.class));
havarunner/havarunner
src/test/java/com/github/havarunner/FilterTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.github.havarunner.annotation.Scenarios; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; import java.util.Collection; import java.util.Set; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.*;
package com.github.havarunner; public class FilterTest { @Test public void HavaRunner_supports_the_JUnit_filter_API() { HavaRunner havaRunner = new HavaRunner(TestClass.class); havaRunner.filter(new Filter() { public boolean shouldRun(Description description) { throw new UnsupportedOperationException("HavaRunner should not call this method"); } public String describe() { return String.format("Method HavaRunner_should_run_only_this_method(%s)", TestClass.class.getName()); } });
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/FilterTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.github.havarunner.annotation.Scenarios; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.manipulation.Filter; import java.util.Collection; import java.util.Set; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.*; package com.github.havarunner; public class FilterTest { @Test public void HavaRunner_supports_the_JUnit_filter_API() { HavaRunner havaRunner = new HavaRunner(TestClass.class); havaRunner.filter(new Filter() { public boolean shouldRun(Description description) { throw new UnsupportedOperationException("HavaRunner should not call this method"); } public String describe() { return String.format("Method HavaRunner_should_run_only_this_method(%s)", TestClass.class.getName()); } });
run(havaRunner);
havarunner/havarunner
src/test/java/com/github/havarunner/suite/RunningSuiteTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.github.havarunner.suite; @RunWith(Enclosed.class) public class RunningSuiteTest { public static class when_running_the_whole_suite { static boolean suiteTestCalled; static boolean suiteMember1Called; static boolean suiteMember2Called; @Test public void HavaRunner_calls_all_the_suite_members_when_running_the_suite() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/suite/RunningSuiteTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.github.havarunner.suite; @RunWith(Enclosed.class) public class RunningSuiteTest { public static class when_running_the_whole_suite { static boolean suiteTestCalled; static boolean suiteMember1Called; static boolean suiteMember2Called; @Test public void HavaRunner_calls_all_the_suite_members_when_running_the_suite() {
run(new HavaRunner(ExampleSuite.class));
havarunner/havarunner
src/test/java/com/github/havarunner/IgnoredTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Description> runAndRecordIgnores(HavaRunner havaRunner) { // final List<Description> ignores = Collections.synchronizedList(Lists.<Description>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestIgnored(Description description) { // ignores.add(description); // } // }; // run(havaRunner, runNotifier); // return ignores; // }
import org.junit.Ignore; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.runAndRecordIgnores; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package com.github.havarunner; public class IgnoredTest { static boolean ignoredTestIsRun; static boolean testInIgnoredCLassIsRun; @Test public void it_records_ignored_tests_properly() throws InitializationError { HavaRunner havaRunner = new HavaRunner(ContainingIgnoredTest.class);
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static List<Description> runAndRecordIgnores(HavaRunner havaRunner) { // final List<Description> ignores = Collections.synchronizedList(Lists.<Description>newArrayList()); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestIgnored(Description description) { // ignores.add(description); // } // }; // run(havaRunner, runNotifier); // return ignores; // } // Path: src/test/java/com/github/havarunner/IgnoredTest.java import org.junit.Ignore; import org.junit.Test; import org.junit.runner.Description; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.InitializationError; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import static com.github.havarunner.TestHelper.runAndRecordIgnores; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package com.github.havarunner; public class IgnoredTest { static boolean ignoredTestIsRun; static boolean testInIgnoredCLassIsRun; @Test public void it_records_ignored_tests_properly() throws InitializationError { HavaRunner havaRunner = new HavaRunner(ContainingIgnoredTest.class);
final List<Description> expectedIgnoration = runAndRecordIgnores(havaRunner);
havarunner/havarunner
src/test/java/com/github/havarunner/scenarios/AfterAllsWithScenariosTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import java.util.Collections; import java.util.List; import java.util.Set; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.github.havarunner.scenarios; public class AfterAllsWithScenariosTest { private static List<String> afterAllMethodsCalled = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void HavaRunner_will_call_the_AfterAll_methods_for_all_the_scenario_instances() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/scenarios/AfterAllsWithScenariosTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import java.util.Collections; import java.util.List; import java.util.Set; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.github.havarunner.scenarios; public class AfterAllsWithScenariosTest { private static List<String> afterAllMethodsCalled = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void HavaRunner_will_call_the_AfterAll_methods_for_all_the_scenario_instances() {
run(new HavaRunner(ValidScenarioTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/covariant/SuiteConstructorSubclassTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import org.junit.After; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.suite.covariant; public class SuiteConstructorSubclassTest { static boolean suiteMemberTestInvoked = false; @After public void reset() { suiteMemberTestInvoked = false; } @Test public void havarunner_should_support_covariant_suite_objects(){
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/suite/covariant/SuiteConstructorSubclassTest.java import com.github.havarunner.HavaRunner; import org.junit.After; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.suite.covariant; public class SuiteConstructorSubclassTest { static boolean suiteMemberTestInvoked = false; @After public void reset() { suiteMemberTestInvoked = false; } @Test public void havarunner_should_support_covariant_suite_objects(){
run(new HavaRunner(Suite.class));
havarunner/havarunner
src/test/java/com/github/havarunner/TestMethodInSuperclassTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner; public class TestMethodInSuperclassTest { static boolean parentCalled; static boolean grandParentCalled; @Test public void HavaRunner_scans_for_test_methods_in_the_class_hierarchy() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/TestMethodInSuperclassTest.java import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner; public class TestMethodInSuperclassTest { static boolean parentCalled; static boolean grandParentCalled; @Test public void HavaRunner_scans_for_test_methods_in_the_class_hierarchy() {
run(new HavaRunner(Child.class));
havarunner/havarunner
src/test/java/com/github/havarunner/AssumeThatTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailedAssumption(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestAssumptionFailed(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.RunSequentially; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.Statement; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailedAssumption; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue;
package com.github.havarunner; public class AssumeThatTest { @Test public void HavaRunner_ignores_tests_that_use_the_assume_API_of_JUnit() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailedAssumption(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestAssumptionFailed(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/AssumeThatTest.java import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.RunSequentially; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunNotifier; import org.junit.runners.model.Statement; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailedAssumption; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeTrue; package com.github.havarunner; public class AssumeThatTest { @Test public void HavaRunner_ignores_tests_that_use_the_assume_API_of_JUnit() {
Failure failure = runAndRecordFailedAssumption(new HavaRunner(AssumptionDoesNotHold.class));
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterWhenExceptionTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static org.junit.Assert.assertTrue;
package com.github.havarunner.beforeafter; public class AfterWhenExceptionTest { static boolean afterCalled; @Test public void HavaRunner_the_after_method_even_if_the_test_fails() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterWhenExceptionTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static org.junit.Assert.assertTrue; package com.github.havarunner.beforeafter; public class AfterWhenExceptionTest { static boolean afterCalled; @Test public void HavaRunner_the_after_method_even_if_the_test_fails() {
runAndIgnoreErrors(new HavaRunner(SequentialTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/ImplicitSuiteMembersTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.google.common.collect.Lists; import org.junit.Test; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.suite; public class ImplicitSuiteMembersTest { static boolean implicitTestInvoked; @Test public void suites_implicitly_include_enclosed_classes_of_suite_members() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/suite/ImplicitSuiteMembersTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.google.common.collect.Lists; import org.junit.Test; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.suite; public class ImplicitSuiteMembersTest { static boolean implicitTestInvoked; @Test public void suites_implicitly_include_enclosed_classes_of_suite_members() {
run(new HavaRunner(Suite.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/ImplicitSuiteMembersTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.google.common.collect.Lists; import org.junit.Test; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.suite; public class ImplicitSuiteMembersTest { static boolean implicitTestInvoked; @Test public void suites_implicitly_include_enclosed_classes_of_suite_members() { run(new HavaRunner(Suite.class)); assertTrue(implicitTestInvoked); } @Test public void HavaRunner_includes_suite_members_exactly_once() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertTestClasses(List<Class> expected, Class testClass) { // Set<String> parsedClassNames = parsedTestClassNames(testClass); // assertEquals(toName(expected), parsedClassNames); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/suite/ImplicitSuiteMembersTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.google.common.collect.Lists; import org.junit.Test; import static com.github.havarunner.TestHelper.assertTestClasses; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.suite; public class ImplicitSuiteMembersTest { static boolean implicitTestInvoked; @Test public void suites_implicitly_include_enclosed_classes_of_suite_members() { run(new HavaRunner(Suite.class)); assertTrue(implicitTestInvoked); } @Test public void HavaRunner_includes_suite_members_exactly_once() {
assertTestClasses(Lists.<Class>newArrayList(SuiteMember.class, SuiteMember.InnerSuiteClass.class), Suite.class);
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterBeforeTimingTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.beforeafter; public class AfterBeforeTimingTest { static long beforeCalled; static long testCalled; static long afterCalled; @Test public void HavaRunner_calls_first_before_then_test_and_finally_after() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterBeforeTimingTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.beforeafter; public class AfterBeforeTimingTest { static long beforeCalled; static long testCalled; static long afterCalled; @Test public void HavaRunner_calls_first_before_then_test_and_finally_after() {
run(new HavaRunner(SequentialTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/example/suite/scenario/RestForDifferentUsersTest.java
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import java.util.ArrayList; import static org.junit.Assert.assertEquals;
package com.github.havarunner.example.suite.scenario; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class RestForDifferentUsersTest {
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // } // Path: src/test/java/com/github/havarunner/example/suite/scenario/RestForDifferentUsersTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import java.util.ArrayList; import static org.junit.Assert.assertEquals; package com.github.havarunner.example.suite.scenario; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class RestForDifferentUsersTest {
private final WebServer webServer;
havarunner/havarunner
src/test/java/com/github/havarunner/example/suite/rest/RestTest.java
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals;
package com.github.havarunner.example.suite.rest; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class RestTest {
// Path: src/test/java/com/github/havarunner/example/suite/WebApplicationSuiteTest.java // @RunWith(HavaRunner.class) // public class WebApplicationSuiteTest implements HavaRunnerSuite<WebServer> { // // final WebServer webServer; // // public WebApplicationSuiteTest() { // this.webServer = new WebServer(); // } // // @Override // public WebServer suiteObject() { // return webServer; // } // // @Override // public void afterSuite() { // JVM calls this method in the shutdown hook // webServer.shutDown(); // } // } // // Path: src/test/java/com/github/havarunner/example/suite/WebServer.java // public class WebServer { // boolean running; // // public WebServer() { // running = true; // } // // public void shutDown() { // running = false; // } // // public int httpStatus(String url) { // return 200; // } // // public String htmlDocument(String url) { // return "<html><body><title>hello HawaRunner</title></body></html>"; // } // // public String htmlDocument(String url, String user) { // return "<html><body><title>hello "+user+"</title></body></html>"; // } // } // Path: src/test/java/com/github/havarunner/example/suite/rest/RestTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.example.suite.WebApplicationSuiteTest; import com.github.havarunner.example.suite.WebServer; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; package com.github.havarunner.example.suite.rest; @RunWith(HavaRunner.class) @PartOf(WebApplicationSuiteTest.class) public class RestTest {
private final WebServer webServer;
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*;
public void HavaRunner_marks_the_test_to_be_RunSequentially() { TestAndParameters test = findByClass(new HavaRunner(SequentialSuite.class).tests(), SuiteMember.class); assertTrue(test.runSequentially().isDefined()); assertEquals("tests in this suite do not thrive in the concurrent world", test.runSequentially().get().because()); } @Test public void HavaRunner_lets_the_test_override_the_RunSequentially_spec_of_the_suite() { TestAndParameters test = findByClass( new HavaRunner(SequentialSuite.class).tests(), SuiteMemberOverridingRunSequentially.class ); assertTrue(test.runSequentially().isDefined()); assertEquals("this suite member has its own reason for sequentiality", test.runSequentially().get().because()); } private TestAndParameters findByClass(Iterable<TestAndParameters> children, final Class clazz) { return Iterables.find(children, new Predicate<TestAndParameters>() { public boolean apply(TestAndParameters input) { return input.testClass().equals(clazz); } }); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*; public void HavaRunner_marks_the_test_to_be_RunSequentially() { TestAndParameters test = findByClass(new HavaRunner(SequentialSuite.class).tests(), SuiteMember.class); assertTrue(test.runSequentially().isDefined()); assertEquals("tests in this suite do not thrive in the concurrent world", test.runSequentially().get().because()); } @Test public void HavaRunner_lets_the_test_override_the_RunSequentially_spec_of_the_suite() { TestAndParameters test = findByClass( new HavaRunner(SequentialSuite.class).tests(), SuiteMemberOverridingRunSequentially.class ); assertTrue(test.runSequentially().isDefined()); assertEquals("this suite member has its own reason for sequentiality", test.runSequentially().get().because()); } private TestAndParameters findByClass(Iterable<TestAndParameters> children, final Class clazz) { return Iterables.find(children, new Predicate<TestAndParameters>() { public boolean apply(TestAndParameters input) { return input.testClass().equals(clazz); } }); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() {
run(new HavaRunner(SeqTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*;
@Test public void HavaRunner_lets_the_test_override_the_RunSequentially_spec_of_the_suite() { TestAndParameters test = findByClass( new HavaRunner(SequentialSuite.class).tests(), SuiteMemberOverridingRunSequentially.class ); assertTrue(test.runSequentially().isDefined()); assertEquals("this suite member has its own reason for sequentiality", test.runSequentially().get().because()); } private TestAndParameters findByClass(Iterable<TestAndParameters> children, final Class clazz) { return Iterables.find(children, new Predicate<TestAndParameters>() { public boolean apply(TestAndParameters input) { return input.testClass().equals(clazz); } }); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() { run(new HavaRunner(SeqTest.class)); } @Test public void HavaRunner_can_run_sequentially_only_tests_of_same_instance() { if (items.get(0).equals(1)) { // if-else, because we can't be sure of the order in which the test methods are run
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*; @Test public void HavaRunner_lets_the_test_override_the_RunSequentially_spec_of_the_suite() { TestAndParameters test = findByClass( new HavaRunner(SequentialSuite.class).tests(), SuiteMemberOverridingRunSequentially.class ); assertTrue(test.runSequentially().isDefined()); assertEquals("this suite member has its own reason for sequentiality", test.runSequentially().get().because()); } private TestAndParameters findByClass(Iterable<TestAndParameters> children, final Class clazz) { return Iterables.find(children, new Predicate<TestAndParameters>() { public boolean apply(TestAndParameters input) { return input.testClass().equals(clazz); } }); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() { run(new HavaRunner(SeqTest.class)); } @Test public void HavaRunner_can_run_sequentially_only_tests_of_same_instance() { if (items.get(0).equals(1)) { // if-else, because we can't be sure of the order in which the test methods are run
assertAllEqual(1, items.subList(0, 100));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*;
}); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() { run(new HavaRunner(SeqTest.class)); } @Test public void HavaRunner_can_run_sequentially_only_tests_of_same_instance() { if (items.get(0).equals(1)) { // if-else, because we can't be sure of the order in which the test methods are run assertAllEqual(1, items.subList(0, 100)); assertAllEqual(2, items.subList(100, 200)); } else { assertAllEqual(2, items.subList(0, 100)); assertAllEqual(1, items.subList(100, 200)); } } @RunSequentially( because = "this test doesn't thrive in the concurrent world", with = RunSequentially.SequentialityContext.TESTS_OF_SAME_INSTANCE ) static class SeqTest { @Test void test1() throws InterruptedException {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void assertAllEqual(int expected, List<Integer> integers) { // assertTrue(allEqual(expected, integers)); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/RunSequentiallyTestsOfSameInstance.java import com.github.havarunner.ConcurrencyControl; import com.github.havarunner.HavaRunner; import com.github.havarunner.TestAndParameters; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.annotation.Scenarios; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import static com.github.havarunner.ConcurrencyControl.semaphore; import static com.github.havarunner.TestHelper.addHundredTimes; import static com.github.havarunner.TestHelper.assertAllEqual; import static com.github.havarunner.TestHelper.run; import static com.google.common.collect.Collections2.filter; import static org.junit.Assert.*; }); } } public static class when_there_is_only_one_test { static List<Integer> items = Lists.newArrayList(); @BeforeClass public static void runTest() { run(new HavaRunner(SeqTest.class)); } @Test public void HavaRunner_can_run_sequentially_only_tests_of_same_instance() { if (items.get(0).equals(1)) { // if-else, because we can't be sure of the order in which the test methods are run assertAllEqual(1, items.subList(0, 100)); assertAllEqual(2, items.subList(100, 200)); } else { assertAllEqual(2, items.subList(0, 100)); assertAllEqual(1, items.subList(100, 200)); } } @RunSequentially( because = "this test doesn't thrive in the concurrent world", with = RunSequentially.SequentialityContext.TESTS_OF_SAME_INSTANCE ) static class SeqTest { @Test void test1() throws InterruptedException {
addHundredTimes(1, items);
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/afterall/SuiteMember1.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // }
import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import static com.github.havarunner.TestHelper.addHundredTimes;
package com.github.havarunner.sequentiality.afterall; @PartOf(SequentialSuite.class) class SuiteMember1 { SuiteMember1(String suiteObject) {} @Test void test() {} @AfterAll void shutdown() throws InterruptedException {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> void addHundredTimes(T item, List<T> items) throws InterruptedException { // for (int i = 0; i < 100; i++) { // Thread.sleep(1); // Sleep to increase chances of context switching // items.add(item); // } // } // Path: src/test/java/com/github/havarunner/sequentiality/afterall/SuiteMember1.java import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.PartOf; import org.junit.Test; import static com.github.havarunner.TestHelper.addHundredTimes; package com.github.havarunner.sequentiality.afterall; @PartOf(SequentialSuite.class) class SuiteMember1 { SuiteMember1(String suiteObject) {} @Test void test() {} @AfterAll void shutdown() throws InterruptedException {
addHundredTimes(1, SequentialityWithAfterAllsTest.ints);
havarunner/havarunner
src/test/java/com/github/havarunner/rules/RuleTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.Collection; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
package com.github.havarunner.rules; public class RuleTest { static Collection<Description> firstRuleApplications= Collections.synchronizedList(Lists.<Description>newArrayList()); static Collection<Description> secondRuleApplications = Collections.synchronizedList(Lists.<Description>newArrayList()); static boolean firstTestRun; static boolean secondTestRun; @Test public void HavaRunner_supports_JUnit_rules() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/rules/RuleTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.Collection; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; package com.github.havarunner.rules; public class RuleTest { static Collection<Description> firstRuleApplications= Collections.synchronizedList(Lists.<Description>newArrayList()); static Collection<Description> secondRuleApplications = Collections.synchronizedList(Lists.<Description>newArrayList()); static boolean firstTestRun; static boolean secondTestRun; @Test public void HavaRunner_supports_JUnit_rules() {
run(new HavaRunner(TestWithTwoRules.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/RunningSuiteMembersIndividuallyTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; import java.util.List; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;
package com.github.havarunner.suite; @RunWith(Enclosed.class) public class RunningSuiteMembersIndividuallyTest { public static class when_one_suite_and_scenarios { static String suiteObject; static List<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_the_suite_and_scenario_objects_to_the_test_constructor() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/suite/RunningSuiteMembersIndividuallyTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; import java.util.List; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; package com.github.havarunner.suite; @RunWith(Enclosed.class) public class RunningSuiteMembersIndividuallyTest { public static class when_one_suite_and_scenarios { static String suiteObject; static List<String> scenarios = Lists.newArrayList(); @Test public void HavaRunner_passes_the_suite_and_scenario_objects_to_the_test_constructor() {
run(new HavaRunner(test_with_scenarios_that_belongs_to_a_suite.class));
havarunner/havarunner
src/test/java/com/github/havarunner/suite/RunningSuiteMembersIndividuallyTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; import java.util.List; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;
@PartOf(Suite.class) static class TestInASuite { TestInASuite(String suiteObj) { receivedSuiteObjects.add(suiteObj); } @Test void test() { } } @PartOf(Suite.class) static class AnotherTestInTheSuite { AnotherTestInTheSuite(String suiteObj) { receivedSuiteObjects.add(suiteObj); } @Test void test() { } } } public static class when_suite_member_is_missing_the_suite_object_constructor { @Test public void HavaRunner_gives_a_helpful_error_message_if_the_suite_test_does_not_have_the_required_constructor() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/suite/RunningSuiteMembersIndividuallyTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.annotation.Scenarios; import com.github.havarunner.exception.ConstructorNotFound; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import org.junit.runner.notification.Failure; import java.util.List; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @PartOf(Suite.class) static class TestInASuite { TestInASuite(String suiteObj) { receivedSuiteObjects.add(suiteObj); } @Test void test() { } } @PartOf(Suite.class) static class AnotherTestInTheSuite { AnotherTestInTheSuite(String suiteObj) { receivedSuiteObjects.add(suiteObj); } @Test void test() { } } } public static class when_suite_member_is_missing_the_suite_object_constructor { @Test public void HavaRunner_gives_a_helpful_error_message_if_the_suite_test_does_not_have_the_required_constructor() {
Failure failure = runAndRecordFailure(new HavaRunner(TestWithoutTheRequiredSuiteConstructor.class));
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterWhenExceptionInBeforeTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static org.junit.Assert.assertTrue;
package com.github.havarunner.beforeafter; public class AfterWhenExceptionInBeforeTest { static boolean afterCalled; @Test public void HavaRunner_the_after_method_even_if_the_before_call_fails() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterWhenExceptionInBeforeTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static org.junit.Assert.assertTrue; package com.github.havarunner.beforeafter; public class AfterWhenExceptionInBeforeTest { static boolean afterCalled; @Test public void HavaRunner_the_after_method_even_if_the_before_call_fails() {
runAndIgnoreErrors(new HavaRunner(SequentialTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/enclosed/EnclosedNonStaticTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.NonStaticInnerClassException; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals;
package com.github.havarunner.enclosed; public class EnclosedNonStaticTest { @Test public void HavaRunner_gives_a_helpful_error_if_the_class_contains_nonstatic_inner_classes() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/enclosed/EnclosedNonStaticTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.HavaRunnerSuite; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.NonStaticInnerClassException; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; package com.github.havarunner.enclosed; public class EnclosedNonStaticTest { @Test public void HavaRunner_gives_a_helpful_error_if_the_class_contains_nonstatic_inner_classes() {
Failure failure = runAndRecordFailure(new HavaRunner(TestClass.class));
havarunner/havarunner
src/test/java/com/github/havarunner/ExpectedExceptionTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.exception.TestDidNotRiseExpectedException; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertEquals;
package com.github.havarunner; public class ExpectedExceptionTest { @Test public void HavaRunner_supports_the_expected_exception_in_the_Test_annotation() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/ExpectedExceptionTest.java import com.github.havarunner.exception.TestDidNotRiseExpectedException; import org.junit.Test; import org.junit.runner.notification.Failure; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertEquals; package com.github.havarunner; public class ExpectedExceptionTest { @Test public void HavaRunner_supports_the_expected_exception_in_the_Test_annotation() {
Failure failure = runAndRecordFailure(new HavaRunner(TestWithExpectedException.class));
havarunner/havarunner
src/test/java/com/github/havarunner/OneFailsOneSucceedsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // }
import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.collect.Lists.newArrayList; import static org.junit.Assert.assertEquals;
package com.github.havarunner; public class OneFailsOneSucceedsTest { static List<String> messages = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void HavaRunner_calls_the_AfterAll_even_though_one_constructor_in_the_test_set_fails() { // This is a regression test
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // } // Path: src/test/java/com/github/havarunner/OneFailsOneSucceedsTest.java import com.github.havarunner.annotation.AfterAll; import com.github.havarunner.annotation.Scenarios; import com.google.common.collect.Lists; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.collect.Lists.newArrayList; import static org.junit.Assert.assertEquals; package com.github.havarunner; public class OneFailsOneSucceedsTest { static List<String> messages = Collections.synchronizedList(Lists.<String>newArrayList()); @Test public void HavaRunner_calls_the_AfterAll_even_though_one_constructor_in_the_test_set_fails() { // This is a regression test
runAndIgnoreErrors(new HavaRunner(OtherFails.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/ParallelismTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> boolean allEqual(final T expected, List<T> items) { // return Iterables.all(items, new Predicate<T>() { // public boolean apply(T input) { // return input.equals(expected); // } // }); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.allEqual; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail;
package com.github.havarunner.sequentiality; public class ParallelismTest { static List<Integer> items = Collections.synchronizedList(Lists.<Integer>newArrayList()); @BeforeClass public static void runTest() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> boolean allEqual(final T expected, List<T> items) { // return Iterables.all(items, new Predicate<T>() { // public boolean apply(T input) { // return input.equals(expected); // } // }); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/ParallelismTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.allEqual; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; package com.github.havarunner.sequentiality; public class ParallelismTest { static List<Integer> items = Collections.synchronizedList(Lists.<Integer>newArrayList()); @BeforeClass public static void runTest() {
run(new HavaRunner(ParallelTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/sequentiality/ParallelismTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> boolean allEqual(final T expected, List<T> items) { // return Iterables.all(items, new Predicate<T>() { // public boolean apply(T input) { // return input.equals(expected); // } // }); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.allEqual; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail;
package com.github.havarunner.sequentiality; public class ParallelismTest { static List<Integer> items = Collections.synchronizedList(Lists.<Integer>newArrayList()); @BeforeClass public static void runTest() { run(new HavaRunner(ParallelTest.class)); } @Test public void HavaRunner_runs_tests_in_parallel_by_default() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static <T> boolean allEqual(final T expected, List<T> items) { // return Iterables.all(items, new Predicate<T>() { // public boolean apply(T input) { // return input.equals(expected); // } // }); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/sequentiality/ParallelismTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import org.junit.BeforeClass; import org.junit.Test; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.allEqual; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; package com.github.havarunner.sequentiality; public class ParallelismTest { static List<Integer> items = Collections.synchronizedList(Lists.<Integer>newArrayList()); @BeforeClass public static void runTest() { run(new HavaRunner(ParallelTest.class)); } @Test public void HavaRunner_runs_tests_in_parallel_by_default() {
assertFalse(allEqual(1, items.subList(0, 100)));
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterCallOrderTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner.beforeafter; public class AfterCallOrderTest { static long grandParentAfterCalled; static long parentAfterCalled; static long childAfterCalled; @Test public void HavaRunner_calls_the_descendant_afters_first() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterCallOrderTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import org.junit.After; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner.beforeafter; public class AfterCallOrderTest { static long grandParentAfterCalled; static long parentAfterCalled; static long childAfterCalled; @Test public void HavaRunner_calls_the_descendant_afters_first() {
run(new HavaRunner(Child.class));
havarunner/havarunner
src/test/java/org/testapp/InvalidSuiteConfigTest.java
// Path: src/test/java/org/testapp/suite/TestAppSuite.java // public class TestAppSuite implements HavaRunnerSuite<String> { // @Override // public String suiteObject() { // return "hello"; // } // // @Override // public void afterSuite() { // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.SuiteMemberDoesNotBelongToSuitePackage; import org.junit.Test; import org.junit.runner.notification.Failure; import org.testapp.suite.TestAppSuite; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals;
package org.testapp; public class InvalidSuiteConfigTest { @Test public void suite_members_must_be_within_the_same_package_as_the_suite() {
// Path: src/test/java/org/testapp/suite/TestAppSuite.java // public class TestAppSuite implements HavaRunnerSuite<String> { // @Override // public String suiteObject() { // return "hello"; // } // // @Override // public void afterSuite() { // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/org/testapp/InvalidSuiteConfigTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.SuiteMemberDoesNotBelongToSuitePackage; import org.junit.Test; import org.junit.runner.notification.Failure; import org.testapp.suite.TestAppSuite; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals; package org.testapp; public class InvalidSuiteConfigTest { @Test public void suite_members_must_be_within_the_same_package_as_the_suite() {
Failure failure = runAndRecordFailure(new HavaRunner(InvalidSuiteMember.class));
havarunner/havarunner
src/test/java/org/testapp/InvalidSuiteConfigTest.java
// Path: src/test/java/org/testapp/suite/TestAppSuite.java // public class TestAppSuite implements HavaRunnerSuite<String> { // @Override // public String suiteObject() { // return "hello"; // } // // @Override // public void afterSuite() { // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.SuiteMemberDoesNotBelongToSuitePackage; import org.junit.Test; import org.junit.runner.notification.Failure; import org.testapp.suite.TestAppSuite; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals;
package org.testapp; public class InvalidSuiteConfigTest { @Test public void suite_members_must_be_within_the_same_package_as_the_suite() { Failure failure = runAndRecordFailure(new HavaRunner(InvalidSuiteMember.class)); assertEquals(SuiteMemberDoesNotBelongToSuitePackage.class, failure.getException().getClass()); assertEquals( "Suite member org.testapp.InvalidSuiteConfigTest$InvalidSuiteMember must be within the same package as the suite org.testapp.suite.TestAppSuite. Try moving InvalidSuiteMember under the package org.testapp.suite.", failure.getException().getMessage() ); }
// Path: src/test/java/org/testapp/suite/TestAppSuite.java // public class TestAppSuite implements HavaRunnerSuite<String> { // @Override // public String suiteObject() { // return "hello"; // } // // @Override // public void afterSuite() { // } // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/org/testapp/InvalidSuiteConfigTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.PartOf; import com.github.havarunner.exception.SuiteMemberDoesNotBelongToSuitePackage; import org.junit.Test; import org.junit.runner.notification.Failure; import org.testapp.suite.TestAppSuite; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals; package org.testapp; public class InvalidSuiteConfigTest { @Test public void suite_members_must_be_within_the_same_package_as_the_suite() { Failure failure = runAndRecordFailure(new HavaRunner(InvalidSuiteMember.class)); assertEquals(SuiteMemberDoesNotBelongToSuitePackage.class, failure.getException().getClass()); assertEquals( "Suite member org.testapp.InvalidSuiteConfigTest$InvalidSuiteMember must be within the same package as the suite org.testapp.suite.TestAppSuite. Try moving InvalidSuiteMember under the package org.testapp.suite.", failure.getException().getMessage() ); }
@PartOf(TestAppSuite.class)
havarunner/havarunner
src/test/java/com/github/havarunner/validations/UnsupportedJUnitAnnotationsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.exception.UnsupportedAnnotationException; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals;
package com.github.havarunner.validations; public class UnsupportedJUnitAnnotationsTest { @Test public void HavaRunner_gives_a_helpful_error_message_a_parallel_test_uses_an_annotation_that_may_only_be_used_with_sequential_tests() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithBefore.class);
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/validations/UnsupportedJUnitAnnotationsTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.exception.UnsupportedAnnotationException; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; package com.github.havarunner.validations; public class UnsupportedJUnitAnnotationsTest { @Test public void HavaRunner_gives_a_helpful_error_message_a_parallel_test_uses_an_annotation_that_may_only_be_used_with_sequential_tests() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithBefore.class);
UnsupportedAnnotationException report = (UnsupportedAnnotationException) runAndRecordFailure(havaRunner).getException();
havarunner/havarunner
src/test/java/com/github/havarunner/validations/UnsupportedJUnitAnnotationsTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.exception.UnsupportedAnnotationException; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals;
package com.github.havarunner.validations; public class UnsupportedJUnitAnnotationsTest { @Test public void HavaRunner_gives_a_helpful_error_message_a_parallel_test_uses_an_annotation_that_may_only_be_used_with_sequential_tests() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithBefore.class); UnsupportedAnnotationException report = (UnsupportedAnnotationException) runAndRecordFailure(havaRunner).getException(); assertEquals(report.annotationClass(), Before.class); assertEquals( "Only tests that are @RunSequentially may use @Before (class com.github.havarunner.validations.UnsupportedJUnitAnnotationsTest$ParallelTestWithBefore uses the unsupported annotation org.junit.Before)", report.getMessage() ); } @Test public void HavaRunner_gives_a_helpful_error_message_when_a_test_uses_an_unsupported_junit_annotation() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithAfterClass.class); UnsupportedAnnotationException report = (UnsupportedAnnotationException) runAndRecordFailure(havaRunner).getException(); assertEquals(report.annotationClass(), AfterClass.class); assertEquals( "class com.github.havarunner.validations.UnsupportedJUnitAnnotationsTest$ParallelTestWithAfterClass uses the unsupported annotation org.junit.AfterClass", report.getMessage() ); } @Test public void sequential_tests_may_use_Before() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static Failure runAndRecordFailure(HavaRunner havaRunner) { // final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); // RunNotifier runNotifier = new RunNotifier() { // @Override // public void fireTestFailure(Failure failure) { // expectedFailure.set(failure); // } // }; // run(havaRunner, runNotifier); // return expectedFailure.get(); // } // Path: src/test/java/com/github/havarunner/validations/UnsupportedJUnitAnnotationsTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.RunSequentially; import com.github.havarunner.exception.UnsupportedAnnotationException; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndRecordFailure; import static org.junit.Assert.assertEquals; package com.github.havarunner.validations; public class UnsupportedJUnitAnnotationsTest { @Test public void HavaRunner_gives_a_helpful_error_message_a_parallel_test_uses_an_annotation_that_may_only_be_used_with_sequential_tests() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithBefore.class); UnsupportedAnnotationException report = (UnsupportedAnnotationException) runAndRecordFailure(havaRunner).getException(); assertEquals(report.annotationClass(), Before.class); assertEquals( "Only tests that are @RunSequentially may use @Before (class com.github.havarunner.validations.UnsupportedJUnitAnnotationsTest$ParallelTestWithBefore uses the unsupported annotation org.junit.Before)", report.getMessage() ); } @Test public void HavaRunner_gives_a_helpful_error_message_when_a_test_uses_an_unsupported_junit_annotation() { HavaRunner havaRunner = new HavaRunner(ParallelTestWithAfterClass.class); UnsupportedAnnotationException report = (UnsupportedAnnotationException) runAndRecordFailure(havaRunner).getException(); assertEquals(report.annotationClass(), AfterClass.class); assertEquals( "class com.github.havarunner.validations.UnsupportedJUnitAnnotationsTest$ParallelTestWithAfterClass uses the unsupported annotation org.junit.AfterClass", report.getMessage() ); } @Test public void sequential_tests_may_use_Before() {
run(new HavaRunner(SequentialTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/TestInAbstractSuperclass.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue;
package com.github.havarunner; public class TestInAbstractSuperclass { static boolean parentTestRun; @Test public void HavaRunner_should_discover_tests_in_abstract_super_class() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/TestInAbstractSuperclass.java import org.junit.Test; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertTrue; package com.github.havarunner; public class TestInAbstractSuperclass { static boolean parentTestRun; @Test public void HavaRunner_should_discover_tests_in_abstract_super_class() {
run(new HavaRunner(Child.class));
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterAllTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.base.Preconditions.checkNotNull; import static org.junit.Assert.*;
package com.github.havarunner.beforeafter; @RunWith(Enclosed.class) public class AfterAllTest { public static class when_the_test_class_contains_multiple_tests { static Long test1MethodCall; static Long test2MethodCall; static List<Long> afterMethodCalls = new CopyOnWriteArrayList<>(); @Test public void HavaRunner_calls_the_After_method_once_for_the_instance() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterAllTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.base.Preconditions.checkNotNull; import static org.junit.Assert.*; package com.github.havarunner.beforeafter; @RunWith(Enclosed.class) public class AfterAllTest { public static class when_the_test_class_contains_multiple_tests { static Long test1MethodCall; static Long test2MethodCall; static List<Long> afterMethodCalls = new CopyOnWriteArrayList<>(); @Test public void HavaRunner_calls_the_After_method_once_for_the_instance() {
run(new HavaRunner(MultipleTests.class));
havarunner/havarunner
src/test/java/com/github/havarunner/beforeafter/AfterAllTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // }
import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.base.Preconditions.checkNotNull; import static org.junit.Assert.*;
assertEquals(1, afterMethodCalls.size()); } static class MultipleTests { @Test void test_1() { assertNull(test1MethodCall); test1MethodCall = System.currentTimeMillis(); } @Test void test_2() { assertNull(test2MethodCall); test2MethodCall = System.currentTimeMillis(); } @AfterAll void cleanUp() throws InterruptedException { Thread.sleep(1); // Sleep. Otherwise millisecond-precision is not enough. afterMethodCalls.add(System.currentTimeMillis()); } } } public static class when_test_fails { static boolean worldIsBuilt = false; static boolean worldIsDestroyed = false; @Test public void HavaRunner_calls_the_AfterAll_method_even_if_the_test_throws_an_exception() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // // Path: src/test/java/com/github/havarunner/TestHelper.java // public static void runAndIgnoreErrors(HavaRunner havaRunner) { // run(havaRunner, new RunNotifier()); // } // Path: src/test/java/com/github/havarunner/beforeafter/AfterAllTest.java import com.github.havarunner.HavaRunner; import com.github.havarunner.annotation.AfterAll; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import static com.github.havarunner.TestHelper.run; import static com.github.havarunner.TestHelper.runAndIgnoreErrors; import static com.google.common.base.Preconditions.checkNotNull; import static org.junit.Assert.*; assertEquals(1, afterMethodCalls.size()); } static class MultipleTests { @Test void test_1() { assertNull(test1MethodCall); test1MethodCall = System.currentTimeMillis(); } @Test void test_2() { assertNull(test2MethodCall); test2MethodCall = System.currentTimeMillis(); } @AfterAll void cleanUp() throws InterruptedException { Thread.sleep(1); // Sleep. Otherwise millisecond-precision is not enough. afterMethodCalls.add(System.currentTimeMillis()); } } } public static class when_test_fails { static boolean worldIsBuilt = false; static boolean worldIsDestroyed = false; @Test public void HavaRunner_calls_the_AfterAll_method_even_if_the_test_throws_an_exception() {
runAndIgnoreErrors(new HavaRunner(AfterFailingTest.class));
havarunner/havarunner
src/test/java/com/github/havarunner/SameInstanceTest.java
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // }
import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import com.github.havarunner.annotation.Scenarios; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertSame;
package com.github.havarunner; @RunWith(Enclosed.class) public class SameInstanceTest { public static class when_the_test_has_multiple_scenarios { static List<Object> instanceWhenMars = Collections.synchronizedList(Lists.newArrayList()); static List<Object> instanceWhenVenus = Collections.synchronizedList(Lists.newArrayList()); @Test public void HavaRunner_calls_each_test_method_on_the_same_instance() {
// Path: src/test/java/com/github/havarunner/TestHelper.java // public static void run(HavaRunner havaRunner, RunNotifier runNotifier) { // havaRunner.run(runNotifier); // } // Path: src/test/java/com/github/havarunner/SameInstanceTest.java import com.github.havarunner.HavaRunner; import com.google.common.collect.Lists; import com.github.havarunner.annotation.Scenarios; import org.junit.Test; import org.junit.experimental.runners.Enclosed; import org.junit.runner.RunWith; import java.util.Collection; import java.util.Collections; import java.util.List; import static com.github.havarunner.TestHelper.run; import static org.junit.Assert.assertSame; package com.github.havarunner; @RunWith(Enclosed.class) public class SameInstanceTest { public static class when_the_test_has_multiple_scenarios { static List<Object> instanceWhenMars = Collections.synchronizedList(Lists.newArrayList()); static List<Object> instanceWhenVenus = Collections.synchronizedList(Lists.newArrayList()); @Test public void HavaRunner_calls_each_test_method_on_the_same_instance() {
run(new HavaRunner(TestWithScenarios.class));
dmitriid/cali
src/main/java/com/dmitriid/cali/db/Neo4JConnector.java
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // }
import com.dmitriid.cali.CommandLine; import com.tinkerpop.blueprints.pgm.Vertex; import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext;
//------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class Neo4JConnector extends DBConnector { public Neo4JConnector(String[] args) { super();
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // } // Path: src/main/java/com/dmitriid/cali/db/Neo4JConnector.java import com.dmitriid.cali.CommandLine; import com.tinkerpop.blueprints.pgm.Vertex; import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext; //------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class Neo4JConnector extends DBConnector { public Neo4JConnector(String[] args) { super();
CommandLine line = new CommandLine(args);
dmitriid/cali
src/main/java/com/dmitriid/cali/db/OrientDBConnector.java
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // } // // Path: src/main/java/com/dmitriid/cali/converters/ORecordIdConverter.java // public class ORecordIdConverter extends AbstractErlangJavaConverter<ORecordId, OtpErlangString> { // public ORecordIdConverter() { // super(ORecordId.class, OtpErlangString.class); // } // // @Override // protected OtpErlangString fromJava(ORecordId in) { // return new OtpErlangString(in.toString()); // } // // @Override // protected ORecordId fromErlang(OtpErlangString in) { // return null; // } // }
import com.dmitriid.cali.CommandLine; import com.dmitriid.cali.converters.ORecordIdConverter; import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext;
//------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class OrientDBConnector extends DBConnector{ public OrientDBConnector(String[] args) { super();
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // } // // Path: src/main/java/com/dmitriid/cali/converters/ORecordIdConverter.java // public class ORecordIdConverter extends AbstractErlangJavaConverter<ORecordId, OtpErlangString> { // public ORecordIdConverter() { // super(ORecordId.class, OtpErlangString.class); // } // // @Override // protected OtpErlangString fromJava(ORecordId in) { // return new OtpErlangString(in.toString()); // } // // @Override // protected ORecordId fromErlang(OtpErlangString in) { // return null; // } // } // Path: src/main/java/com/dmitriid/cali/db/OrientDBConnector.java import com.dmitriid.cali.CommandLine; import com.dmitriid.cali.converters.ORecordIdConverter; import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext; //------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class OrientDBConnector extends DBConnector{ public OrientDBConnector(String[] args) { super();
CommandLine line = new CommandLine(args);
dmitriid/cali
src/main/java/com/dmitriid/cali/db/OrientDBConnector.java
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // } // // Path: src/main/java/com/dmitriid/cali/converters/ORecordIdConverter.java // public class ORecordIdConverter extends AbstractErlangJavaConverter<ORecordId, OtpErlangString> { // public ORecordIdConverter() { // super(ORecordId.class, OtpErlangString.class); // } // // @Override // protected OtpErlangString fromJava(ORecordId in) { // return new OtpErlangString(in.toString()); // } // // @Override // protected ORecordId fromErlang(OtpErlangString in) { // return null; // } // }
import com.dmitriid.cali.CommandLine; import com.dmitriid.cali.converters.ORecordIdConverter; import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext;
//------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class OrientDBConnector extends DBConnector{ public OrientDBConnector(String[] args) { super(); CommandLine line = new CommandLine(args); String url = line.optionValue("u", "url"); String user = line.optionValue("user"); String password = line.optionValue("pass");
// Path: src/main/java/com/dmitriid/cali/CommandLine.java // public class CommandLine { // private HashMap<String, String> _options = new HashMap<String, String>(); // // private Pattern _optionMatch = Pattern.compile("^[-]{1,2}(\\w+)"); // handle -o and --opt and -opt // // public CommandLine(String[] args) { // String optionName = null; // Matcher matcher; // // for(String o : args) { // matcher = _optionMatch.matcher(o); // if(matcher.find()) { // if(optionName != null) { // in case there was an option without a parameter before this one // _options.put(matcher.group(1), null); // optionName = null; // } // optionName = matcher.group(1); // } else { // if(optionName != null) { // _options.put(optionName, o); // } // // optionName = null; // } // } // } // // public boolean hasOption(String... keys) { // for(String key : keys) { // if(_options.containsKey(key)) { // return true; // } // } // return false; // } // // public String optionValue(String... options){ // for(String option : options){ // if(_options.containsKey(option)){ // return _options.get(option); // } // } // // return null; // } // } // // Path: src/main/java/com/dmitriid/cali/converters/ORecordIdConverter.java // public class ORecordIdConverter extends AbstractErlangJavaConverter<ORecordId, OtpErlangString> { // public ORecordIdConverter() { // super(ORecordId.class, OtpErlangString.class); // } // // @Override // protected OtpErlangString fromJava(ORecordId in) { // return new OtpErlangString(in.toString()); // } // // @Override // protected ORecordId fromErlang(OtpErlangString in) { // return null; // } // } // Path: src/main/java/com/dmitriid/cali/db/OrientDBConnector.java import com.dmitriid.cali.CommandLine; import com.dmitriid.cali.converters.ORecordIdConverter; import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph; import com.tinkerpop.gremlin.compiler.context.GremlinScriptContext; //------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; class OrientDBConnector extends DBConnector{ public OrientDBConnector(String[] args) { super(); CommandLine line = new CommandLine(args); String url = line.optionValue("u", "url"); String user = line.optionValue("user"); String password = line.optionValue("pass");
_cm.register(new ORecordIdConverter());
dmitriid/cali
src/main/java/com/dmitriid/cali/db/DBConnector.java
// Path: src/main/java/com/dmitriid/ji/ConversionManager.java // public class ConversionManager { // // private final Map<Class<?>, AbstractErlangJavaConverter> converters = new HashMap<Class<?>, AbstractErlangJavaConverter>(); // // @SuppressWarnings("unchecked") // public <I, O> O convert(I in) throws IllegalArgumentException { // if(null == in){ // return (O)do_conversion(new NullObject()); // } // // return (O)do_conversion(in); // } // // public <I, O> O do_conversion(I in) throws IllegalArgumentException { // // Try exact match. // Converter converter = converters.get(in.getClass()); // if(converter != null) { // return converter.<I, O>convert(in); // } // // // Try IS-A match. // for(Map.Entry<Class<?>, AbstractErlangJavaConverter> entry : converters.entrySet()) { // if(entry.getKey().isAssignableFrom(in.getClass())) { // return (O) entry.getValue().convert(in); // } // } // // throw new IllegalArgumentException(/* describe supported arguments and given one */); // } // // //@Autowired // // public void register(AbstractErlangJavaConverter... converters) { // for(AbstractErlangJavaConverter converter : converters) { // Set<Class<?>> clazzes = converter.getSupportedClasses(); // for(Class<?> clazz : clazzes) { // if(this.converters.containsKey(clazz)) { // this.converters.get(clazz).add(converter); // } else // this.converters.put(clazz, converter); // } // } // } // // public void registerBasic(){ // register( // new IntegerConverter(), // new LongConverter(), // new FloatConverter(), // new DoubleConverter(), // // new StringConverter(), // new BinaryConverter(), // new AtomConverter(), // new ByteArrayConverter(), // // new ArrayListConverter(this), // new TupleConverter(this), // // new NullObjectConverter() // ); // } // }
import com.dmitriid.cali.converters.*; import com.dmitriid.ji.ConversionManager; import com.ericsson.otp.erlang.*; import com.tinkerpop.blueprints.pgm.Element; import com.tinkerpop.blueprints.pgm.Graph; import com.tinkerpop.blueprints.pgm.Vertex; import com.tinkerpop.gremlin.GremlinScriptEngine; import com.tinkerpop.gremlin.GremlinScriptEngineFactory; import org.neo4j.helpers.Pair; import java.util.ArrayList; import java.util.Stack;
//------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; public class DBConnector{ protected static final String GREMLIN = "gremlin"; protected static final String ROOT_VARIABLE = "$_"; protected static final String GRAPH_VARIABLE = "$_g"; protected static final String WILDCARD = "*"; protected static final String ROOT = "root"; protected static final String SCRIPT = "script"; protected static final String RESULTS = "results"; protected static final String RETURN_KEYS = "return_keys"; protected Graph _graphDb = null;
// Path: src/main/java/com/dmitriid/ji/ConversionManager.java // public class ConversionManager { // // private final Map<Class<?>, AbstractErlangJavaConverter> converters = new HashMap<Class<?>, AbstractErlangJavaConverter>(); // // @SuppressWarnings("unchecked") // public <I, O> O convert(I in) throws IllegalArgumentException { // if(null == in){ // return (O)do_conversion(new NullObject()); // } // // return (O)do_conversion(in); // } // // public <I, O> O do_conversion(I in) throws IllegalArgumentException { // // Try exact match. // Converter converter = converters.get(in.getClass()); // if(converter != null) { // return converter.<I, O>convert(in); // } // // // Try IS-A match. // for(Map.Entry<Class<?>, AbstractErlangJavaConverter> entry : converters.entrySet()) { // if(entry.getKey().isAssignableFrom(in.getClass())) { // return (O) entry.getValue().convert(in); // } // } // // throw new IllegalArgumentException(/* describe supported arguments and given one */); // } // // //@Autowired // // public void register(AbstractErlangJavaConverter... converters) { // for(AbstractErlangJavaConverter converter : converters) { // Set<Class<?>> clazzes = converter.getSupportedClasses(); // for(Class<?> clazz : clazzes) { // if(this.converters.containsKey(clazz)) { // this.converters.get(clazz).add(converter); // } else // this.converters.put(clazz, converter); // } // } // } // // public void registerBasic(){ // register( // new IntegerConverter(), // new LongConverter(), // new FloatConverter(), // new DoubleConverter(), // // new StringConverter(), // new BinaryConverter(), // new AtomConverter(), // new ByteArrayConverter(), // // new ArrayListConverter(this), // new TupleConverter(this), // // new NullObjectConverter() // ); // } // } // Path: src/main/java/com/dmitriid/cali/db/DBConnector.java import com.dmitriid.cali.converters.*; import com.dmitriid.ji.ConversionManager; import com.ericsson.otp.erlang.*; import com.tinkerpop.blueprints.pgm.Element; import com.tinkerpop.blueprints.pgm.Graph; import com.tinkerpop.blueprints.pgm.Vertex; import com.tinkerpop.gremlin.GremlinScriptEngine; import com.tinkerpop.gremlin.GremlinScriptEngineFactory; import org.neo4j.helpers.Pair; import java.util.ArrayList; import java.util.Stack; //------------------------------------------------------------------------------ // Copyright (c) 2010. Dmitrii Dimandt <dmitrii@dmitriid.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.dmitriid.cali.db; public class DBConnector{ protected static final String GREMLIN = "gremlin"; protected static final String ROOT_VARIABLE = "$_"; protected static final String GRAPH_VARIABLE = "$_g"; protected static final String WILDCARD = "*"; protected static final String ROOT = "root"; protected static final String SCRIPT = "script"; protected static final String RESULTS = "results"; protected static final String RETURN_KEYS = "return_keys"; protected Graph _graphDb = null;
protected ConversionManager _cm = null;
dmitriid/cali
src/main/java/com/dmitriid/cali/converters/ElementObject.java
// Path: src/main/java/com/dmitriid/cali/db/Tokens.java // public class Tokens { // // public static final String JSON_APPLICATION = "json/application"; // // public static final String _ID = "_id"; // public static final String ID = "id"; // public static final String DIRECTION = "direction"; // public static final String _TYPE = "_type"; // public static final String _LABEL = "_label"; // public static final String _OUT_V = "_outV"; // public static final String _IN_V = "_inV"; // public static final String VERTEX = "vertex"; // public static final String EDGE = "edge"; // // // public static final String REXSTER_GRAPH_TYPE = "rexster.graph.type"; // public static final String REXSTER_GRAPH_FILE = "rexster.graph.file"; // public static final String REXSTER_CACHE_MAXSIZE = "rexster.cache.maxsize"; // public static final String REXSTER_PACKAGES_ALLOWED = "rexster.packages.allowed"; // // public static final String DESCRIPTION = "description"; // public static final String PARAMETERS = "parameters"; // public static final String API = "api"; // }
import com.dmitriid.cali.db.Tokens; import com.tinkerpop.blueprints.pgm.Edge; import com.tinkerpop.blueprints.pgm.Element; import com.tinkerpop.blueprints.pgm.Vertex; import org.neo4j.helpers.Pair; import java.util.ArrayList; import java.util.Set;
public Object get(){ if(_o instanceof Element){ return get_properties(); } return _o; } Object get_properties(){ ArrayList properties = new ArrayList(); if(null == _properties) { if(_o instanceof Edge){ Edge edge = (Edge) _o; properties.add(new Pair("label", edge.getLabel())); properties.add(new Pair("inE", edge.getInVertex().getId())); properties.add(new Pair("outE", edge.getOutVertex().getId())); return new Pair("edge", properties); } else { Vertex vertex = (Vertex) _o; properties.add(new Pair("id", vertex.getId())); for(String key : vertex.getPropertyKeys()) { properties.add(new Pair(key, vertex.getProperty(key))); } } } else { Element element = (Element) _o; for(Object k : _properties) { String key = (String) k;
// Path: src/main/java/com/dmitriid/cali/db/Tokens.java // public class Tokens { // // public static final String JSON_APPLICATION = "json/application"; // // public static final String _ID = "_id"; // public static final String ID = "id"; // public static final String DIRECTION = "direction"; // public static final String _TYPE = "_type"; // public static final String _LABEL = "_label"; // public static final String _OUT_V = "_outV"; // public static final String _IN_V = "_inV"; // public static final String VERTEX = "vertex"; // public static final String EDGE = "edge"; // // // public static final String REXSTER_GRAPH_TYPE = "rexster.graph.type"; // public static final String REXSTER_GRAPH_FILE = "rexster.graph.file"; // public static final String REXSTER_CACHE_MAXSIZE = "rexster.cache.maxsize"; // public static final String REXSTER_PACKAGES_ALLOWED = "rexster.packages.allowed"; // // public static final String DESCRIPTION = "description"; // public static final String PARAMETERS = "parameters"; // public static final String API = "api"; // } // Path: src/main/java/com/dmitriid/cali/converters/ElementObject.java import com.dmitriid.cali.db.Tokens; import com.tinkerpop.blueprints.pgm.Edge; import com.tinkerpop.blueprints.pgm.Element; import com.tinkerpop.blueprints.pgm.Vertex; import org.neo4j.helpers.Pair; import java.util.ArrayList; import java.util.Set; public Object get(){ if(_o instanceof Element){ return get_properties(); } return _o; } Object get_properties(){ ArrayList properties = new ArrayList(); if(null == _properties) { if(_o instanceof Edge){ Edge edge = (Edge) _o; properties.add(new Pair("label", edge.getLabel())); properties.add(new Pair("inE", edge.getInVertex().getId())); properties.add(new Pair("outE", edge.getOutVertex().getId())); return new Pair("edge", properties); } else { Vertex vertex = (Vertex) _o; properties.add(new Pair("id", vertex.getId())); for(String key : vertex.getPropertyKeys()) { properties.add(new Pair(key, vertex.getProperty(key))); } } } else { Element element = (Element) _o; for(Object k : _properties) { String key = (String) k;
if(key.equals(Tokens._ID)) {
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DayPickerViewAnimator.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int DAY_PICKER_INDEX = 0; // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int MONTH_PICKER_INDEX = 1;
import android.content.Context; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ViewAnimator; import com.philliphsu.bottomsheetpickers.R; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.DAY_PICKER_INDEX; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.MONTH_PICKER_INDEX;
package com.philliphsu.bottomsheetpickers.date; /** * Parent of {@link PagingDayPickerView} and {@link MonthPickerView}. */ public final class DayPickerViewAnimator extends ViewAnimator { private final Animation mDayPickerInAnimation; private final Animation mDayPickerOutAnimation; private final Animation mMonthPickerInAnimation; private final Animation mMonthPickerOutAnimation; public DayPickerViewAnimator(Context context, AttributeSet attrs) { super(context, attrs); mDayPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_up); mDayPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_down); mMonthPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_down); mMonthPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_up); } @Override public void setDisplayedChild(int whichChild) { switch (whichChild) {
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int DAY_PICKER_INDEX = 0; // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int MONTH_PICKER_INDEX = 1; // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DayPickerViewAnimator.java import android.content.Context; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ViewAnimator; import com.philliphsu.bottomsheetpickers.R; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.DAY_PICKER_INDEX; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.MONTH_PICKER_INDEX; package com.philliphsu.bottomsheetpickers.date; /** * Parent of {@link PagingDayPickerView} and {@link MonthPickerView}. */ public final class DayPickerViewAnimator extends ViewAnimator { private final Animation mDayPickerInAnimation; private final Animation mDayPickerOutAnimation; private final Animation mMonthPickerInAnimation; private final Animation mMonthPickerOutAnimation; public DayPickerViewAnimator(Context context, AttributeSet attrs) { super(context, attrs); mDayPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_up); mDayPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_down); mMonthPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_down); mMonthPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_up); } @Override public void setDisplayedChild(int whichChild) { switch (whichChild) {
case DAY_PICKER_INDEX:
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DayPickerViewAnimator.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int DAY_PICKER_INDEX = 0; // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int MONTH_PICKER_INDEX = 1;
import android.content.Context; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ViewAnimator; import com.philliphsu.bottomsheetpickers.R; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.DAY_PICKER_INDEX; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.MONTH_PICKER_INDEX;
package com.philliphsu.bottomsheetpickers.date; /** * Parent of {@link PagingDayPickerView} and {@link MonthPickerView}. */ public final class DayPickerViewAnimator extends ViewAnimator { private final Animation mDayPickerInAnimation; private final Animation mDayPickerOutAnimation; private final Animation mMonthPickerInAnimation; private final Animation mMonthPickerOutAnimation; public DayPickerViewAnimator(Context context, AttributeSet attrs) { super(context, attrs); mDayPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_up); mDayPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_down); mMonthPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_down); mMonthPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_up); } @Override public void setDisplayedChild(int whichChild) { switch (whichChild) { case DAY_PICKER_INDEX: setInAnimation(mDayPickerInAnimation); setOutAnimation(mMonthPickerOutAnimation); break;
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int DAY_PICKER_INDEX = 0; // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/PagingDayPickerView.java // static final int MONTH_PICKER_INDEX = 1; // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DayPickerViewAnimator.java import android.content.Context; import android.util.AttributeSet; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.widget.ViewAnimator; import com.philliphsu.bottomsheetpickers.R; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.DAY_PICKER_INDEX; import static com.philliphsu.bottomsheetpickers.date.PagingDayPickerView.MONTH_PICKER_INDEX; package com.philliphsu.bottomsheetpickers.date; /** * Parent of {@link PagingDayPickerView} and {@link MonthPickerView}. */ public final class DayPickerViewAnimator extends ViewAnimator { private final Animation mDayPickerInAnimation; private final Animation mDayPickerOutAnimation; private final Animation mMonthPickerInAnimation; private final Animation mMonthPickerOutAnimation; public DayPickerViewAnimator(Context context, AttributeSet attrs) { super(context, attrs); mDayPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_up); mDayPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_day_picker_slide_down); mMonthPickerInAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_down); mMonthPickerOutAnimation = AnimationUtils.loadAnimation(context, R.anim.bsp_month_picker_slide_up); } @Override public void setDisplayedChild(int whichChild) { switch (whichChild) { case DAY_PICKER_INDEX: setInAnimation(mDayPickerInAnimation); setOutAnimation(mMonthPickerOutAnimation); break;
case MONTH_PICKER_INDEX:
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialogViewDelegate.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // }
import android.app.TimePickerDialog.OnTimeSetListener; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.widget.TimePicker; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull;
package com.philliphsu.bottomsheetpickers.time.numberpad; /** * Handles the {@link INumberPadTimePicker.DialogView DialogView} responsibilities of a number pad time picker dialog. */ final class NumberPadTimePickerDialogViewDelegate implements INumberPadTimePicker.DialogView { private static final String KEY_DIGITS = "digits"; // TODO: Why do we need the count? private static final String KEY_COUNT = "count"; private static final String KEY_AM_PM_STATE = "am_pm_state"; private final @NonNull DialogInterface mDelegator; private final @NonNull NumberPadTimePicker mTimePicker; private final @Nullable OnTimeSetListener mTimeSetListener; private final INumberPadTimePicker.DialogPresenter mPresenter; // Dummy TimePicker Passed to onTimeSet() callback. private final TimePicker mDummy; private View mOkButton; // TODO: Consider removing the okButton param because (1) the alert layout does not have it ready // at the time of construction and (2) the bottom sheet layout does not need this class anymore // to control its FAB. Keep the setOkButton() instead. NumberPadTimePickerDialogViewDelegate(@NonNull DialogInterface delegator, @NonNull Context context, @NonNull NumberPadTimePicker timePicker, @Nullable View okButton, @Nullable OnTimeSetListener listener, boolean is24HourMode) {
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialogViewDelegate.java import android.app.TimePickerDialog.OnTimeSetListener; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.widget.TimePicker; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; package com.philliphsu.bottomsheetpickers.time.numberpad; /** * Handles the {@link INumberPadTimePicker.DialogView DialogView} responsibilities of a number pad time picker dialog. */ final class NumberPadTimePickerDialogViewDelegate implements INumberPadTimePicker.DialogView { private static final String KEY_DIGITS = "digits"; // TODO: Why do we need the count? private static final String KEY_COUNT = "count"; private static final String KEY_AM_PM_STATE = "am_pm_state"; private final @NonNull DialogInterface mDelegator; private final @NonNull NumberPadTimePicker mTimePicker; private final @Nullable OnTimeSetListener mTimeSetListener; private final INumberPadTimePicker.DialogPresenter mPresenter; // Dummy TimePicker Passed to onTimeSet() callback. private final TimePicker mDummy; private View mOkButton; // TODO: Consider removing the okButton param because (1) the alert layout does not have it ready // at the time of construction and (2) the bottom sheet layout does not need this class anymore // to control its FAB. Keep the setOkButton() instead. NumberPadTimePickerDialogViewDelegate(@NonNull DialogInterface delegator, @NonNull Context context, @NonNull NumberPadTimePicker timePicker, @Nullable View okButton, @Nullable OnTimeSetListener listener, boolean is24HourMode) {
mDelegator = checkNotNull(delegator);
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DatePickerController.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DatePickerDialog.java // public interface OnDateChangedListener { // // public void onDateChanged(); // }
import com.philliphsu.bottomsheetpickers.date.DatePickerDialog.OnDateChangedListener; import java.util.Calendar;
/* * Copyright (C) 2013 The Android Open Source Project * * 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.philliphsu.bottomsheetpickers.date; /** * Controller class to communicate among the various components of the date picker dialog. */ public interface DatePickerController { void onYearSelected(int year); void onDayOfMonthSelected(int year, int month, int day); void onMonthYearSelected(int month, int year);
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DatePickerDialog.java // public interface OnDateChangedListener { // // public void onDateChanged(); // } // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/date/DatePickerController.java import com.philliphsu.bottomsheetpickers.date.DatePickerDialog.OnDateChangedListener; import java.util.Calendar; /* * Copyright (C) 2013 The Android Open Source Project * * 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.philliphsu.bottomsheetpickers.date; /** * Controller class to communicate among the various components of the date picker dialog. */ public interface DatePickerController { void onYearSelected(int year); void onDayOfMonthSelected(int year, int month, int day); void onMonthYearSelected(int month, int year);
void registerOnDateChangedListener(OnDateChangedListener listener);
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerPresenter.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/DigitwiseTimeModel.java // static final int MAX_DIGITS = 4;
import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.AM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.HRS_24; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.PM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.UNSPECIFIED; import static com.philliphsu.bottomsheetpickers.time.numberpad.DigitwiseTimeModel.MAX_DIGITS;
package com.philliphsu.bottomsheetpickers.time.numberpad; class NumberPadTimePickerPresenter implements INumberPadTimePicker.Presenter, DigitwiseTimeModel.OnInputChangeListener { private static final int MAX_CHARS = 5; // 4 digits + time separator private final StringBuilder mFormattedInput = new StringBuilder(MAX_CHARS); private final String[] mAltTexts = new String[2]; private final @NonNull LocaleModel mLocaleModel; private final ButtonTextModel mTextModel; private final String mTimeSeparator; private final boolean mIs24HourMode; private INumberPadTimePicker.View mView; private boolean mAltKeysDisabled; private boolean mAllNumberKeysDisabled; private boolean mHeaderDisplayFocused; final DigitwiseTimeModel mTimeModel = new DigitwiseTimeModel(this); @AmPmState int mAmPmState = UNSPECIFIED; NumberPadTimePickerPresenter(@NonNull INumberPadTimePicker.View view, @NonNull LocaleModel localeModel, boolean is24HourMode) {
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/DigitwiseTimeModel.java // static final int MAX_DIGITS = 4; // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerPresenter.java import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.AM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.HRS_24; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.PM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.UNSPECIFIED; import static com.philliphsu.bottomsheetpickers.time.numberpad.DigitwiseTimeModel.MAX_DIGITS; package com.philliphsu.bottomsheetpickers.time.numberpad; class NumberPadTimePickerPresenter implements INumberPadTimePicker.Presenter, DigitwiseTimeModel.OnInputChangeListener { private static final int MAX_CHARS = 5; // 4 digits + time separator private final StringBuilder mFormattedInput = new StringBuilder(MAX_CHARS); private final String[] mAltTexts = new String[2]; private final @NonNull LocaleModel mLocaleModel; private final ButtonTextModel mTextModel; private final String mTimeSeparator; private final boolean mIs24HourMode; private INumberPadTimePicker.View mView; private boolean mAltKeysDisabled; private boolean mAllNumberKeysDisabled; private boolean mHeaderDisplayFocused; final DigitwiseTimeModel mTimeModel = new DigitwiseTimeModel(this); @AmPmState int mAmPmState = UNSPECIFIED; NumberPadTimePickerPresenter(@NonNull INumberPadTimePicker.View view, @NonNull LocaleModel localeModel, boolean is24HourMode) {
mView = checkNotNull(view);
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerPresenter.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/DigitwiseTimeModel.java // static final int MAX_DIGITS = 4;
import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.AM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.HRS_24; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.PM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.UNSPECIFIED; import static com.philliphsu.bottomsheetpickers.time.numberpad.DigitwiseTimeModel.MAX_DIGITS;
updateAltKeysStates(); updateBackspaceState(); // TOneverDO: Call before both updateAltKeysStates() and updateNumberKeysStates(). updateHeaderDisplayFocus(); } private void updateHeaderDisplayFocus() { final boolean showHeaderDisplayFocused = !(mAllNumberKeysDisabled && mAltKeysDisabled); if (mHeaderDisplayFocused != showHeaderDisplayFocused) { mView.setHeaderDisplayFocused(showHeaderDisplayFocused); mHeaderDisplayFocused = showHeaderDisplayFocused; } } private void updateBackspaceState() { mView.setBackspaceEnabled(count() > 0); } private void updateAltKeysStates() { boolean enabled = false; if (count() == 0) { // No input, no access! enabled = false; } else if (count() == 1) { // Any of 0-9 inputted, always have access in either clock. enabled = true; } else if (count() == 2) { // Any 2 digits that make a valid hour for either clock are eligible for access final int time = getDigitsAsInteger(); enabled = is24HourFormat() ? time <= 23 : time >= 10 && time <= 12;
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/DigitwiseTimeModel.java // static final int MAX_DIGITS = 4; // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerPresenter.java import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.AM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.HRS_24; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.PM; import static com.philliphsu.bottomsheetpickers.time.numberpad.AmPmState.UNSPECIFIED; import static com.philliphsu.bottomsheetpickers.time.numberpad.DigitwiseTimeModel.MAX_DIGITS; updateAltKeysStates(); updateBackspaceState(); // TOneverDO: Call before both updateAltKeysStates() and updateNumberKeysStates(). updateHeaderDisplayFocus(); } private void updateHeaderDisplayFocus() { final boolean showHeaderDisplayFocused = !(mAllNumberKeysDisabled && mAltKeysDisabled); if (mHeaderDisplayFocused != showHeaderDisplayFocused) { mView.setHeaderDisplayFocused(showHeaderDisplayFocused); mHeaderDisplayFocused = showHeaderDisplayFocused; } } private void updateBackspaceState() { mView.setBackspaceEnabled(count() > 0); } private void updateAltKeysStates() { boolean enabled = false; if (count() == 0) { // No input, no access! enabled = false; } else if (count() == 1) { // Any of 0-9 inputted, always have access in either clock. enabled = true; } else if (count() == 2) { // Any 2 digits that make a valid hour for either clock are eligible for access final int time = getDigitsAsInteger(); enabled = is24HourFormat() ? time <= 23 : time >= 10 && time <= 12;
} else if (count() == 3 || count() == MAX_DIGITS) {
philliphsu/BottomSheetPickers
bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialogThemer.java
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // }
import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull;
package com.philliphsu.bottomsheetpickers.time.numberpad; /** * Interface through which a {@link NumberPadTimePicker} contained in * a {@link BottomSheetNumberPadTimePickerDialog} can have its colors customized. */ class NumberPadTimePickerDialogThemer implements NumberPadTimePickerThemer { private final NumberPadTimePicker.NumberPadTimePickerComponent mTimePickerComponent; NumberPadTimePickerDialogThemer(@NonNull NumberPadTimePicker.NumberPadTimePickerComponent timePickerComponent) {
// Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/Preconditions.java // static <T> T checkNotNull(T t) { // if (t == null) { // throw new NullPointerException(); // } // return t; // } // Path: bottomsheetpickers/src/main/java/com/philliphsu/bottomsheetpickers/time/numberpad/NumberPadTimePickerDialogThemer.java import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import static com.philliphsu.bottomsheetpickers.time.numberpad.Preconditions.checkNotNull; package com.philliphsu.bottomsheetpickers.time.numberpad; /** * Interface through which a {@link NumberPadTimePicker} contained in * a {@link BottomSheetNumberPadTimePickerDialog} can have its colors customized. */ class NumberPadTimePickerDialogThemer implements NumberPadTimePickerThemer { private final NumberPadTimePicker.NumberPadTimePickerComponent mTimePickerComponent; NumberPadTimePickerDialogThemer(@NonNull NumberPadTimePicker.NumberPadTimePickerComponent timePickerComponent) {
mTimePickerComponent = checkNotNull(timePickerComponent);
fsmk/MCA-VTU-Lab-Manual
Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/client/Client.java
// Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/IShape.java // public interface IShape // { // // public double calcArea(); // // public double calcPerimeter(); // public String getName(); // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Circle.java // public class Circle implements IShape { // // int m_radius; // // public Circle(int radius) // { // m_radius = radius; // } // // @Override // public double calcArea() { // //Area of circle = PI * Square of radius of the circle // return Math.PI*m_radius*m_radius; // } // // @Override // public double calcPerimeter() { // //Perimeter of circle = 2 * PI * radius of the circle // return 2*Math.PI*m_radius; // } // // @Override // public String getName() { // return "Circle"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Rectangle.java // public class Rectangle implements IShape { // // private int m_breadth; // private int m_length; // // public Rectangle(int length, int breadth) // { // m_length = length; // m_breadth = breadth; // // } // // @Override // public double calcArea() { // return m_length*m_breadth; // } // // @Override // public double calcPerimeter() { // return 2*(m_length*m_breadth); // } // // @Override // public String getName() { // return "Rectangle"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Square.java // public class Square implements IShape { // // private int m_side; // // public Square(int side) // { // m_side =side; // } // // @Override // public double calcArea() { // return m_side*m_side; // } // // // @Override // public double calcPerimeter() { // return 4*m_side; // } // // @Override // public String getName() { // return "Square"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Triangle.java // public class Triangle implements IShape { // // int m_s1; // int m_s2; // int m_s3; // // public Triangle(int s1, int s2, int s3) // { // m_s1 = s1; // m_s2 = s2; // m_s3 = s3; // } // // @Override // public double calcArea() { // //Heron's formula // float semi_perimeter = (m_s1+m_s2+m_s3)/2; // float s = semi_perimeter * (semi_perimeter -m_s1) * (semi_perimeter -m_s2) * (semi_perimeter -m_s3); // double area = Math.sqrt(s); // return area; // } // // @Override // public double calcPerimeter() { // return m_s1+m_s2+m_s3; // } // // @Override // public String getName() { // return "Triangle"; // } // // }
import java.util.Scanner; import org.fsmk.mca.example7.shape.IShape; import org.fsmk.mca.example7.shape.Circle; import org.fsmk.mca.example7.shape.Rectangle; import org.fsmk.mca.example7.shape.Square; import org.fsmk.mca.example7.shape.Triangle;
package org.fsmk.mca.example7.client; public class Client { private static Scanner scanner; public static void main(String[] args) { while(true) { // Initialize Scanner to get inputs from the console/STDIN scanner = new Scanner(System.in); System.out.println("Welcome to the program to demonstrate usage of classes from another package."); System.out.println("1. Square"); System.out.println("2. Rectangle"); System.out.println("3. Circle"); System.out.println("4. Triangle"); System.out.println("5. Exit the program!!!"); System.out.println("Please select one of the option given below to choose the shape for which you want to find the area or perimeter."); System.out.println("Your option: "); int shape_choice = scanner.nextInt(); switch(shape_choice) { case 1: { System.out.println("Enter the side of the square:"); int side = scanner.nextInt();
// Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/IShape.java // public interface IShape // { // // public double calcArea(); // // public double calcPerimeter(); // public String getName(); // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Circle.java // public class Circle implements IShape { // // int m_radius; // // public Circle(int radius) // { // m_radius = radius; // } // // @Override // public double calcArea() { // //Area of circle = PI * Square of radius of the circle // return Math.PI*m_radius*m_radius; // } // // @Override // public double calcPerimeter() { // //Perimeter of circle = 2 * PI * radius of the circle // return 2*Math.PI*m_radius; // } // // @Override // public String getName() { // return "Circle"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Rectangle.java // public class Rectangle implements IShape { // // private int m_breadth; // private int m_length; // // public Rectangle(int length, int breadth) // { // m_length = length; // m_breadth = breadth; // // } // // @Override // public double calcArea() { // return m_length*m_breadth; // } // // @Override // public double calcPerimeter() { // return 2*(m_length*m_breadth); // } // // @Override // public String getName() { // return "Rectangle"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Square.java // public class Square implements IShape { // // private int m_side; // // public Square(int side) // { // m_side =side; // } // // @Override // public double calcArea() { // return m_side*m_side; // } // // // @Override // public double calcPerimeter() { // return 4*m_side; // } // // @Override // public String getName() { // return "Square"; // } // // } // // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/shape/Triangle.java // public class Triangle implements IShape { // // int m_s1; // int m_s2; // int m_s3; // // public Triangle(int s1, int s2, int s3) // { // m_s1 = s1; // m_s2 = s2; // m_s3 = s3; // } // // @Override // public double calcArea() { // //Heron's formula // float semi_perimeter = (m_s1+m_s2+m_s3)/2; // float s = semi_perimeter * (semi_perimeter -m_s1) * (semi_perimeter -m_s2) * (semi_perimeter -m_s3); // double area = Math.sqrt(s); // return area; // } // // @Override // public double calcPerimeter() { // return m_s1+m_s2+m_s3; // } // // @Override // public String getName() { // return "Triangle"; // } // // } // Path: Sem3/Java_Prog_Lab/7/org/fsmk/mca/example7/client/Client.java import java.util.Scanner; import org.fsmk.mca.example7.shape.IShape; import org.fsmk.mca.example7.shape.Circle; import org.fsmk.mca.example7.shape.Rectangle; import org.fsmk.mca.example7.shape.Square; import org.fsmk.mca.example7.shape.Triangle; package org.fsmk.mca.example7.client; public class Client { private static Scanner scanner; public static void main(String[] args) { while(true) { // Initialize Scanner to get inputs from the console/STDIN scanner = new Scanner(System.in); System.out.println("Welcome to the program to demonstrate usage of classes from another package."); System.out.println("1. Square"); System.out.println("2. Rectangle"); System.out.println("3. Circle"); System.out.println("4. Triangle"); System.out.println("5. Exit the program!!!"); System.out.println("Please select one of the option given below to choose the shape for which you want to find the area or perimeter."); System.out.println("Your option: "); int shape_choice = scanner.nextInt(); switch(shape_choice) { case 1: { System.out.println("Enter the side of the square:"); int side = scanner.nextInt();
Square square = new Square(side);