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
|
---|---|---|---|---|---|---|
cyberbeat/java-css | com/sun/stylesheet/Animation.java | // Path: com/sun/stylesheet/types/Time.java
// public class Time {
// public enum Unit { MS, S, M }
//
// private static final int MILLISECONDS_PER_SECOND = 1000;
// private static final int SECONDS_PER_MINUTE = 60;
//
// private float millis;
//
// public Time(float value, Unit unit) {
// switch (unit) {
// case MS: millis = value; break;
// case S: millis = value * MILLISECONDS_PER_SECOND; break;
// case M: millis = value * MILLISECONDS_PER_SECOND *
// SECONDS_PER_MINUTE; break;
// default: throw new Error("Can't-happen error: invalid unit " +
// "specified");
// }
// }
//
//
// public float getTime(Unit unit) {
// switch (unit) {
// case MS: return millis;
// case S: return millis / MILLISECONDS_PER_SECOND;
// case M: return millis / MILLISECONDS_PER_SECOND /
// SECONDS_PER_MINUTE;
// default: throw new Error("Can't-happen error: invalid unit " +
// "specified");
// }
// }
//
//
// public void writeBinary(DataOutputStream out) throws IOException {
// out.writeFloat(millis);
// }
//
//
// public static Time readBinary(DataInputStream in) throws IOException {
// return new Time(in.readFloat(), Unit.MS);
// }
//
//
// public String toString() {
// return String.valueOf(millis) + "ms";
// }
// }
| import java.awt.geom.Point2D;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.sun.stylesheet.types.Time; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet;
/**
* Represents animation properties which control how to vary a value over time.
*
*@author Ethan Nicholas
*/
public class Animation {
public enum Interpolation { DEFAULT_CURVE, LINEAR, EASE_IN, EASE_OUT,
EASE_IN_OUT }; | // Path: com/sun/stylesheet/types/Time.java
// public class Time {
// public enum Unit { MS, S, M }
//
// private static final int MILLISECONDS_PER_SECOND = 1000;
// private static final int SECONDS_PER_MINUTE = 60;
//
// private float millis;
//
// public Time(float value, Unit unit) {
// switch (unit) {
// case MS: millis = value; break;
// case S: millis = value * MILLISECONDS_PER_SECOND; break;
// case M: millis = value * MILLISECONDS_PER_SECOND *
// SECONDS_PER_MINUTE; break;
// default: throw new Error("Can't-happen error: invalid unit " +
// "specified");
// }
// }
//
//
// public float getTime(Unit unit) {
// switch (unit) {
// case MS: return millis;
// case S: return millis / MILLISECONDS_PER_SECOND;
// case M: return millis / MILLISECONDS_PER_SECOND /
// SECONDS_PER_MINUTE;
// default: throw new Error("Can't-happen error: invalid unit " +
// "specified");
// }
// }
//
//
// public void writeBinary(DataOutputStream out) throws IOException {
// out.writeFloat(millis);
// }
//
//
// public static Time readBinary(DataInputStream in) throws IOException {
// return new Time(in.readFloat(), Unit.MS);
// }
//
//
// public String toString() {
// return String.valueOf(millis) + "ms";
// }
// }
// Path: com/sun/stylesheet/Animation.java
import java.awt.geom.Point2D;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.sun.stylesheet.types.Time;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet;
/**
* Represents animation properties which control how to vary a value over time.
*
*@author Ethan Nicholas
*/
public class Animation {
public enum Interpolation { DEFAULT_CURVE, LINEAR, EASE_IN, EASE_OUT,
EASE_IN_OUT }; | private Time duration; |
cyberbeat/java-css | com/sun/stylesheet/swing/TextDecorationHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/PropertyHandler.java
// public interface PropertyHandler {
// public Class getPropertyType(Object object) throws StylesheetException;
//
// public Object getProperty(Object object) throws StylesheetException;
//
// public void setProperty(Object object, Object value) throws StylesheetException;
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
| import javax.swing.JComponent;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.PropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the <code>text-decoration</code> synthetic property.
*
*@author Ethan Nicholas
*/
public class TextDecorationHandler implements PropertyHandler {
public enum Decoration { none, underline, linethrough };
private static final StringBuilder TEXT_DECORATION_KEY =
new StringBuilder("$cssTextDecoration");
private static final String UNDERLINE_START = "<html><!-- css --><u>";
private static final String UNDERLINE_END = "</u>";
private static final String LINETHROUGH_START =
"<html><!-- css --><strike>";
private static final String LINETHROUGH_END = "</strike>";
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/PropertyHandler.java
// public interface PropertyHandler {
// public Class getPropertyType(Object object) throws StylesheetException;
//
// public Object getProperty(Object object) throws StylesheetException;
//
// public void setProperty(Object object, Object value) throws StylesheetException;
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
// Path: com/sun/stylesheet/swing/TextDecorationHandler.java
import javax.swing.JComponent;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.PropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the <code>text-decoration</code> synthetic property.
*
*@author Ethan Nicholas
*/
public class TextDecorationHandler implements PropertyHandler {
public enum Decoration { none, underline, linethrough };
private static final StringBuilder TEXT_DECORATION_KEY =
new StringBuilder("$cssTextDecoration");
private static final String UNDERLINE_START = "<html><!-- css --><u>";
private static final String UNDERLINE_END = "</u>";
private static final String LINETHROUGH_START =
"<html><!-- css --><strike>";
private static final String LINETHROUGH_END = "</strike>";
| private StyleSupport styleSupport; |
cyberbeat/java-css | com/sun/stylesheet/swing/TextDecorationHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/PropertyHandler.java
// public interface PropertyHandler {
// public Class getPropertyType(Object object) throws StylesheetException;
//
// public Object getProperty(Object object) throws StylesheetException;
//
// public void setProperty(Object object, Object value) throws StylesheetException;
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
| import javax.swing.JComponent;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.PropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport; |
public TextDecorationHandler(StyleSupport styleSupport) {
this.styleSupport = styleSupport;
}
public Class getPropertyType(Object object) {
return Decoration.class;
}
private String stripText(String text) {
if (text.startsWith(UNDERLINE_START) && text.endsWith(UNDERLINE_END))
text = text.substring(UNDERLINE_START.length(), text.length() -
UNDERLINE_END.length());
if (text.startsWith(LINETHROUGH_START) &&
text.endsWith(LINETHROUGH_END))
text = text.substring(LINETHROUGH_START.length(), text.length() -
LINETHROUGH_END.length());
return text;
}
TextHandler getTextHandler() {
if (textHandler == null)
textHandler = (TextHandler) styleSupport.getPropertyHandler("text");
return textHandler;
}
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/PropertyHandler.java
// public interface PropertyHandler {
// public Class getPropertyType(Object object) throws StylesheetException;
//
// public Object getProperty(Object object) throws StylesheetException;
//
// public void setProperty(Object object, Object value) throws StylesheetException;
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
// Path: com/sun/stylesheet/swing/TextDecorationHandler.java
import javax.swing.JComponent;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.PropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport;
public TextDecorationHandler(StyleSupport styleSupport) {
this.styleSupport = styleSupport;
}
public Class getPropertyType(Object object) {
return Decoration.class;
}
private String stripText(String text) {
if (text.startsWith(UNDERLINE_START) && text.endsWith(UNDERLINE_END))
text = text.substring(UNDERLINE_START.length(), text.length() -
UNDERLINE_END.length());
if (text.startsWith(LINETHROUGH_START) &&
text.endsWith(LINETHROUGH_END))
text = text.substring(LINETHROUGH_START.length(), text.length() -
LINETHROUGH_END.length());
return text;
}
TextHandler getTextHandler() {
if (textHandler == null)
textHandler = (TextHandler) styleSupport.getPropertyHandler("text");
return textHandler;
}
| public Object getProperty(Object object) throws StylesheetException { |
cyberbeat/java-css | com/sun/stylesheet/styleable/DefaultPropertyHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/UnsupportedPropertyException.java
// public class UnsupportedPropertyException extends StylesheetException {
// /** Creates a new <code>UnsupportedPropertyException</code>. */
// public UnsupportedPropertyException() {
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message.
// *
// *@param msg the exception's detail message
// */
// public UnsupportedPropertyException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified cause.
// *
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.UnsupportedPropertyException; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */
package com.sun.stylesheet.styleable;
/**
* Provides get/set support for a JavaBeans property.
*
*@author Ethan Nicholas
*/
public class DefaultPropertyHandler implements PropertyHandler {
protected PropertyDescriptor descriptor;
public DefaultPropertyHandler(PropertyDescriptor descriptor) {
this.descriptor = descriptor;
}
public Class getPropertyType(Object object) {
return descriptor.getPropertyType();
}
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/UnsupportedPropertyException.java
// public class UnsupportedPropertyException extends StylesheetException {
// /** Creates a new <code>UnsupportedPropertyException</code>. */
// public UnsupportedPropertyException() {
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message.
// *
// *@param msg the exception's detail message
// */
// public UnsupportedPropertyException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified cause.
// *
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.UnsupportedPropertyException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */
package com.sun.stylesheet.styleable;
/**
* Provides get/set support for a JavaBeans property.
*
*@author Ethan Nicholas
*/
public class DefaultPropertyHandler implements PropertyHandler {
protected PropertyDescriptor descriptor;
public DefaultPropertyHandler(PropertyDescriptor descriptor) {
this.descriptor = descriptor;
}
public Class getPropertyType(Object object) {
return descriptor.getPropertyType();
}
| public Object getProperty(Object object) throws StylesheetException { |
cyberbeat/java-css | com/sun/stylesheet/styleable/DefaultPropertyHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/UnsupportedPropertyException.java
// public class UnsupportedPropertyException extends StylesheetException {
// /** Creates a new <code>UnsupportedPropertyException</code>. */
// public UnsupportedPropertyException() {
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message.
// *
// *@param msg the exception's detail message
// */
// public UnsupportedPropertyException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified cause.
// *
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.UnsupportedPropertyException; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */
package com.sun.stylesheet.styleable;
/**
* Provides get/set support for a JavaBeans property.
*
*@author Ethan Nicholas
*/
public class DefaultPropertyHandler implements PropertyHandler {
protected PropertyDescriptor descriptor;
public DefaultPropertyHandler(PropertyDescriptor descriptor) {
this.descriptor = descriptor;
}
public Class getPropertyType(Object object) {
return descriptor.getPropertyType();
}
public Object getProperty(Object object) throws StylesheetException {
if (descriptor.getReadMethod() != null) {
try {
return descriptor.getReadMethod().invoke(object);
}
catch (Exception e) {
throw new StylesheetException(e);
}
}
else | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/UnsupportedPropertyException.java
// public class UnsupportedPropertyException extends StylesheetException {
// /** Creates a new <code>UnsupportedPropertyException</code>. */
// public UnsupportedPropertyException() {
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message.
// *
// *@param msg the exception's detail message
// */
// public UnsupportedPropertyException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified cause.
// *
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>UnsupportedPropertyException</code> with the
// * specified detail message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public UnsupportedPropertyException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.UnsupportedPropertyException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */
package com.sun.stylesheet.styleable;
/**
* Provides get/set support for a JavaBeans property.
*
*@author Ethan Nicholas
*/
public class DefaultPropertyHandler implements PropertyHandler {
protected PropertyDescriptor descriptor;
public DefaultPropertyHandler(PropertyDescriptor descriptor) {
this.descriptor = descriptor;
}
public Class getPropertyType(Object object) {
return descriptor.getPropertyType();
}
public Object getProperty(Object object) throws StylesheetException {
if (descriptor.getReadMethod() != null) {
try {
return descriptor.getReadMethod().invoke(object);
}
catch (Exception e) {
throw new StylesheetException(e);
}
}
else | throw new UnsupportedPropertyException("property " + |
cyberbeat/java-css | com/sun/stylesheet/types/AbstractColorConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.util.Arrays;
import com.sun.stylesheet.StylesheetException;
| /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Abstract base class for converting strings into colors. Because this CSS
* engine must support two completely different color classes (AWT colors and
* JavaFX colors), this base class handles the basic conversion of color strings
* into red, green, blue, and alpha components without dictating any particular
* final output class.
* <p>
* Supported strings are those defined by CSS3 (e.g. "#00ff00" or "rgb(0%, 100%,
* 0%)" with two minor additions. The string "null" converts to a null
* reference, and an eight-digit hex format (e.g. "#00ff007f") is supported with
* the final two digits controlling alpha.
* <p>
* Concrete subclasses are responsible for taking the computed color channel
* values and storing them in the final output object, such as
* <code>java.awt.Color</code.
*
*@author Ethan Nicholas
*/
public abstract class AbstractColorConverter implements TypeConverter {
public Object convertFromString(String string) {
if (string.equals("null"))
return null;
else if (string.length() == 7 && string.charAt(0) == '#') {
int r = Integer.parseInt(string.substring(1, 3), 16);
int g = Integer.parseInt(string.substring(3, 5), 16);
int b = Integer.parseInt(string.substring(5), 16);
return createColor(r, g, b);
}
else if (string.length() == 9 && string.charAt(0) == '#') {
int r = Integer.parseInt(string.substring(1, 3), 16);
int g = Integer.parseInt(string.substring(3, 5), 16);
int b = Integer.parseInt(string.substring(5, 7), 16);
int a = Integer.parseInt(string.substring(7), 16);
return createColor(r, g, b, a);
}
else if (string.equals("transparent"))
return convertFromString("#00000000");
else if (string.startsWith("rgb(") && string.endsWith(")")) {
String[] args = TypeManager.parseArgs(
string.substring("rgb(".length(), string.length() - 1));
if (args.length != 3)
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/AbstractColorConverter.java
import java.util.Arrays;
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Abstract base class for converting strings into colors. Because this CSS
* engine must support two completely different color classes (AWT colors and
* JavaFX colors), this base class handles the basic conversion of color strings
* into red, green, blue, and alpha components without dictating any particular
* final output class.
* <p>
* Supported strings are those defined by CSS3 (e.g. "#00ff00" or "rgb(0%, 100%,
* 0%)" with two minor additions. The string "null" converts to a null
* reference, and an eight-digit hex format (e.g. "#00ff007f") is supported with
* the final two digits controlling alpha.
* <p>
* Concrete subclasses are responsible for taking the computed color channel
* values and storing them in the final output object, such as
* <code>java.awt.Color</code.
*
*@author Ethan Nicholas
*/
public abstract class AbstractColorConverter implements TypeConverter {
public Object convertFromString(String string) {
if (string.equals("null"))
return null;
else if (string.length() == 7 && string.charAt(0) == '#') {
int r = Integer.parseInt(string.substring(1, 3), 16);
int g = Integer.parseInt(string.substring(3, 5), 16);
int b = Integer.parseInt(string.substring(5), 16);
return createColor(r, g, b);
}
else if (string.length() == 9 && string.charAt(0) == '#') {
int r = Integer.parseInt(string.substring(1, 3), 16);
int g = Integer.parseInt(string.substring(3, 5), 16);
int b = Integer.parseInt(string.substring(5, 7), 16);
int a = Integer.parseInt(string.substring(7), 16);
return createColor(r, g, b, a);
}
else if (string.equals("transparent"))
return convertFromString("#00000000");
else if (string.startsWith("rgb(") && string.endsWith(")")) {
String[] args = TypeManager.parseArgs(
string.substring("rgb(".length(), string.length() - 1));
if (args.length != 3)
| throw new StylesheetException("rgb() takes 3 arguments, " +
|
MooSell/Android | app/src/main/java/com/designwall/moosell/model/Order/OrderRefunds.java | // Path: app/src/main/java/com/designwall/moosell/model/Order/subclass/LineItem.java
// public class LineItem {
// private int id;
// private String subtotal;
// private String subtotal_tax;
// private String total;
// private String total_tax;
// private String price;
// private int quantity;
// private String tax_class;
// private String name;
// private int product_id;
// private String sku;
// private List<MetaItem> meta;
// private String variations;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSubtotal() {
// return subtotal;
// }
//
// public void setSubtotal(String subtotal) {
// this.subtotal = subtotal;
// }
//
// public String getSubtotal_tax() {
// return subtotal_tax;
// }
//
// public void setSubtotal_tax(String subtotal_tax) {
// this.subtotal_tax = subtotal_tax;
// }
//
// public String getTotal() {
// return total;
// }
//
// public void setTotal(String total) {
// this.total = total;
// }
//
// public String getTotal_tax() {
// return total_tax;
// }
//
// public void setTotal_tax(String total_tax) {
// this.total_tax = total_tax;
// }
//
// public String getPrice() {
// return price;
// }
//
// public void setPrice(String price) {
// this.price = price;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public String getTax_class() {
// return tax_class;
// }
//
// public void setTax_class(String tax_class) {
// this.tax_class = tax_class;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getProduct_id() {
// return product_id;
// }
//
// public void setProduct_id(int product_id) {
// this.product_id = product_id;
// }
//
// public String getSku() {
// return sku;
// }
//
// public void setSku(String sku) {
// this.sku = sku;
// }
//
// public List<MetaItem> getMeta() {
// return meta;
// }
//
// public void setMeta(List<MetaItem> meta) {
// this.meta = meta;
// }
//
// public String getVariations() {
// return variations;
// }
//
// public void setVariations(String variations) {
// this.variations = variations;
// }
// }
| import com.designwall.moosell.model.Order.subclass.LineItem;
import java.util.List;
| package com.designwall.moosell.model.Order;
/**
* Created by SCIT on 3/10/2017.
*/
public class OrderRefunds {
private int id;
private String created_at;
private String amount;
private String reason;
| // Path: app/src/main/java/com/designwall/moosell/model/Order/subclass/LineItem.java
// public class LineItem {
// private int id;
// private String subtotal;
// private String subtotal_tax;
// private String total;
// private String total_tax;
// private String price;
// private int quantity;
// private String tax_class;
// private String name;
// private int product_id;
// private String sku;
// private List<MetaItem> meta;
// private String variations;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getSubtotal() {
// return subtotal;
// }
//
// public void setSubtotal(String subtotal) {
// this.subtotal = subtotal;
// }
//
// public String getSubtotal_tax() {
// return subtotal_tax;
// }
//
// public void setSubtotal_tax(String subtotal_tax) {
// this.subtotal_tax = subtotal_tax;
// }
//
// public String getTotal() {
// return total;
// }
//
// public void setTotal(String total) {
// this.total = total;
// }
//
// public String getTotal_tax() {
// return total_tax;
// }
//
// public void setTotal_tax(String total_tax) {
// this.total_tax = total_tax;
// }
//
// public String getPrice() {
// return price;
// }
//
// public void setPrice(String price) {
// this.price = price;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public String getTax_class() {
// return tax_class;
// }
//
// public void setTax_class(String tax_class) {
// this.tax_class = tax_class;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getProduct_id() {
// return product_id;
// }
//
// public void setProduct_id(int product_id) {
// this.product_id = product_id;
// }
//
// public String getSku() {
// return sku;
// }
//
// public void setSku(String sku) {
// this.sku = sku;
// }
//
// public List<MetaItem> getMeta() {
// return meta;
// }
//
// public void setMeta(List<MetaItem> meta) {
// this.meta = meta;
// }
//
// public String getVariations() {
// return variations;
// }
//
// public void setVariations(String variations) {
// this.variations = variations;
// }
// }
// Path: app/src/main/java/com/designwall/moosell/model/Order/OrderRefunds.java
import com.designwall.moosell.model.Order.subclass.LineItem;
import java.util.List;
package com.designwall.moosell.model.Order;
/**
* Created by SCIT on 3/10/2017.
*/
public class OrderRefunds {
private int id;
private String created_at;
private String amount;
private String reason;
| private List<LineItem> line_items;
|
MooSell/Android | app/src/main/java/com/designwall/moosell/model/Customer/Customer.java | // Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/BillingAddress.java
// public class BillingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
// private String email;
// private String phone;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/ShippingAddress.java
// public class ShippingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
// }
| import com.designwall.moosell.model.Customer.subclass.BillingAddress;
import com.designwall.moosell.model.Customer.subclass.ShippingAddress;
import java.util.List;
| package com.designwall.moosell.model.Customer;
/**
* Created by SCIT on 3/10/2017.
*/
public class Customer {
private int id;
private String created_at;
private String email;
private String first_name;
private String last_name;
private String username;
private String password;
private int last_order_id;
private String last_order_date;
private int orders_count;
private int total_spent;
private String avatar_url;
| // Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/BillingAddress.java
// public class BillingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
// private String email;
// private String phone;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/ShippingAddress.java
// public class ShippingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
// }
// Path: app/src/main/java/com/designwall/moosell/model/Customer/Customer.java
import com.designwall.moosell.model.Customer.subclass.BillingAddress;
import com.designwall.moosell.model.Customer.subclass.ShippingAddress;
import java.util.List;
package com.designwall.moosell.model.Customer;
/**
* Created by SCIT on 3/10/2017.
*/
public class Customer {
private int id;
private String created_at;
private String email;
private String first_name;
private String last_name;
private String username;
private String password;
private int last_order_id;
private String last_order_date;
private int orders_count;
private int total_spent;
private String avatar_url;
| private List<BillingAddress> billing_address;
|
MooSell/Android | app/src/main/java/com/designwall/moosell/model/Customer/Customer.java | // Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/BillingAddress.java
// public class BillingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
// private String email;
// private String phone;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/ShippingAddress.java
// public class ShippingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
// }
| import com.designwall.moosell.model.Customer.subclass.BillingAddress;
import com.designwall.moosell.model.Customer.subclass.ShippingAddress;
import java.util.List;
| package com.designwall.moosell.model.Customer;
/**
* Created by SCIT on 3/10/2017.
*/
public class Customer {
private int id;
private String created_at;
private String email;
private String first_name;
private String last_name;
private String username;
private String password;
private int last_order_id;
private String last_order_date;
private int orders_count;
private int total_spent;
private String avatar_url;
private List<BillingAddress> billing_address;
| // Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/BillingAddress.java
// public class BillingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
// private String email;
// private String phone;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
//
// public String getEmail() {
// return email;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public void setPhone(String phone) {
// this.phone = phone;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/model/Customer/subclass/ShippingAddress.java
// public class ShippingAddress {
// private String first_name;
// private String last_name;
// private String company;
// private String address_1;
// private String address_2;
// private String city;
// private String state;
// private String postcode;
// private String country;
//
// public String getFirst_name() {
// return first_name;
// }
//
// public void setFirst_name(String first_name) {
// this.first_name = first_name;
// }
//
// public String getLast_name() {
// return last_name;
// }
//
// public void setLast_name(String last_name) {
// this.last_name = last_name;
// }
//
// public String getCompany() {
// return company;
// }
//
// public void setCompany(String company) {
// this.company = company;
// }
//
// public String getAddress_1() {
// return address_1;
// }
//
// public void setAddress_1(String address_1) {
// this.address_1 = address_1;
// }
//
// public String getAddress_2() {
// return address_2;
// }
//
// public void setAddress_2(String address_2) {
// this.address_2 = address_2;
// }
//
// public String getCity() {
// return city;
// }
//
// public void setCity(String city) {
// this.city = city;
// }
//
// public String getState() {
// return state;
// }
//
// public void setState(String state) {
// this.state = state;
// }
//
// public String getPostcode() {
// return postcode;
// }
//
// public void setPostcode(String postcode) {
// this.postcode = postcode;
// }
//
// public String getCountry() {
// return country;
// }
//
// public void setCountry(String country) {
// this.country = country;
// }
// }
// Path: app/src/main/java/com/designwall/moosell/model/Customer/Customer.java
import com.designwall.moosell.model.Customer.subclass.BillingAddress;
import com.designwall.moosell.model.Customer.subclass.ShippingAddress;
import java.util.List;
package com.designwall.moosell.model.Customer;
/**
* Created by SCIT on 3/10/2017.
*/
public class Customer {
private int id;
private String created_at;
private String email;
private String first_name;
private String last_name;
private String username;
private String password;
private int last_order_id;
private String last_order_date;
private int orders_count;
private int total_spent;
private String avatar_url;
private List<BillingAddress> billing_address;
| private List<ShippingAddress> shipping_address;
|
MooSell/Android | app/src/main/java/com/designwall/moosell/task/GetDataTask.java | // Path: app/src/main/java/com/designwall/moosell/config/Constant.java
// public static final String BASIC_AUTH = "Basic " + Base64.encodeToString((CONSUMER_KEY + ":" + CONSUMER_SECRET).getBytes(), Base64.NO_WRAP);
| import android.os.AsyncTask;
import android.util.Log;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import static com.designwall.moosell.config.Constant.BASIC_AUTH;
| private OkHttpClient mClient;
private String mMethod;
private String mRequestBody;
public GetDataTask(String method) {
mMethod = method;
}
public GetDataTask(String method, String requestBody) {
mMethod = method;
mRequestBody = requestBody;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
mClient = new OkHttpClient.Builder()
.connectTimeout(40, TimeUnit.SECONDS)
.writeTimeout(40, TimeUnit.SECONDS)
.writeTimeout(40, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
}
@Override
protected String[] doInBackground(String... urls) {
String[] result = new String[urls.length];
for (int i = 0; i < urls.length; i++) {
Request request;
//TODO: Remove this log
| // Path: app/src/main/java/com/designwall/moosell/config/Constant.java
// public static final String BASIC_AUTH = "Basic " + Base64.encodeToString((CONSUMER_KEY + ":" + CONSUMER_SECRET).getBytes(), Base64.NO_WRAP);
// Path: app/src/main/java/com/designwall/moosell/task/GetDataTask.java
import android.os.AsyncTask;
import android.util.Log;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import static com.designwall.moosell.config.Constant.BASIC_AUTH;
private OkHttpClient mClient;
private String mMethod;
private String mRequestBody;
public GetDataTask(String method) {
mMethod = method;
}
public GetDataTask(String method, String requestBody) {
mMethod = method;
mRequestBody = requestBody;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
mClient = new OkHttpClient.Builder()
.connectTimeout(40, TimeUnit.SECONDS)
.writeTimeout(40, TimeUnit.SECONDS)
.writeTimeout(40, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
}
@Override
protected String[] doInBackground(String... urls) {
String[] result = new String[urls.length];
for (int i = 0; i < urls.length; i++) {
Request request;
//TODO: Remove this log
| Log.v("Test", BASIC_AUTH);
|
MooSell/Android | app/src/main/java/com/designwall/moosell/adapter/ListCategoryAdapter.java | // Path: app/src/main/java/com/designwall/moosell/model/Product/ProductCategory.java
// public class ProductCategory {
// private int id;
// private String name;
// private String slug;
// private int parent;
// private String description;
// private String display; //Available: default, products, subcategories and both
// private String image;
// private int count;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public int getParent() {
// return parent;
// }
//
// public void setParent(int parent) {
// this.parent = parent;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/util/RecyclerViewItemClicked.java
// public interface RecyclerViewItemClicked {
// void onRecyclerViewItemClicked(int position, View v);
// }
| import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.designwall.moosell.model.Product.ProductCategory;
import com.designwall.moosell.R;
import com.designwall.moosell.util.RecyclerViewItemClicked;
import java.util.List;
| package com.designwall.moosell.adapter;
/**
* Created by SCIT on 3/9/2017.
*/
public class ListCategoryAdapter extends RecyclerView.Adapter<ListCategoryAdapter.ViewHolder> {
private Activity mActivity;
| // Path: app/src/main/java/com/designwall/moosell/model/Product/ProductCategory.java
// public class ProductCategory {
// private int id;
// private String name;
// private String slug;
// private int parent;
// private String description;
// private String display; //Available: default, products, subcategories and both
// private String image;
// private int count;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public int getParent() {
// return parent;
// }
//
// public void setParent(int parent) {
// this.parent = parent;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/util/RecyclerViewItemClicked.java
// public interface RecyclerViewItemClicked {
// void onRecyclerViewItemClicked(int position, View v);
// }
// Path: app/src/main/java/com/designwall/moosell/adapter/ListCategoryAdapter.java
import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.designwall.moosell.model.Product.ProductCategory;
import com.designwall.moosell.R;
import com.designwall.moosell.util.RecyclerViewItemClicked;
import java.util.List;
package com.designwall.moosell.adapter;
/**
* Created by SCIT on 3/9/2017.
*/
public class ListCategoryAdapter extends RecyclerView.Adapter<ListCategoryAdapter.ViewHolder> {
private Activity mActivity;
| private List<ProductCategory> mCategories;
|
MooSell/Android | app/src/main/java/com/designwall/moosell/adapter/ListCategoryAdapter.java | // Path: app/src/main/java/com/designwall/moosell/model/Product/ProductCategory.java
// public class ProductCategory {
// private int id;
// private String name;
// private String slug;
// private int parent;
// private String description;
// private String display; //Available: default, products, subcategories and both
// private String image;
// private int count;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public int getParent() {
// return parent;
// }
//
// public void setParent(int parent) {
// this.parent = parent;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/util/RecyclerViewItemClicked.java
// public interface RecyclerViewItemClicked {
// void onRecyclerViewItemClicked(int position, View v);
// }
| import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.designwall.moosell.model.Product.ProductCategory;
import com.designwall.moosell.R;
import com.designwall.moosell.util.RecyclerViewItemClicked;
import java.util.List;
| package com.designwall.moosell.adapter;
/**
* Created by SCIT on 3/9/2017.
*/
public class ListCategoryAdapter extends RecyclerView.Adapter<ListCategoryAdapter.ViewHolder> {
private Activity mActivity;
private List<ProductCategory> mCategories;
| // Path: app/src/main/java/com/designwall/moosell/model/Product/ProductCategory.java
// public class ProductCategory {
// private int id;
// private String name;
// private String slug;
// private int parent;
// private String description;
// private String display; //Available: default, products, subcategories and both
// private String image;
// private int count;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getSlug() {
// return slug;
// }
//
// public void setSlug(String slug) {
// this.slug = slug;
// }
//
// public int getParent() {
// return parent;
// }
//
// public void setParent(int parent) {
// this.parent = parent;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public String getImage() {
// return image;
// }
//
// public void setImage(String image) {
// this.image = image;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
// }
//
// Path: app/src/main/java/com/designwall/moosell/util/RecyclerViewItemClicked.java
// public interface RecyclerViewItemClicked {
// void onRecyclerViewItemClicked(int position, View v);
// }
// Path: app/src/main/java/com/designwall/moosell/adapter/ListCategoryAdapter.java
import android.app.Activity;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.designwall.moosell.model.Product.ProductCategory;
import com.designwall.moosell.R;
import com.designwall.moosell.util.RecyclerViewItemClicked;
import java.util.List;
package com.designwall.moosell.adapter;
/**
* Created by SCIT on 3/9/2017.
*/
public class ListCategoryAdapter extends RecyclerView.Adapter<ListCategoryAdapter.ViewHolder> {
private Activity mActivity;
private List<ProductCategory> mCategories;
| private RecyclerViewItemClicked mClickListener;
|
mojohaus/build-helper-maven-plugin | src/main/java/org/codehaus/mojo/buildhelper/ParseVersionMojo.java | // Path: src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java
// public class DefaultVersioning
// implements Versioning
// {
//
// private VersionInformation vi;
//
// private String version;
//
// public DefaultVersioning( String version )
// {
// this.version = version;
// this.vi = new VersionInformation( version );
//
// }
//
// public String getVersion()
// {
// return this.version;
// }
//
// @Override
// public int getMajor()
// {
// return this.vi.getMajor();
// }
//
// @Override
// public int getMinor()
// {
// return this.vi.getMinor();
// }
//
// @Override
// public int getPatch()
// {
// return this.vi.getPatch();
// }
//
// @Override
// public String getAsOSGiVersion()
// {
// StringBuffer osgiVersion = new StringBuffer();
// osgiVersion.append( this.getMajor() );
// osgiVersion.append( "." + this.getMinor() );
// osgiVersion.append( "." + this.getPatch() );
//
// if ( this.getQualifier() != null || this.getBuildNumber() != 0 )
// {
// osgiVersion.append( "." );
//
// if ( this.getBuildNumber() != 0 )
// {
// osgiVersion.append( this.getBuildNumber() );
// }
// if ( this.getQualifier() != null )
// {
// // Do not allow having "." in it cause it's not allowed in OSGi.
// String qualifier = this.getQualifier().replaceAll( "\\.", "_" );
// osgiVersion.append( qualifier );
// }
// }
//
// return osgiVersion.toString();
// }
//
// @Override
// public long getBuildNumber()
// {
// return this.vi.getBuildNumber();
// }
//
// @Override
// public String getQualifier()
// {
// return this.vi.getQualifier();
// }
//
// }
| import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.mojo.buildhelper.versioning.DefaultVersioning; | parseVersion( versionString );
}
private void defineVersionProperty( String name, String value )
{
defineProperty( propertyPrefix + '.' + name, value );
}
private void defineFormattedVersionProperty( String name, String value )
{
defineProperty( formattedPropertyPrefix + '.' + name, value );
}
private void defineVersionProperty( String name, int value )
{
defineVersionProperty( name, Integer.toString( value ) );
}
private void defineVersionProperty( String name, long value )
{
defineVersionProperty( name, Long.toString( value ) );
}
/**
* Parse a version String and add the components to a properties object.
*
* @param version the version to parse
*/
public void parseVersion( String version )
{ | // Path: src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java
// public class DefaultVersioning
// implements Versioning
// {
//
// private VersionInformation vi;
//
// private String version;
//
// public DefaultVersioning( String version )
// {
// this.version = version;
// this.vi = new VersionInformation( version );
//
// }
//
// public String getVersion()
// {
// return this.version;
// }
//
// @Override
// public int getMajor()
// {
// return this.vi.getMajor();
// }
//
// @Override
// public int getMinor()
// {
// return this.vi.getMinor();
// }
//
// @Override
// public int getPatch()
// {
// return this.vi.getPatch();
// }
//
// @Override
// public String getAsOSGiVersion()
// {
// StringBuffer osgiVersion = new StringBuffer();
// osgiVersion.append( this.getMajor() );
// osgiVersion.append( "." + this.getMinor() );
// osgiVersion.append( "." + this.getPatch() );
//
// if ( this.getQualifier() != null || this.getBuildNumber() != 0 )
// {
// osgiVersion.append( "." );
//
// if ( this.getBuildNumber() != 0 )
// {
// osgiVersion.append( this.getBuildNumber() );
// }
// if ( this.getQualifier() != null )
// {
// // Do not allow having "." in it cause it's not allowed in OSGi.
// String qualifier = this.getQualifier().replaceAll( "\\.", "_" );
// osgiVersion.append( qualifier );
// }
// }
//
// return osgiVersion.toString();
// }
//
// @Override
// public long getBuildNumber()
// {
// return this.vi.getBuildNumber();
// }
//
// @Override
// public String getQualifier()
// {
// return this.vi.getQualifier();
// }
//
// }
// Path: src/main/java/org/codehaus/mojo/buildhelper/ParseVersionMojo.java
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.mojo.buildhelper.versioning.DefaultVersioning;
parseVersion( versionString );
}
private void defineVersionProperty( String name, String value )
{
defineProperty( propertyPrefix + '.' + name, value );
}
private void defineFormattedVersionProperty( String name, String value )
{
defineProperty( formattedPropertyPrefix + '.' + name, value );
}
private void defineVersionProperty( String name, int value )
{
defineVersionProperty( name, Integer.toString( value ) );
}
private void defineVersionProperty( String name, long value )
{
defineVersionProperty( name, Long.toString( value ) );
}
/**
* Parse a version String and add the components to a properties object.
*
* @param version the version to parse
*/
public void parseVersion( String version )
{ | DefaultVersioning artifactVersion = new DefaultVersioning( version ); |
mozvip/sports-predictions | predictor/src/main/java/predictions/resources/CommunityResource.java | // Path: predictor/src/main/java/predictions/model/db/AccessType.java
// public enum AccessType {
//
// R, W, N
//
// }
//
// Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
//
// Path: predictor/src/main/java/predictions/model/db/User.java
// public class User implements Principal {
//
// @NotNull
// private String community;
//
// @NotNull
// private String name;
//
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// private String changePasswordToken;
//
// private DateTime lastLoginDate;
//
// @Min(value = 0)
// private int currentScore = 0;
//
// @Min(value = 1)
// private int currentRanking = 1;
//
// @Min(value = 1)
// private int previousRanking = 1;
//
// private boolean admin = false;
//
// private boolean active = true;
//
// private boolean late = false;
//
// public User() {
// }
//
// public User(String community, String name, String email, String password, String changePasswordToken,
// DateTime lastLoginDate, int currentScore, int currentRanking, int previousRanking, boolean admin, boolean active, boolean late) {
// super();
// this.community = community;
// this.name = name;
// this.email = email;
// this.password = password;
// this.changePasswordToken = changePasswordToken;
// this.lastLoginDate = lastLoginDate;
// this.currentScore = currentScore;
// this.currentRanking = currentRanking;
// this.previousRanking = previousRanking;
// this.admin = admin;
// this.active = active;
// this.late = late;
// }
//
// @JsonProperty
// public String getCommunity() {
// return community;
// }
//
// @JsonProperty
// public String getEmail() {
// return email.toLowerCase();
// }
//
// @JsonProperty
// public String getName() {
// return name;
// }
//
// @JsonProperty
// public int getCurrentScore() {
// return currentScore;
// }
//
// @JsonProperty
// public boolean isAdmin() {
// return admin;
// }
//
// @JsonProperty
// public boolean isLate() {
// return late;
// }
//
// @JsonProperty
// @JsonFormat(locale = "fr", shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+2")
// public DateTime getLastLoginDate() {
// return lastLoginDate;
// }
//
// @JsonProperty
// public boolean isActive() {
// return active;
// }
//
// @JsonProperty
// public int getCurrentRanking() {
// return currentRanking;
// }
//
// public int getPreviousRanking() {
// return previousRanking;
// }
//
// public String getChangePasswordToken() {
// return changePasswordToken;
// }
// }
| import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import io.dropwizard.auth.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import predictions.model.db.AccessType;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO;
import predictions.model.db.User; | package predictions.resources;
@Path("/community")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Api
public class CommunityResource {
@Context private HttpServletRequest httpRequest;
| // Path: predictor/src/main/java/predictions/model/db/AccessType.java
// public enum AccessType {
//
// R, W, N
//
// }
//
// Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
//
// Path: predictor/src/main/java/predictions/model/db/User.java
// public class User implements Principal {
//
// @NotNull
// private String community;
//
// @NotNull
// private String name;
//
// @NotNull
// private String email;
//
// @NotNull
// private String password;
//
// private String changePasswordToken;
//
// private DateTime lastLoginDate;
//
// @Min(value = 0)
// private int currentScore = 0;
//
// @Min(value = 1)
// private int currentRanking = 1;
//
// @Min(value = 1)
// private int previousRanking = 1;
//
// private boolean admin = false;
//
// private boolean active = true;
//
// private boolean late = false;
//
// public User() {
// }
//
// public User(String community, String name, String email, String password, String changePasswordToken,
// DateTime lastLoginDate, int currentScore, int currentRanking, int previousRanking, boolean admin, boolean active, boolean late) {
// super();
// this.community = community;
// this.name = name;
// this.email = email;
// this.password = password;
// this.changePasswordToken = changePasswordToken;
// this.lastLoginDate = lastLoginDate;
// this.currentScore = currentScore;
// this.currentRanking = currentRanking;
// this.previousRanking = previousRanking;
// this.admin = admin;
// this.active = active;
// this.late = late;
// }
//
// @JsonProperty
// public String getCommunity() {
// return community;
// }
//
// @JsonProperty
// public String getEmail() {
// return email.toLowerCase();
// }
//
// @JsonProperty
// public String getName() {
// return name;
// }
//
// @JsonProperty
// public int getCurrentScore() {
// return currentScore;
// }
//
// @JsonProperty
// public boolean isAdmin() {
// return admin;
// }
//
// @JsonProperty
// public boolean isLate() {
// return late;
// }
//
// @JsonProperty
// @JsonFormat(locale = "fr", shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+2")
// public DateTime getLastLoginDate() {
// return lastLoginDate;
// }
//
// @JsonProperty
// public boolean isActive() {
// return active;
// }
//
// @JsonProperty
// public int getCurrentRanking() {
// return currentRanking;
// }
//
// public int getPreviousRanking() {
// return previousRanking;
// }
//
// public String getChangePasswordToken() {
// return changePasswordToken;
// }
// }
// Path: predictor/src/main/java/predictions/resources/CommunityResource.java
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import io.dropwizard.auth.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import predictions.model.db.AccessType;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO;
import predictions.model.db.User;
package predictions.resources;
@Path("/community")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Api
public class CommunityResource {
@Context private HttpServletRequest httpRequest;
| private CommunityDAO communityDAO; |
mozvip/sports-predictions | football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*; | package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException { | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*;
package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException { | Competition competition = client.competition(467); |
mozvip/sports-predictions | football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*; | package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException {
Competition competition = client.competition(467);
assertEquals("World Cup 2018 Russia", competition.getCaption());
}
@org.junit.Test
public void competition424() throws IOException {
Competition competition = client.competition(424);
assertEquals("European Championships France 2016", competition.getCaption());
assertEquals(51, competition.getNumberOfGames());
| // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*;
package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException {
Competition competition = client.competition(467);
assertEquals("World Cup 2018 Russia", competition.getCaption());
}
@org.junit.Test
public void competition424() throws IOException {
Competition competition = client.competition(424);
assertEquals("European Championships France 2016", competition.getCaption());
assertEquals(51, competition.getNumberOfGames());
| Fixtures fixtures = client.fixtures(competition.getId()); |
mozvip/sports-predictions | football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*; | package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException {
Competition competition = client.competition(467);
assertEquals("World Cup 2018 Russia", competition.getCaption());
}
@org.junit.Test
public void competition424() throws IOException {
Competition competition = client.competition(424);
assertEquals("European Championships France 2016", competition.getCaption());
assertEquals(51, competition.getNumberOfGames());
Fixtures fixtures = client.fixtures(competition.getId());
assertNotNull(fixtures);
}
@org.junit.Test
public void teams() throws IOException { | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/test/java/com/github/mozvip/footballdata/FootballDataClientTest.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import org.junit.Before;
import retrofit2.Call;
import java.io.IOException;
import static org.junit.Assert.*;
package com.github.mozvip.footballdata;
public class FootballDataClientTest {
FootballDataClient client;
@Before
public void setUp() {
client = FootballDataClient.Builder("24d157912c1742a48feff025e0172b38").build();
}
@org.junit.Test
public void competition() throws IOException {
Competition competition = client.competition(467);
assertEquals("World Cup 2018 Russia", competition.getCaption());
}
@org.junit.Test
public void competition424() throws IOException {
Competition competition = client.competition(424);
assertEquals("European Championships France 2016", competition.getCaption());
assertEquals(51, competition.getNumberOfGames());
Fixtures fixtures = client.fixtures(competition.getId());
assertNotNull(fixtures);
}
@org.junit.Test
public void teams() throws IOException { | Teams teams = client.teams(467); |
mozvip/sports-predictions | predictor/src/main/java/predictions/model/MatchPredictions.java | // Path: predictor/src/main/java/predictions/model/db/MatchPrediction.java
// public class MatchPrediction {
//
// @JsonProperty
// private String community;
// @JsonProperty
// private String email;
// @JsonProperty
// private int match_id;
// @JsonProperty
// private int away_score;
// @JsonProperty
// private String away_team_name;
// @JsonProperty
// private int home_score;
// @JsonProperty
// private String home_team_name;
// @JsonProperty
// private boolean home_winner;
// @JsonProperty
// private int score = 0;
// @JsonProperty
// private boolean perfect = false;
//
// public MatchPrediction() {
// }
//
// public MatchPrediction(String community, String email, int match_id, int away_score, String away_team_name,
// int home_score, String home_team_name, boolean home_winner, int score) {
// super();
// this.community = community;
// this.email = email;
// this.match_id = match_id;
// this.away_score = away_score;
// this.away_team_name = away_team_name;
// this.home_score = home_score;
// this.home_team_name = home_team_name;
// this.home_winner = home_winner;
// this.score = score;
// }
//
// public boolean isHome_winner() {
// return home_winner;
// }
//
// public void setHome_winner(boolean home_winner) {
// this.home_winner = home_winner;
// }
//
// public String getCommunity() {
// return community;
// }
//
// public void setCommunity(String community) {
// this.community = community;
// }
//
// public String getEmail() {
// return email != null ? email.toLowerCase() : null;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public int getMatch_id() {
// return match_id;
// }
//
// public void setMatch_id(int match_id) {
// this.match_id = match_id;
// }
//
// public int getAway_score() {
// return away_score;
// }
//
// public void setAway_score(int away_score) {
// this.away_score = away_score;
// }
//
// public String getAway_team_name() {
// return away_team_name;
// }
//
// public void setAway_team_name(String away_team_name) {
// this.away_team_name = away_team_name;
// }
//
// public int getHome_score() {
// return home_score;
// }
//
// public void setHome_score(int home_score) {
// this.home_score = home_score;
// }
//
// public String getHome_team_name() {
// return home_team_name;
// }
//
// public void setHome_team_name(String home_team_name) {
// this.home_team_name = home_team_name;
// }
//
// public int getScore() {
// return score;
// }
//
// public boolean isPerfect() {
// return perfect;
// }
//
// public void setPerfect(boolean perfect) {
// this.perfect = perfect;
// }
// }
| import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import predictions.model.db.MatchPrediction; | package predictions.model;
public class MatchPredictions {
@JsonProperty
private String email;
@JsonProperty
private String community;
@JsonProperty
private String name;
@JsonProperty
private boolean admin;
@JsonProperty
private boolean late;
@JsonProperty
private int currentRanking;
@JsonProperty
private String authToken;
@JsonProperty | // Path: predictor/src/main/java/predictions/model/db/MatchPrediction.java
// public class MatchPrediction {
//
// @JsonProperty
// private String community;
// @JsonProperty
// private String email;
// @JsonProperty
// private int match_id;
// @JsonProperty
// private int away_score;
// @JsonProperty
// private String away_team_name;
// @JsonProperty
// private int home_score;
// @JsonProperty
// private String home_team_name;
// @JsonProperty
// private boolean home_winner;
// @JsonProperty
// private int score = 0;
// @JsonProperty
// private boolean perfect = false;
//
// public MatchPrediction() {
// }
//
// public MatchPrediction(String community, String email, int match_id, int away_score, String away_team_name,
// int home_score, String home_team_name, boolean home_winner, int score) {
// super();
// this.community = community;
// this.email = email;
// this.match_id = match_id;
// this.away_score = away_score;
// this.away_team_name = away_team_name;
// this.home_score = home_score;
// this.home_team_name = home_team_name;
// this.home_winner = home_winner;
// this.score = score;
// }
//
// public boolean isHome_winner() {
// return home_winner;
// }
//
// public void setHome_winner(boolean home_winner) {
// this.home_winner = home_winner;
// }
//
// public String getCommunity() {
// return community;
// }
//
// public void setCommunity(String community) {
// this.community = community;
// }
//
// public String getEmail() {
// return email != null ? email.toLowerCase() : null;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public int getMatch_id() {
// return match_id;
// }
//
// public void setMatch_id(int match_id) {
// this.match_id = match_id;
// }
//
// public int getAway_score() {
// return away_score;
// }
//
// public void setAway_score(int away_score) {
// this.away_score = away_score;
// }
//
// public String getAway_team_name() {
// return away_team_name;
// }
//
// public void setAway_team_name(String away_team_name) {
// this.away_team_name = away_team_name;
// }
//
// public int getHome_score() {
// return home_score;
// }
//
// public void setHome_score(int home_score) {
// this.home_score = home_score;
// }
//
// public String getHome_team_name() {
// return home_team_name;
// }
//
// public void setHome_team_name(String home_team_name) {
// this.home_team_name = home_team_name;
// }
//
// public int getScore() {
// return score;
// }
//
// public boolean isPerfect() {
// return perfect;
// }
//
// public void setPerfect(boolean perfect) {
// this.perfect = perfect;
// }
// }
// Path: predictor/src/main/java/predictions/model/MatchPredictions.java
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import predictions.model.db.MatchPrediction;
package predictions.model;
public class MatchPredictions {
@JsonProperty
private String email;
@JsonProperty
private String community;
@JsonProperty
private String name;
@JsonProperty
private boolean admin;
@JsonProperty
private boolean late;
@JsonProperty
private int currentRanking;
@JsonProperty
private String authToken;
@JsonProperty | private List<MatchPrediction> match_predictions_attributes; |
mozvip/sports-predictions | scrapper/src/wc2018/scrapper/WC2018Scrapper.java | // Path: scrapper/src/model/Match.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class Match {
//
// @JsonProperty
// private int matchNum;
//
// @JsonProperty
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm", timezone="GMT+2")
// private ZonedDateTime dateTime;
//
// @JsonProperty
// private String group;
//
// @JsonProperty
// private String stadium;
//
// @JsonProperty
// private String homeTeamName;
//
// @JsonProperty
// private Integer homeTeamWinnerFrom;
//
// @JsonProperty
// private String awayTeamName;
//
// @JsonProperty
// private Integer awayTeamWinnerFrom;
//
// public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, String homeTeamName, String awayTeamName) {
// this.matchNum = matchNum;
// this.dateTime = dateTime;
// this.group = group;
// this.stadium = stadium.trim();
// this.homeTeamName = homeTeamName.trim();
// this.awayTeamName = awayTeamName.trim();
// }
//
// public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, int homeTeamWinnerFrom, int awayTeamWinnerFrom) {
// this.matchNum = matchNum;
// this.dateTime = dateTime;
// this.group = group;
// this.stadium = stadium;
// this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// }
//
// public int getMatchNum() {
// return matchNum;
// }
//
// public void setMatchNum(int matchNum) {
// this.matchNum = matchNum;
// }
//
// public ZonedDateTime getDateTime() {
// return dateTime;
// }
//
// public void setDateTime(ZonedDateTime dateTime) {
// this.dateTime = dateTime;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getStadium() {
// return stadium;
// }
//
// public void setStadium(String stadium) {
// this.stadium = stadium;
// }
//
// public String getHomeTeamName() {
// return homeTeamName;
// }
//
// public void setHomeTeamName(String homeTeamName) {
// this.homeTeamName = homeTeamName;
// }
//
// public Integer getHomeTeamWinnerFrom() {
// return homeTeamWinnerFrom;
// }
//
// public void setHomeTeamWinnerFrom(Integer homeTeamWinnerFrom) {
// this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// }
//
// public String getAwayTeamName() {
// return awayTeamName;
// }
//
// public void setAwayTeamName(String awayTeamName) {
// this.awayTeamName = awayTeamName;
// }
//
// public Integer getAwayTeamWinnerFrom() {
// return awayTeamWinnerFrom;
// }
//
// public void setAwayTeamWinnerFrom(Integer awayTeamWinnerFrom) {
// this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// }
//
// @Override
// public String toString() {
// return "Match{" +
// "matchNum=" + matchNum +
// ", dateTime=" + dateTime +
// ", group='" + group + '\'' +
// ", stadium='" + stadium + '\'' +
// ", homeTeamName='" + homeTeamName + '\'' +
// ", homeTeamWinnerFrom=" + homeTeamWinnerFrom +
// ", awayTeamName='" + awayTeamName + '\'' +
// ", awayTeamWinnerFrom=" + awayTeamWinnerFrom +
// '}';
// }
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import model.Match;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package wc2018.scrapper;
public class WC2018Scrapper {
public String getName(Element nameElement) throws IOException {
Elements name = nameElement.select("[itemprop=name]");
String teamName = name.select("a").isEmpty() ? name.text() : name.select("a").text();
Elements teamFlag = nameElement.select(".flagicon img");
if (!teamFlag.isEmpty()) {
String flagSet = teamFlag.first().attr("srcset");
Path flagsDirectory = Paths.get("flags");
Files.createDirectories(flagsDirectory);
}
return teamName;
}
public void scrapMatches() throws IOException {
Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup").get();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
| // Path: scrapper/src/model/Match.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class Match {
//
// @JsonProperty
// private int matchNum;
//
// @JsonProperty
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm", timezone="GMT+2")
// private ZonedDateTime dateTime;
//
// @JsonProperty
// private String group;
//
// @JsonProperty
// private String stadium;
//
// @JsonProperty
// private String homeTeamName;
//
// @JsonProperty
// private Integer homeTeamWinnerFrom;
//
// @JsonProperty
// private String awayTeamName;
//
// @JsonProperty
// private Integer awayTeamWinnerFrom;
//
// public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, String homeTeamName, String awayTeamName) {
// this.matchNum = matchNum;
// this.dateTime = dateTime;
// this.group = group;
// this.stadium = stadium.trim();
// this.homeTeamName = homeTeamName.trim();
// this.awayTeamName = awayTeamName.trim();
// }
//
// public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, int homeTeamWinnerFrom, int awayTeamWinnerFrom) {
// this.matchNum = matchNum;
// this.dateTime = dateTime;
// this.group = group;
// this.stadium = stadium;
// this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// }
//
// public int getMatchNum() {
// return matchNum;
// }
//
// public void setMatchNum(int matchNum) {
// this.matchNum = matchNum;
// }
//
// public ZonedDateTime getDateTime() {
// return dateTime;
// }
//
// public void setDateTime(ZonedDateTime dateTime) {
// this.dateTime = dateTime;
// }
//
// public String getGroup() {
// return group;
// }
//
// public void setGroup(String group) {
// this.group = group;
// }
//
// public String getStadium() {
// return stadium;
// }
//
// public void setStadium(String stadium) {
// this.stadium = stadium;
// }
//
// public String getHomeTeamName() {
// return homeTeamName;
// }
//
// public void setHomeTeamName(String homeTeamName) {
// this.homeTeamName = homeTeamName;
// }
//
// public Integer getHomeTeamWinnerFrom() {
// return homeTeamWinnerFrom;
// }
//
// public void setHomeTeamWinnerFrom(Integer homeTeamWinnerFrom) {
// this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// }
//
// public String getAwayTeamName() {
// return awayTeamName;
// }
//
// public void setAwayTeamName(String awayTeamName) {
// this.awayTeamName = awayTeamName;
// }
//
// public Integer getAwayTeamWinnerFrom() {
// return awayTeamWinnerFrom;
// }
//
// public void setAwayTeamWinnerFrom(Integer awayTeamWinnerFrom) {
// this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// }
//
// @Override
// public String toString() {
// return "Match{" +
// "matchNum=" + matchNum +
// ", dateTime=" + dateTime +
// ", group='" + group + '\'' +
// ", stadium='" + stadium + '\'' +
// ", homeTeamName='" + homeTeamName + '\'' +
// ", homeTeamWinnerFrom=" + homeTeamWinnerFrom +
// ", awayTeamName='" + awayTeamName + '\'' +
// ", awayTeamWinnerFrom=" + awayTeamWinnerFrom +
// '}';
// }
// }
// Path: scrapper/src/wc2018/scrapper/WC2018Scrapper.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import model.Match;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package wc2018.scrapper;
public class WC2018Scrapper {
public String getName(Element nameElement) throws IOException {
Elements name = nameElement.select("[itemprop=name]");
String teamName = name.select("a").isEmpty() ? name.text() : name.select("a").text();
Elements teamFlag = nameElement.select(".flagicon img");
if (!teamFlag.isEmpty()) {
String flagSet = teamFlag.first().attr("srcset");
Path flagsDirectory = Paths.get("flags");
Files.createDirectories(flagsDirectory);
}
return teamName;
}
public void scrapMatches() throws IOException {
Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup").get();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
| List<Match> matches = new ArrayList<>(); |
mozvip/sports-predictions | predictor/src/main/java/predictions/phases/PhaseFilter.java | // Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
| import java.io.IOException;
import java.text.SimpleDateFormat;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO; | package predictions.phases;
public class PhaseFilter implements Filter {
private final static Logger LOGGER = LoggerFactory.getLogger( PhaseFilter.class );
private PhaseManager phaseManager; | // Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
// Path: predictor/src/main/java/predictions/phases/PhaseFilter.java
import java.io.IOException;
import java.text.SimpleDateFormat;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO;
package predictions.phases;
public class PhaseFilter implements Filter {
private final static Logger LOGGER = LoggerFactory.getLogger( PhaseFilter.class );
private PhaseManager phaseManager; | private CommunityDAO communityDAO; |
mozvip/sports-predictions | predictor/src/main/java/predictions/phases/PhaseFilter.java | // Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
| import java.io.IOException;
import java.text.SimpleDateFormat;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO; | package predictions.phases;
public class PhaseFilter implements Filter {
private final static Logger LOGGER = LoggerFactory.getLogger( PhaseFilter.class );
private PhaseManager phaseManager;
private CommunityDAO communityDAO;
public PhaseFilter(PhaseManager phaseManager, CommunityDAO communityDAO) {
this.phaseManager = phaseManager;
this.communityDAO = communityDAO;
}
public void init(FilterConfig filterConfig) {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// get current phase
Phase currentPhase = phaseManager.getCurrentPhase();
if (currentPhase.getWelcomePage() == null) {
chain.doFilter(request, response);
return;
}
HttpServletRequest servletRequest = (HttpServletRequest) request;
String requestURI = servletRequest.getRequestURI();
String communityName = (String) request.getAttribute("community");
// TODO: cache communities | // Path: predictor/src/main/java/predictions/model/db/Community.java
// public class Community {
//
// @JsonProperty
// private String name;
//
// @JsonProperty
// private boolean createAccountEnabled = true;
//
// @JsonProperty
//
// private ZonedDateTime openingDate = null;
//
// @JsonProperty
// private AccessType groupsAccess = AccessType.N;
//
// @JsonProperty
// private AccessType finalsAccess = AccessType.N;
//
// public Community() {
//
// }
//
// public Community(String name, boolean createAccountEnabled, ZonedDateTime openingDate, AccessType groupsAccess, AccessType finalsAccess) {
// super();
// this.name = name;
// this.openingDate = openingDate;
// this.createAccountEnabled = createAccountEnabled;
// this.groupsAccess = groupsAccess;
// this.finalsAccess = finalsAccess;
// }
//
// public String getName() {
// return name;
// }
//
// public boolean isCreateAccountEnabled() {
// return createAccountEnabled;
// }
//
// public AccessType getGroupsAccess() {
// return groupsAccess;
// }
//
// public AccessType getFinalsAccess() {
// return finalsAccess;
// }
//
// public ZonedDateTime getOpeningDate() {
// return openingDate;
// }
// }
//
// Path: predictor/src/main/java/predictions/model/db/CommunityDAO.java
// @RegisterRowMapper(CommunityMapper.class)
// public interface CommunityDAO {
//
// @SqlUpdate("MERGE INTO COMMUNITY KEY(COMMUNITY_NAME) VALUES(:name, :createAccountEnabled, :openingDate, :groupsAccess, :finalsAccess)")
// void updateCommunity(@Bind("name") String name, @Bind("createAccountEnabled") boolean createAccountEnabled, @Bind("openingDate")ZonedDateTime openingDate, @Bind("groupsAccess") AccessType groupsAccess, @Bind("finalsAccess") AccessType finalsAccess);
//
// @SqlQuery("SELECT COMMUNITY.* FROM COMMUNITY WHERE COMMUNITY_NAME = :name")
// Community getCommunity(@Bind("name") String name);
//
// }
// Path: predictor/src/main/java/predictions/phases/PhaseFilter.java
import java.io.IOException;
import java.text.SimpleDateFormat;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import predictions.model.db.Community;
import predictions.model.db.CommunityDAO;
package predictions.phases;
public class PhaseFilter implements Filter {
private final static Logger LOGGER = LoggerFactory.getLogger( PhaseFilter.class );
private PhaseManager phaseManager;
private CommunityDAO communityDAO;
public PhaseFilter(PhaseManager phaseManager, CommunityDAO communityDAO) {
this.phaseManager = phaseManager;
this.communityDAO = communityDAO;
}
public void init(FilterConfig filterConfig) {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// get current phase
Phase currentPhase = phaseManager.getCurrentPhase();
if (currentPhase.getWelcomePage() == null) {
chain.doFilter(request, response);
return;
}
HttpServletRequest servletRequest = (HttpServletRequest) request;
String requestURI = servletRequest.getRequestURI();
String communityName = (String) request.getAttribute("community");
// TODO: cache communities | Community community = communityDAO.getCommunity(communityName); |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}") | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}") | Call<Competition> competition(@Path("id") int competitionId); |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}")
Call<Competition> competition(@Path("id") int competitionId);
@GET("v1/competitions/{id}/teams") | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}")
Call<Competition> competition(@Path("id") int competitionId);
@GET("v1/competitions/{id}/teams") | Call<Teams> teams(@Path("id") int competitionId); |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path; | package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}")
Call<Competition> competition(@Path("id") int competitionId);
@GET("v1/competitions/{id}/teams")
Call<Teams> teams(@Path("id") int competitionId);
@GET("v1/competitions/{id}/fixtures") | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataService.java
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
package com.github.mozvip.footballdata;
public interface FootballDataService {
@GET("v1/competitions/{id}")
Call<Competition> competition(@Path("id") int competitionId);
@GET("v1/competitions/{id}/teams")
Call<Teams> teams(@Path("id") int competitionId);
@GET("v1/competitions/{id}/fixtures") | Call<Fixtures> fixtures(@Path("id") int competitionId); |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException; | package com.github.mozvip.footballdata;
public class FootballDataClient {
public static final class Builder {
private String apiKey;
private Builder(String apiKey) {
this.apiKey = apiKey;
}
public FootballDataClient build() {
return new FootballDataClient( apiKey );
}
}
public static Builder Builder(String apiKey) {
return new Builder(apiKey);
}
private String apiKey;
private FootballDataService service = null;
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
| // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException;
package com.github.mozvip.footballdata;
public class FootballDataClient {
public static final class Builder {
private String apiKey;
private Builder(String apiKey) {
this.apiKey = apiKey;
}
public FootballDataClient build() {
return new FootballDataClient( apiKey );
}
}
public static Builder Builder(String apiKey) {
return new Builder(apiKey);
}
private String apiKey;
private FootballDataService service = null;
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
| public Competition competition(int competitionId) throws IOException { |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException; | }
public static Builder Builder(String apiKey) {
return new Builder(apiKey);
}
private String apiKey;
private FootballDataService service = null;
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
public Competition competition(int competitionId) throws IOException {
Response<Competition> response = service.competition(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
| // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException;
}
public static Builder Builder(String apiKey) {
return new Builder(apiKey);
}
private String apiKey;
private FootballDataService service = null;
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
public Competition competition(int competitionId) throws IOException {
Response<Competition> response = service.competition(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
| public Teams teams(int competitionId) throws IOException { |
mozvip/sports-predictions | football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java | // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
| import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException; |
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
public Competition competition(int competitionId) throws IOException {
Response<Competition> response = service.competition(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
public Teams teams(int competitionId) throws IOException {
Response<Teams> response = service.teams(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
| // Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Competition.java
// public class Competition {
//
// private Map<String, Link> _links;
// private int id;
// private String caption;
// private String league;
// private String year;
// private int currentMatchday;
// private int numberOfMatchdays;
// private int numberOfTeams;
// private int numberOfGames;
// private ZonedDateTime lastUpdated;
//
// public Competition() {
// }
//
// public Competition(int id, String caption, String league, String year, int currentMatchday, int numberOfMatchdays, int numberOfTeams, int numberOfGames, ZonedDateTime lastUpdated) {
// this.id = id;
// this.caption = caption;
// this.league = league;
// this.year = year;
// this.currentMatchday = currentMatchday;
// this.numberOfMatchdays = numberOfMatchdays;
// this.numberOfTeams = numberOfTeams;
// this.numberOfGames = numberOfGames;
// this.lastUpdated = lastUpdated;
// }
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getCaption() {
// return caption;
// }
//
// public void setCaption(String caption) {
// this.caption = caption;
// }
//
// public String getLeague() {
// return league;
// }
//
// public void setLeague(String league) {
// this.league = league;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setYear(String year) {
// this.year = year;
// }
//
// public int getCurrentMatchday() {
// return currentMatchday;
// }
//
// public void setCurrentMatchday(int currentMatchday) {
// this.currentMatchday = currentMatchday;
// }
//
// public int getNumberOfMatchdays() {
// return numberOfMatchdays;
// }
//
// public void setNumberOfMatchdays(int numberOfMatchdays) {
// this.numberOfMatchdays = numberOfMatchdays;
// }
//
// public int getNumberOfTeams() {
// return numberOfTeams;
// }
//
// public void setNumberOfTeams(int numberOfTeams) {
// this.numberOfTeams = numberOfTeams;
// }
//
// public int getNumberOfGames() {
// return numberOfGames;
// }
//
// public void setNumberOfGames(int numberOfGames) {
// this.numberOfGames = numberOfGames;
// }
//
// public ZonedDateTime getLastUpdated() {
// return lastUpdated;
// }
//
// public void setLastUpdated(ZonedDateTime lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Fixtures.java
// public class Fixtures {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Fixture> fixtures;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Fixture> getFixtures() {
// return fixtures;
// }
//
// public void setFixtures(List<Fixture> fixtures) {
// this.fixtures = fixtures;
// }
// }
//
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/model/Teams.java
// public class Teams {
//
// private Map<String, Link> _links;
// private int count;
//
// private List<Team> teams;
//
// public Map<String, Link> get_links() {
// return _links;
// }
//
// public void set_links(Map<String, Link> _links) {
// this._links = _links;
// }
//
// public int getCount() {
// return count;
// }
//
// public void setCount(int count) {
// this.count = count;
// }
//
// public List<Team> getTeams() {
// return teams;
// }
//
// public void setTeams(List<Team> teams) {
// this.teams = teams;
// }
// }
// Path: football-data-client/src/main/java/com/github/mozvip/footballdata/FootballDataClient.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.mozvip.footballdata.model.Competition;
import com.github.mozvip.footballdata.model.Fixtures;
import com.github.mozvip.footballdata.model.Teams;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import retrofit2.http.GET;
import java.io.IOException;
public FootballDataClient(String apiKey) {
this.apiKey = apiKey;
ObjectMapper mapper = new ObjectMapper()
.registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.football-data.org")
.addConverterFactory(JacksonConverterFactory.create(mapper))
.build();
service = retrofit.create(FootballDataService.class);
}
public Competition competition(int competitionId) throws IOException {
Response<Competition> response = service.competition(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
public Teams teams(int competitionId) throws IOException {
Response<Teams> response = service.teams(competitionId).execute();
if (response.isSuccessful()) {
return response.body();
}
throw new IOException(response.message());
}
| public Fixtures fixtures(int competitionId) throws IOException { |
mistodev/processing-idea | src/org/idea/processing/plugin/run_configuration/ProcessingRunConfigurationEditor.java | // Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
// INSTANCE;
//
// public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
// VirtualFile importableRoot = LocalFileFinder.findFile(path);
//
// if (importableRoot == null) {
// return new HashSet<>();
// }
//
// return Arrays.stream(importableRoot.getChildren())
// .filter(predicate)
// .collect(Collectors.toSet());
// }
//
// public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
// if (modules == null || modules.length == 0) return null;
//
// GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
//
// for (int i = 1; i < modules.length; i++) {
// scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
// }
//
// return scope;
// }
// }
| import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.ui.ColorChooser;
import com.intellij.ui.ColorUtil;
import com.intellij.util.Query;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection; |
@Override
protected void resetEditorFrom(@NotNull T t) {
moduleSelector.fillModules(project);
Module[] allModules = ModuleManager.getInstance(project).getModules();
if (allModules.length > 0) {
moduleSelector.setSelectedModule(allModules[0]);
}
Module sketchModule = null;
for (Module projectModule : allModules) {
if (projectModule.getName().equals(t.getRunSettings().getModule())) {
sketchModule = projectModule;
moduleSelector.setSelectedModule(projectModule);
break;
}
}
refreshSketchSelectorFromSelectedModule();
if (sketchModule != null) {
String savedSketchClassFqn = t.getRunSettings().getSketchClass();
Module[] moduleSearchScope = {sketchModule};
PsiClass sketchClass = JavaPsiFacade.getInstance(project)
.findClass(savedSketchClassFqn, | // Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
// INSTANCE;
//
// public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
// VirtualFile importableRoot = LocalFileFinder.findFile(path);
//
// if (importableRoot == null) {
// return new HashSet<>();
// }
//
// return Arrays.stream(importableRoot.getChildren())
// .filter(predicate)
// .collect(Collectors.toSet());
// }
//
// public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
// if (modules == null || modules.length == 0) return null;
//
// GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
//
// for (int i = 1; i < modules.length; i++) {
// scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
// }
//
// return scope;
// }
// }
// Path: src/org/idea/processing/plugin/run_configuration/ProcessingRunConfigurationEditor.java
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClass;
import com.intellij.psi.search.searches.AllClassesSearch;
import com.intellij.ui.ColorChooser;
import com.intellij.ui.ColorUtil;
import com.intellij.util.Query;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
@Override
protected void resetEditorFrom(@NotNull T t) {
moduleSelector.fillModules(project);
Module[] allModules = ModuleManager.getInstance(project).getModules();
if (allModules.length > 0) {
moduleSelector.setSelectedModule(allModules[0]);
}
Module sketchModule = null;
for (Module projectModule : allModules) {
if (projectModule.getName().equals(t.getRunSettings().getModule())) {
sketchModule = projectModule;
moduleSelector.setSelectedModule(projectModule);
break;
}
}
refreshSketchSelectorFromSelectedModule();
if (sketchModule != null) {
String savedSketchClassFqn = t.getRunSettings().getSketchClass();
Module[] moduleSearchScope = {sketchModule};
PsiClass sketchClass = JavaPsiFacade.getInstance(project)
.findClass(savedSketchClassFqn, | ProcessingPluginUtil.INSTANCE.sketchesInModuleScope(moduleSearchScope) |
mistodev/processing-idea | src/org/idea/processing/plugin/pde_import/ImportSketchClasses.java | // Path: src/org/idea/processing/plugin/project_creation/RunnableActionUtils.java
// public class RunnableActionUtils {
// public static void runWhenInitialized(final Project project, final Runnable r) {
// if (project.isDisposed()) return;
//
// if (isNoBackgroundMode()) {
// r.run();
// return;
// }
//
// if (!project.isInitialized()) {
// StartupManager.getInstance(project).registerPostStartupActivity(DisposeAwareRunnable.create(r, project));
// return;
// }
//
// runDumbAware(project, r);
// }
//
// public static void runDumbAware(final Project project, final Runnable r) {
// if (DumbService.isDumbAware(r)) {
// r.run();
// }
// else {
// DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(r, project));
// }
// }
//
// public static boolean isNoBackgroundMode() {
// return (ApplicationManager.getApplication().isUnitTestMode()
// || ApplicationManager.getApplication().isHeadlessEnvironment());
// }
//
// }
| import java.util.*;
import com.intellij.ide.util.PackageUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.idea.processing.plugin.project_creation.RunnableActionUtils; | ImportDialogs.NO_MAIN_SKETCH_CLASS.getDialog().show();
}*/
PsiFile selectedMainSketchFile;
PsiClass selectedMainSketchClass;
PsiImportList correspondingImportList;
// At this point, a short-list of potential main classes has been established. Select one for the purposes of import.
Iterator<Map.Entry<Pair<PsiFile, PsiClass>, PsiImportList>> classesIterator = mainSketchClasses.entrySet().iterator();
Map.Entry<Pair<PsiFile, PsiClass>, PsiImportList> entry = classesIterator.next();
selectedMainSketchFile = entry.getKey().getFirst();
selectedMainSketchClass = entry.getKey().getSecond();
correspondingImportList = entry.getValue();
if (selectedMainSketchFile == null || selectedMainSketchClass == null || correspondingImportList == null) {
throw new IllegalStateException("The selected main sketch class is null, or the corresponding import list to the class is null.");
}
PsiFile postProcessedMainSketchFile = MigrationActions.postProcessSelectedMainSketchClass(project, selectedMainSketchClass, correspondingImportList);
importableSketchFiles.remove(selectedMainSketchFile);
importableSketchFiles.add(postProcessedMainSketchFile);
// Write all of the imported sketch files to disk.
final VirtualFile sketchResourcesRoot = importBuilder.getParameters().resourceDirectoryPath;
logger.info("Preparing to import sketch resources from '" + sketchResourcesRoot + "'.");
| // Path: src/org/idea/processing/plugin/project_creation/RunnableActionUtils.java
// public class RunnableActionUtils {
// public static void runWhenInitialized(final Project project, final Runnable r) {
// if (project.isDisposed()) return;
//
// if (isNoBackgroundMode()) {
// r.run();
// return;
// }
//
// if (!project.isInitialized()) {
// StartupManager.getInstance(project).registerPostStartupActivity(DisposeAwareRunnable.create(r, project));
// return;
// }
//
// runDumbAware(project, r);
// }
//
// public static void runDumbAware(final Project project, final Runnable r) {
// if (DumbService.isDumbAware(r)) {
// r.run();
// }
// else {
// DumbService.getInstance(project).runWhenSmart(DisposeAwareRunnable.create(r, project));
// }
// }
//
// public static boolean isNoBackgroundMode() {
// return (ApplicationManager.getApplication().isUnitTestMode()
// || ApplicationManager.getApplication().isHeadlessEnvironment());
// }
//
// }
// Path: src/org/idea/processing/plugin/pde_import/ImportSketchClasses.java
import java.util.*;
import com.intellij.ide.util.PackageUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.idea.processing.plugin.project_creation.RunnableActionUtils;
ImportDialogs.NO_MAIN_SKETCH_CLASS.getDialog().show();
}*/
PsiFile selectedMainSketchFile;
PsiClass selectedMainSketchClass;
PsiImportList correspondingImportList;
// At this point, a short-list of potential main classes has been established. Select one for the purposes of import.
Iterator<Map.Entry<Pair<PsiFile, PsiClass>, PsiImportList>> classesIterator = mainSketchClasses.entrySet().iterator();
Map.Entry<Pair<PsiFile, PsiClass>, PsiImportList> entry = classesIterator.next();
selectedMainSketchFile = entry.getKey().getFirst();
selectedMainSketchClass = entry.getKey().getSecond();
correspondingImportList = entry.getValue();
if (selectedMainSketchFile == null || selectedMainSketchClass == null || correspondingImportList == null) {
throw new IllegalStateException("The selected main sketch class is null, or the corresponding import list to the class is null.");
}
PsiFile postProcessedMainSketchFile = MigrationActions.postProcessSelectedMainSketchClass(project, selectedMainSketchClass, correspondingImportList);
importableSketchFiles.remove(selectedMainSketchFile);
importableSketchFiles.add(postProcessedMainSketchFile);
// Write all of the imported sketch files to disk.
final VirtualFile sketchResourcesRoot = importBuilder.getParameters().resourceDirectoryPath;
logger.info("Preparing to import sketch resources from '" + sketchResourcesRoot + "'.");
| RunnableActionUtils.runWhenInitialized(project, () -> { |
mistodev/processing-idea | src/org/idea/processing/plugin/pde_import/ProcessingSketchRootSelectStep.java | // Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
// INSTANCE;
//
// public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
// VirtualFile importableRoot = LocalFileFinder.findFile(path);
//
// if (importableRoot == null) {
// return new HashSet<>();
// }
//
// return Arrays.stream(importableRoot.getChildren())
// .filter(predicate)
// .collect(Collectors.toSet());
// }
//
// public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
// if (modules == null || modules.length == 0) return null;
//
// GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
//
// for (int i = 1; i < modules.length; i++) {
// scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
// }
//
// return scope;
// }
// }
| import com.intellij.ide.impl.ProjectUtil;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.projectImport.ProjectImportWizardStep;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.JBColor;
import com.intellij.util.PathUtil;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.ItemEvent;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate; | customImportRootDirectoryBrowser.setVisible(true);
customImportRootDirectoryBrowser.setEnabled(true);
} else {
customImportRootDirectoryBrowser.setVisible(false);
customImportRootDirectoryBrowser.setEnabled(false);
}
refreshProjectCreationPreview();
});
} else {
radioButton.addItemListener(e -> refreshProjectCreationPreview());
}
}
}
}
@Override
public void updateDataModel() {
getWizardContext().setProjectName(PathUtil.getFileName(projectRootDirectoryBrowser.getText()));
getWizardContext().setProjectFileDirectory(projectRootDirectoryBrowser.getText());
if (importIntoDefaultProjectOption.isSelected()) {
getParameters().projectCreationRoot = ProjectUtil.getBaseDir();
} else if (createProjectInSelectedRootOption.isSelected()) {
getParameters().projectCreationRoot = projectRootDirectoryBrowser.getText();
} else if (importProjectIntoCustomRootOption.isSelected()) {
getParameters().projectCreationRoot = customImportRootDirectoryBrowser.getText();
}
getParameters().root = projectRootDirectoryBrowser.getText(); | // Path: src/org/idea/processing/plugin/ProcessingPluginUtil.java
// public enum ProcessingPluginUtil {
// INSTANCE;
//
// public Collection<VirtualFile> filterFilesAtRoot(@NotNull String path, @NotNull Predicate<VirtualFile> predicate) {
// VirtualFile importableRoot = LocalFileFinder.findFile(path);
//
// if (importableRoot == null) {
// return new HashSet<>();
// }
//
// return Arrays.stream(importableRoot.getChildren())
// .filter(predicate)
// .collect(Collectors.toSet());
// }
//
// public GlobalSearchScope sketchesInModuleScope(Module[] modules) {
// if (modules == null || modules.length == 0) return null;
//
// GlobalSearchScope scope = GlobalSearchScope.moduleScope(modules[0]);
//
// for (int i = 1; i < modules.length; i++) {
// scope.uniteWith(GlobalSearchScope.moduleScope(modules[i]));
// }
//
// return scope;
// }
// }
// Path: src/org/idea/processing/plugin/pde_import/ProcessingSketchRootSelectStep.java
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.ide.util.projectWizard.WizardContext;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.projectImport.ProjectImportWizardStep;
import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.JBColor;
import com.intellij.util.PathUtil;
import org.idea.processing.plugin.ProcessingPluginUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.ItemEvent;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.StringJoiner;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Predicate;
customImportRootDirectoryBrowser.setVisible(true);
customImportRootDirectoryBrowser.setEnabled(true);
} else {
customImportRootDirectoryBrowser.setVisible(false);
customImportRootDirectoryBrowser.setEnabled(false);
}
refreshProjectCreationPreview();
});
} else {
radioButton.addItemListener(e -> refreshProjectCreationPreview());
}
}
}
}
@Override
public void updateDataModel() {
getWizardContext().setProjectName(PathUtil.getFileName(projectRootDirectoryBrowser.getText()));
getWizardContext().setProjectFileDirectory(projectRootDirectoryBrowser.getText());
if (importIntoDefaultProjectOption.isSelected()) {
getParameters().projectCreationRoot = ProjectUtil.getBaseDir();
} else if (createProjectInSelectedRootOption.isSelected()) {
getParameters().projectCreationRoot = projectRootDirectoryBrowser.getText();
} else if (importProjectIntoCustomRootOption.isSelected()) {
getParameters().projectCreationRoot = customImportRootDirectoryBrowser.getText();
}
getParameters().root = projectRootDirectoryBrowser.getText(); | getParameters().importablePdeFiles = ProcessingPluginUtil.INSTANCE.filterFilesAtRoot(projectRootDirectoryBrowser.getText(), isPdeFile()); |
mistodev/processing-idea | src/org/idea/processing/plugin/intention/SettingsInvokedInSetupInspection.java | // Path: src/org/idea/processing/plugin/project_creation/ProcessingModuleType.java
// public class ProcessingModuleType extends ModuleType<ProcessingModuleBuilder> {
// private static final String id = "org.idea.processing.module";
//
// public ProcessingModuleType() {
// super(id);
// }
//
// public static ProcessingModuleType getInstance() {
// return (ProcessingModuleType) ModuleTypeManager.getInstance().findByID(id);
// }
//
// @NotNull
// @Override
// public ProcessingModuleBuilder createModuleBuilder() {
// return new ProcessingModuleBuilder();
// }
//
// @NotNull
// @Override
// public String getName() {
// return "Processing Module";
// }
//
// @NotNull
// @Override
// public String getDescription() {
// return "A Processing language module.";
// }
//
// @Override
// public Icon getBigIcon() {
// return AllIcons.General.Information;
// }
//
// @Override
// public Icon getNodeIcon(@Deprecated boolean b) {
// return AllIcons.General.Information;
// }
//
// @Nullable
// @Override
// public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
// return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder,
// moduleBuilder::isSuitableSdkType);
// }
//
// @NotNull
// @Override
// public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ProcessingModuleBuilder moduleBuilder, @NotNull ModulesProvider modulesProvider) {
// return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
// }
// }
| import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.idea.processing.plugin.project_creation.ProcessingModuleType;
import org.jetbrains.annotations.Nls; | /*
* Copyright (c) 2017 mistodev
*
* This file is part of "Processing IDEA plugin" and is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.idea.processing.plugin.intention;
// @TODO Refactor code to reduce duplication.
public class SettingsInvokedInSetupInspection extends LocalInspectionTool implements CleanupLocalInspectionTool {
private final Collection<String> SETTINGS_METHODS =
new HashSet<>(Arrays.asList("size", "fullScreen", "pixelDensity", "smooth", "noSmooth"));
@NotNull
public String getGroupDisplayName() {
return "Processing";
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return "Settings methods must be invoked only from 'settings' method";
}
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
Module psiFileModule = ModuleUtil.findModuleForPsiElement(holder.getFile());
| // Path: src/org/idea/processing/plugin/project_creation/ProcessingModuleType.java
// public class ProcessingModuleType extends ModuleType<ProcessingModuleBuilder> {
// private static final String id = "org.idea.processing.module";
//
// public ProcessingModuleType() {
// super(id);
// }
//
// public static ProcessingModuleType getInstance() {
// return (ProcessingModuleType) ModuleTypeManager.getInstance().findByID(id);
// }
//
// @NotNull
// @Override
// public ProcessingModuleBuilder createModuleBuilder() {
// return new ProcessingModuleBuilder();
// }
//
// @NotNull
// @Override
// public String getName() {
// return "Processing Module";
// }
//
// @NotNull
// @Override
// public String getDescription() {
// return "A Processing language module.";
// }
//
// @Override
// public Icon getBigIcon() {
// return AllIcons.General.Information;
// }
//
// @Override
// public Icon getNodeIcon(@Deprecated boolean b) {
// return AllIcons.General.Information;
// }
//
// @Nullable
// @Override
// public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
// return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder,
// moduleBuilder::isSuitableSdkType);
// }
//
// @NotNull
// @Override
// public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ProcessingModuleBuilder moduleBuilder, @NotNull ModulesProvider modulesProvider) {
// return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
// }
// }
// Path: src/org/idea/processing/plugin/intention/SettingsInvokedInSetupInspection.java
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInspection.CleanupLocalInspectionTool;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.idea.processing.plugin.project_creation.ProcessingModuleType;
import org.jetbrains.annotations.Nls;
/*
* Copyright (c) 2017 mistodev
*
* This file is part of "Processing IDEA plugin" and is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.idea.processing.plugin.intention;
// @TODO Refactor code to reduce duplication.
public class SettingsInvokedInSetupInspection extends LocalInspectionTool implements CleanupLocalInspectionTool {
private final Collection<String> SETTINGS_METHODS =
new HashSet<>(Arrays.asList("size", "fullScreen", "pixelDensity", "smooth", "noSmooth"));
@NotNull
public String getGroupDisplayName() {
return "Processing";
}
@Nls
@NotNull
@Override
public String getDisplayName() {
return "Settings methods must be invoked only from 'settings' method";
}
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
Module psiFileModule = ModuleUtil.findModuleForPsiElement(holder.getFile());
| if (psiFileModule != null && ModuleUtil.getModuleType(psiFileModule) != ProcessingModuleType.getInstance()) { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/Promises.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promises.java
// public interface Promises<Success>{
//
// <Success2> Promises<Success2> map(final Transformation<Success, Success2> transform);
//
// Promises<Success> onSuccess(Callback<Success> onSuccess);
//
// Promises<Success> onFailure(Callback<Throwable> onFailure);
//
// Promises<Success> runOnUiThread();
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
| import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Promise;
import org.codeandmagic.promise.Promises;
import org.codeandmagic.promise.Transformation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 18/03/2014.
*/
class PromisesList<Success> implements Promises<Success> {
private final Collection<Promise<Success>> mPromises;
PromisesList(Collection<Promise<Success>> promises) {
mPromises = promises;
}
@Override | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promises.java
// public interface Promises<Success>{
//
// <Success2> Promises<Success2> map(final Transformation<Success, Success2> transform);
//
// Promises<Success> onSuccess(Callback<Success> onSuccess);
//
// Promises<Success> onFailure(Callback<Throwable> onFailure);
//
// Promises<Success> runOnUiThread();
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/Promises.java
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Promise;
import org.codeandmagic.promise.Promises;
import org.codeandmagic.promise.Transformation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 18/03/2014.
*/
class PromisesList<Success> implements Promises<Success> {
private final Collection<Promise<Success>> mPromises;
PromisesList(Collection<Promise<Success>> promises) {
mPromises = promises;
}
@Override | public <Success2> Promises<Success2> map(Transformation<Success, Success2> transform) { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/Promises.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promises.java
// public interface Promises<Success>{
//
// <Success2> Promises<Success2> map(final Transformation<Success, Success2> transform);
//
// Promises<Success> onSuccess(Callback<Success> onSuccess);
//
// Promises<Success> onFailure(Callback<Throwable> onFailure);
//
// Promises<Success> runOnUiThread();
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
| import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Promise;
import org.codeandmagic.promise.Promises;
import org.codeandmagic.promise.Transformation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 18/03/2014.
*/
class PromisesList<Success> implements Promises<Success> {
private final Collection<Promise<Success>> mPromises;
PromisesList(Collection<Promise<Success>> promises) {
mPromises = promises;
}
@Override
public <Success2> Promises<Success2> map(Transformation<Success, Success2> transform) {
List<Promise<Success2>> newPromises = new ArrayList<Promise<Success2>>(mPromises.size());
for (Promise<Success> p : mPromises) {
newPromises.add(p.map(transform));
}
return new PromisesList<Success2>(newPromises);
}
@Override | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promises.java
// public interface Promises<Success>{
//
// <Success2> Promises<Success2> map(final Transformation<Success, Success2> transform);
//
// Promises<Success> onSuccess(Callback<Success> onSuccess);
//
// Promises<Success> onFailure(Callback<Throwable> onFailure);
//
// Promises<Success> runOnUiThread();
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/Promises.java
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Promise;
import org.codeandmagic.promise.Promises;
import org.codeandmagic.promise.Transformation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 18/03/2014.
*/
class PromisesList<Success> implements Promises<Success> {
private final Collection<Promise<Success>> mPromises;
PromisesList(Collection<Promise<Success>> promises) {
mPromises = promises;
}
@Override
public <Success2> Promises<Success2> map(Transformation<Success, Success2> transform) {
List<Promise<Success2>> newPromises = new ArrayList<Promise<Success2>>(mPromises.size());
for (Promise<Success> p : mPromises) {
newPromises.add(p.map(transform));
}
return new PromisesList<Success2>(newPromises);
}
@Override | public Promises<Success> onSuccess(Callback<Success> onSuccess) { |
CodeAndMagic/android-deferred-object | sample/src/instrumentTest/java/org/codeandmagic/promise/volley/tests/VolleyJsonObjectTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/PlanetsActivity.java
// public class PlanetsActivity extends ActionBarActivity {
//
// private final static String EARTH = "https://farm3.staticflickr.com/2116/2222523978_f48bf28571_o.jpg";
// private final static String MARS = "https://farm6.staticflickr.com/5328/6897598788_a748a78bb8_o.png";
// private final static String VENUS = "https://farm8.staticflickr.com/7233/7302574832_ed3fa543b2_o.jpg";
//
// private TextView mProgress1, mProgress2, mProgress3, mLog;
// private Button mStart;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.planets_activity);
//
// mLog = (TextView) findViewById(R.id.log);
//
// mProgress1 = (TextView) findViewById(R.id.progress1);
// mProgress2 = (TextView) findViewById(R.id.progress2);
// mProgress3 = (TextView) findViewById(R.id.progress3);
//
// mStart = (Button) findViewById(R.id.start);
// mStart.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startTasks();
// }
// });
// }
//
// private void startTasks() {
// final Promise<File> promise1 = createPromise(EARTH, "Earth", mProgress1);
// final Promise<File> promise2 = createPromise(MARS, "Mars", mProgress2);
// final Promise<File> promise3 = createPromise(VENUS, "Venus", mProgress3);
//
// DeferredObject.merge(File.class, promise1, promise2, promise3)
// .runOnUiThread()
// .onSuccess(new Callback<File[]>() {
// @Override
// public void onCallback(File[] result) {
// mStart.setText(R.string.all_done);
// mStart.setEnabled(true);
// reset(mProgress1, mProgress2, mProgress3);
// }
// })
// .onFailure(new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable result) {
// mStart.setText(R.string.failure);
// mStart.setEnabled(true);
// }
// })
// .onProgress(new Callback<Float>() {
// @Override
// public void onCallback(Float result) {
// mLog.append(" (" + result + " out of 3)");
// }
// });
//
// }
//
// private void done(TextView progress) {
// progress.getCompoundDrawables()[1].setLevel(1);
// }
//
// private void reset(TextView... progress) {
// for (TextView p : progress) {
// p.getCompoundDrawables()[1].setLevel(0);
// p.setText(R.string.no_progress);
// }
// }
//
// private Promise<File> createPromise(String url, String fileName, TextView progress) {
// try {
// return new DownloadPromise(new URL(url), getSdCardFile(fileName))
// .runOnUiThread()
// .onSuccess(successCallback(progress))
// .onFailure(failureCallback(url))
// .onProgress(TextViewUtils.setPercent(progress));
// } catch (IOException e) {
// mLog.setText("Can't mStart download " + url + " due to exception: " + e.getMessage());
// return null;
// }
// }
//
// private Callback<File> successCallback(final TextView textView) {
// return new Callback<File>() {
// @Override
// public void onCallback(File result) {
// mLog.append("\nFile stored in " + result.getPath());
// done(textView);
// }
// };
// }
//
// private Callback<Throwable> failureCallback(final String fileName) {
// return new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable e) {
// mLog.append("\nFailed " + fileName + " because " + e.getClass().getName() + " " + e.getMessage());
// }
// };
// }
// }
| import android.test.ActivityInstrumentationTestCase2;
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Transformation;
import org.codeandmagic.promise.sample.PlanetsActivity;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import org.codeandmagic.promise.volley.VolleyRequest.RObject;
import org.json.JSONObject;
import static org.mockito.Mockito.*; | package org.codeandmagic.promise.volley.tests;
/**
* Created by evelina on 02/03/2014.
*/
public class VolleyJsonObjectTests extends ActivityInstrumentationTestCase2<PlanetsActivity> {
public static final String SUCCESS_URL = "http://date.jsontest.com/";
public static final String FAILURE_URL = "http://example.com/";
public VolleyJsonObjectTests() {
super(PlanetsActivity.class);
}
public void testSuccessRequest() { | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/PlanetsActivity.java
// public class PlanetsActivity extends ActionBarActivity {
//
// private final static String EARTH = "https://farm3.staticflickr.com/2116/2222523978_f48bf28571_o.jpg";
// private final static String MARS = "https://farm6.staticflickr.com/5328/6897598788_a748a78bb8_o.png";
// private final static String VENUS = "https://farm8.staticflickr.com/7233/7302574832_ed3fa543b2_o.jpg";
//
// private TextView mProgress1, mProgress2, mProgress3, mLog;
// private Button mStart;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.planets_activity);
//
// mLog = (TextView) findViewById(R.id.log);
//
// mProgress1 = (TextView) findViewById(R.id.progress1);
// mProgress2 = (TextView) findViewById(R.id.progress2);
// mProgress3 = (TextView) findViewById(R.id.progress3);
//
// mStart = (Button) findViewById(R.id.start);
// mStart.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startTasks();
// }
// });
// }
//
// private void startTasks() {
// final Promise<File> promise1 = createPromise(EARTH, "Earth", mProgress1);
// final Promise<File> promise2 = createPromise(MARS, "Mars", mProgress2);
// final Promise<File> promise3 = createPromise(VENUS, "Venus", mProgress3);
//
// DeferredObject.merge(File.class, promise1, promise2, promise3)
// .runOnUiThread()
// .onSuccess(new Callback<File[]>() {
// @Override
// public void onCallback(File[] result) {
// mStart.setText(R.string.all_done);
// mStart.setEnabled(true);
// reset(mProgress1, mProgress2, mProgress3);
// }
// })
// .onFailure(new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable result) {
// mStart.setText(R.string.failure);
// mStart.setEnabled(true);
// }
// })
// .onProgress(new Callback<Float>() {
// @Override
// public void onCallback(Float result) {
// mLog.append(" (" + result + " out of 3)");
// }
// });
//
// }
//
// private void done(TextView progress) {
// progress.getCompoundDrawables()[1].setLevel(1);
// }
//
// private void reset(TextView... progress) {
// for (TextView p : progress) {
// p.getCompoundDrawables()[1].setLevel(0);
// p.setText(R.string.no_progress);
// }
// }
//
// private Promise<File> createPromise(String url, String fileName, TextView progress) {
// try {
// return new DownloadPromise(new URL(url), getSdCardFile(fileName))
// .runOnUiThread()
// .onSuccess(successCallback(progress))
// .onFailure(failureCallback(url))
// .onProgress(TextViewUtils.setPercent(progress));
// } catch (IOException e) {
// mLog.setText("Can't mStart download " + url + " due to exception: " + e.getMessage());
// return null;
// }
// }
//
// private Callback<File> successCallback(final TextView textView) {
// return new Callback<File>() {
// @Override
// public void onCallback(File result) {
// mLog.append("\nFile stored in " + result.getPath());
// done(textView);
// }
// };
// }
//
// private Callback<Throwable> failureCallback(final String fileName) {
// return new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable e) {
// mLog.append("\nFailed " + fileName + " because " + e.getClass().getName() + " " + e.getMessage());
// }
// };
// }
// }
// Path: sample/src/instrumentTest/java/org/codeandmagic/promise/volley/tests/VolleyJsonObjectTests.java
import android.test.ActivityInstrumentationTestCase2;
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Transformation;
import org.codeandmagic.promise.sample.PlanetsActivity;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import org.codeandmagic.promise.volley.VolleyRequest.RObject;
import org.json.JSONObject;
import static org.mockito.Mockito.*;
package org.codeandmagic.promise.volley.tests;
/**
* Created by evelina on 02/03/2014.
*/
public class VolleyJsonObjectTests extends ActivityInstrumentationTestCase2<PlanetsActivity> {
public static final String SUCCESS_URL = "http://date.jsontest.com/";
public static final String FAILURE_URL = "http://example.com/";
public VolleyJsonObjectTests() {
super(PlanetsActivity.class);
}
public void testSuccessRequest() { | Callback<JSONObject> successCallback = mock(Callback.class); |
CodeAndMagic/android-deferred-object | sample/src/instrumentTest/java/org/codeandmagic/promise/volley/tests/VolleyJsonObjectTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/PlanetsActivity.java
// public class PlanetsActivity extends ActionBarActivity {
//
// private final static String EARTH = "https://farm3.staticflickr.com/2116/2222523978_f48bf28571_o.jpg";
// private final static String MARS = "https://farm6.staticflickr.com/5328/6897598788_a748a78bb8_o.png";
// private final static String VENUS = "https://farm8.staticflickr.com/7233/7302574832_ed3fa543b2_o.jpg";
//
// private TextView mProgress1, mProgress2, mProgress3, mLog;
// private Button mStart;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.planets_activity);
//
// mLog = (TextView) findViewById(R.id.log);
//
// mProgress1 = (TextView) findViewById(R.id.progress1);
// mProgress2 = (TextView) findViewById(R.id.progress2);
// mProgress3 = (TextView) findViewById(R.id.progress3);
//
// mStart = (Button) findViewById(R.id.start);
// mStart.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startTasks();
// }
// });
// }
//
// private void startTasks() {
// final Promise<File> promise1 = createPromise(EARTH, "Earth", mProgress1);
// final Promise<File> promise2 = createPromise(MARS, "Mars", mProgress2);
// final Promise<File> promise3 = createPromise(VENUS, "Venus", mProgress3);
//
// DeferredObject.merge(File.class, promise1, promise2, promise3)
// .runOnUiThread()
// .onSuccess(new Callback<File[]>() {
// @Override
// public void onCallback(File[] result) {
// mStart.setText(R.string.all_done);
// mStart.setEnabled(true);
// reset(mProgress1, mProgress2, mProgress3);
// }
// })
// .onFailure(new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable result) {
// mStart.setText(R.string.failure);
// mStart.setEnabled(true);
// }
// })
// .onProgress(new Callback<Float>() {
// @Override
// public void onCallback(Float result) {
// mLog.append(" (" + result + " out of 3)");
// }
// });
//
// }
//
// private void done(TextView progress) {
// progress.getCompoundDrawables()[1].setLevel(1);
// }
//
// private void reset(TextView... progress) {
// for (TextView p : progress) {
// p.getCompoundDrawables()[1].setLevel(0);
// p.setText(R.string.no_progress);
// }
// }
//
// private Promise<File> createPromise(String url, String fileName, TextView progress) {
// try {
// return new DownloadPromise(new URL(url), getSdCardFile(fileName))
// .runOnUiThread()
// .onSuccess(successCallback(progress))
// .onFailure(failureCallback(url))
// .onProgress(TextViewUtils.setPercent(progress));
// } catch (IOException e) {
// mLog.setText("Can't mStart download " + url + " due to exception: " + e.getMessage());
// return null;
// }
// }
//
// private Callback<File> successCallback(final TextView textView) {
// return new Callback<File>() {
// @Override
// public void onCallback(File result) {
// mLog.append("\nFile stored in " + result.getPath());
// done(textView);
// }
// };
// }
//
// private Callback<Throwable> failureCallback(final String fileName) {
// return new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable e) {
// mLog.append("\nFailed " + fileName + " because " + e.getClass().getName() + " " + e.getMessage());
// }
// };
// }
// }
| import android.test.ActivityInstrumentationTestCase2;
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Transformation;
import org.codeandmagic.promise.sample.PlanetsActivity;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import org.codeandmagic.promise.volley.VolleyRequest.RObject;
import org.json.JSONObject;
import static org.mockito.Mockito.*; |
verify(successCallback, times(2)).onCallback(any(JSONObject.class));
verify(failureCallback, never()).onCallback(any(Throwable.class));
}
public void testFailedRequest() {
Callback<JSONObject> successCallback = mock(Callback.class);
Callback<Throwable> failureCallback = mock(Callback.class);
RequestQueue queue = Volley.newRequestQueue(getActivity().getApplicationContext());
VolleyJsonPromise.jsonObjectPromise(queue, Method.GET, FAILURE_URL, null)
.onSuccess(successCallback)
.onFailure(failureCallback);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
verify(successCallback, never()).onCallback(any(JSONObject.class));
verify(failureCallback, only()).onCallback(any(Throwable.class));
}
public void testExtendedRequest() {
Callback<JSONObject> successCallback = mock(Callback.class);
Callback<Throwable> failureCallback = mock(Callback.class);
RequestQueue queue = Volley.newRequestQueue(getActivity().getApplicationContext());
VolleyJsonPromise.jsonObjectPromise(Method.GET, SUCCESS_URL, null) | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/PlanetsActivity.java
// public class PlanetsActivity extends ActionBarActivity {
//
// private final static String EARTH = "https://farm3.staticflickr.com/2116/2222523978_f48bf28571_o.jpg";
// private final static String MARS = "https://farm6.staticflickr.com/5328/6897598788_a748a78bb8_o.png";
// private final static String VENUS = "https://farm8.staticflickr.com/7233/7302574832_ed3fa543b2_o.jpg";
//
// private TextView mProgress1, mProgress2, mProgress3, mLog;
// private Button mStart;
//
// @Override
// public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.planets_activity);
//
// mLog = (TextView) findViewById(R.id.log);
//
// mProgress1 = (TextView) findViewById(R.id.progress1);
// mProgress2 = (TextView) findViewById(R.id.progress2);
// mProgress3 = (TextView) findViewById(R.id.progress3);
//
// mStart = (Button) findViewById(R.id.start);
// mStart.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// startTasks();
// }
// });
// }
//
// private void startTasks() {
// final Promise<File> promise1 = createPromise(EARTH, "Earth", mProgress1);
// final Promise<File> promise2 = createPromise(MARS, "Mars", mProgress2);
// final Promise<File> promise3 = createPromise(VENUS, "Venus", mProgress3);
//
// DeferredObject.merge(File.class, promise1, promise2, promise3)
// .runOnUiThread()
// .onSuccess(new Callback<File[]>() {
// @Override
// public void onCallback(File[] result) {
// mStart.setText(R.string.all_done);
// mStart.setEnabled(true);
// reset(mProgress1, mProgress2, mProgress3);
// }
// })
// .onFailure(new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable result) {
// mStart.setText(R.string.failure);
// mStart.setEnabled(true);
// }
// })
// .onProgress(new Callback<Float>() {
// @Override
// public void onCallback(Float result) {
// mLog.append(" (" + result + " out of 3)");
// }
// });
//
// }
//
// private void done(TextView progress) {
// progress.getCompoundDrawables()[1].setLevel(1);
// }
//
// private void reset(TextView... progress) {
// for (TextView p : progress) {
// p.getCompoundDrawables()[1].setLevel(0);
// p.setText(R.string.no_progress);
// }
// }
//
// private Promise<File> createPromise(String url, String fileName, TextView progress) {
// try {
// return new DownloadPromise(new URL(url), getSdCardFile(fileName))
// .runOnUiThread()
// .onSuccess(successCallback(progress))
// .onFailure(failureCallback(url))
// .onProgress(TextViewUtils.setPercent(progress));
// } catch (IOException e) {
// mLog.setText("Can't mStart download " + url + " due to exception: " + e.getMessage());
// return null;
// }
// }
//
// private Callback<File> successCallback(final TextView textView) {
// return new Callback<File>() {
// @Override
// public void onCallback(File result) {
// mLog.append("\nFile stored in " + result.getPath());
// done(textView);
// }
// };
// }
//
// private Callback<Throwable> failureCallback(final String fileName) {
// return new Callback<Throwable>() {
// @Override
// public void onCallback(Throwable e) {
// mLog.append("\nFailed " + fileName + " because " + e.getClass().getName() + " " + e.getMessage());
// }
// };
// }
// }
// Path: sample/src/instrumentTest/java/org/codeandmagic/promise/volley/tests/VolleyJsonObjectTests.java
import android.test.ActivityInstrumentationTestCase2;
import com.android.volley.Request.Method;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Transformation;
import org.codeandmagic.promise.sample.PlanetsActivity;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import org.codeandmagic.promise.volley.VolleyRequest.RObject;
import org.json.JSONObject;
import static org.mockito.Mockito.*;
verify(successCallback, times(2)).onCallback(any(JSONObject.class));
verify(failureCallback, never()).onCallback(any(Throwable.class));
}
public void testFailedRequest() {
Callback<JSONObject> successCallback = mock(Callback.class);
Callback<Throwable> failureCallback = mock(Callback.class);
RequestQueue queue = Volley.newRequestQueue(getActivity().getApplicationContext());
VolleyJsonPromise.jsonObjectPromise(queue, Method.GET, FAILURE_URL, null)
.onSuccess(successCallback)
.onFailure(failureCallback);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
verify(successCallback, never()).onCallback(any(JSONObject.class));
verify(failureCallback, only()).onCallback(any(Throwable.class));
}
public void testExtendedRequest() {
Callback<JSONObject> successCallback = mock(Callback.class);
Callback<Throwable> failureCallback = mock(Callback.class);
RequestQueue queue = Volley.newRequestQueue(getActivity().getApplicationContext());
VolleyJsonPromise.jsonObjectPromise(Method.GET, SUCCESS_URL, null) | .map(new Transformation<RObject, RObject>() { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
| import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 10/02/2014.
*/
public class DeferredObject<Success> extends AbstractPromise<Success> {
public static <S> DeferredObject<S> successful(S value) {
final DeferredObject<S> deferredObject = new DeferredObject<S>();
deferredObject.success(value);
return deferredObject;
}
public static <S> DeferredObject<S> failed(Throwable value) {
final DeferredObject<S> deferredObject = new DeferredObject<S>();
deferredObject.failure(value);
return deferredObject;
}
| // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java
import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.impl;
/**
* Created by evelina on 10/02/2014.
*/
public class DeferredObject<Success> extends AbstractPromise<Success> {
public static <S> DeferredObject<S> successful(S value) {
final DeferredObject<S> deferredObject = new DeferredObject<S>();
deferredObject.success(value);
return deferredObject;
}
public static <S> DeferredObject<S> failed(Throwable value) {
final DeferredObject<S> deferredObject = new DeferredObject<S>();
deferredObject.failure(value);
return deferredObject;
}
| public static <T, S extends T> DeferredObject<T[]> merge(Class<T> clazz, Promise<S>... promises) { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
| import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise; | return new MergePromise<T, S>(clazz, allowedFailures, promises);
}
@Override
public void success(Success resolved) {
super.success(resolved);
}
@Override
public void failure(Throwable throwable) {
super.failure(throwable);
}
@Override
public void progress(Float progress) {
super.progress(progress);
}
public static class MergePromise<T, S extends T> extends DeferredObject<T[]> {
private final Promise<S>[] mPromises;
private final int mLength;
private final int mAllowedFailures;
private final Throwable[] mFailures;
private final T[] mSuccesses;
private int mCountCompleted = 0;
private int mCountFailures = 0;
| // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java
import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise;
return new MergePromise<T, S>(clazz, allowedFailures, promises);
}
@Override
public void success(Success resolved) {
super.success(resolved);
}
@Override
public void failure(Throwable throwable) {
super.failure(throwable);
}
@Override
public void progress(Float progress) {
super.progress(progress);
}
public static class MergePromise<T, S extends T> extends DeferredObject<T[]> {
private final Promise<S>[] mPromises;
private final int mLength;
private final int mAllowedFailures;
private final Throwable[] mFailures;
private final T[] mSuccesses;
private int mCountCompleted = 0;
private int mCountFailures = 0;
| private Callback<Throwable> newFailureCallback(final int index) { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
| import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise; | }
@Override
public void progress(Float progress) {
super.progress(progress);
}
public static class MergePromise<T, S extends T> extends DeferredObject<T[]> {
private final Promise<S>[] mPromises;
private final int mLength;
private final int mAllowedFailures;
private final Throwable[] mFailures;
private final T[] mSuccesses;
private int mCountCompleted = 0;
private int mCountFailures = 0;
private Callback<Throwable> newFailureCallback(final int index) {
return new Callback<Throwable>() {
@Override
public void onCallback(Throwable result) {
synchronized (MergePromise.this) {
mFailures[index] = result;
mCountCompleted++;
mCountFailures++;
MergePromise.this.progress((float) mCountCompleted);
if (mCountFailures > mAllowedFailures) { | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/MergeFailure.java
// public class MergeFailure extends Exception {
//
// public final Throwable[] mFailures;
//
// public MergeFailure(String message, Throwable[] failures) {
// super(message);
// mFailures = failures;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Promise.java
// public interface Promise<Success> extends Promise3<Success, Throwable, Float> {
//
// @Override
// public Promise<Success> onSuccess(Callback<Success> onSuccess);
//
// @Override
// public Promise<Success> onFailure(Callback<Throwable> onFailure);
//
// @Override
// public Promise<Success> onProgress(Callback<Float> onProgress);
//
// @Override
// public Promise<Success> onComplete(Callback<Either<Throwable, Success>> onComplete);
//
// @Override
// public <Success2> Promise<Success2> map(final Transformation<Success, Success2> transform);
//
// @Override
// public <Success2> Promise<Success2> flatMap(final Transformation<Success, Either<Throwable, Success2>> transform);
//
// @Override
// public Promise<Success> andThen(Callback<Success> onSuccess,
// Callback<Throwable> onFailure,
// Callback<Float> onProgress);
//
// @Override
// public Promise<Success> flatRecover(final Transformation<Throwable, Either<Throwable, Success>> transform);
//
// @Override
// public Promise<Success> recover(final Transformation<Throwable, Success> transform);
//
//
// public <Success2> Promise<Success2> pipe(final Pipe<Success, Success2> transform);
//
// public Promise<Success> recoverWith(final Pipe<Throwable, Success> transform);
//
// @Override
// public Promise<Success> runOnUiThread();
//
// /**
// * <b>IMPORTANT NOTE</b>
// * This method operates on the assumption that the Success of this Promise is an {@link java.util.Collection<T1>}.
// * If not, it will fail with a {@link ClassCastException}.
// * <p/>
// * This method creates a list of Promises by applying a {@link Pipe} to each
// * element in the {@link java.util.Collection<T1>}.
// * <p/>
// *
// * @param transform the {@link Transformation} to be applied to each element
// * @param <T1>
// * @param <T2>
// * @return
// */
// public <T1, T2> Promises<T2> split(Pipe<T1, T2> transform);
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject.java
import java.lang.reflect.Array;
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.MergeFailure;
import org.codeandmagic.promise.Promise;
}
@Override
public void progress(Float progress) {
super.progress(progress);
}
public static class MergePromise<T, S extends T> extends DeferredObject<T[]> {
private final Promise<S>[] mPromises;
private final int mLength;
private final int mAllowedFailures;
private final Throwable[] mFailures;
private final T[] mSuccesses;
private int mCountCompleted = 0;
private int mCountFailures = 0;
private Callback<Throwable> newFailureCallback(final int index) {
return new Callback<Throwable>() {
@Override
public void onCallback(Throwable result) {
synchronized (MergePromise.this) {
mFailures[index] = result;
mCountCompleted++;
mCountFailures++;
MergePromise.this.progress((float) mCountCompleted);
if (mCountFailures > mAllowedFailures) { | MergePromise.this.failure(new MergeFailure("Failed MergePromise because more than '" |
CodeAndMagic/android-deferred-object | sample/src/main/java/org/codeandmagic/promise/sample/MainActivity.java | // Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static class Sample {
// public final String title;
// public final String subtitle;
// public final Class<? extends Activity> activity;
//
// public Sample(String title, String subtitle, Class<Activity> activity) {
// this.title = title;
// this.subtitle = subtitle;
// this.activity = activity;
// }
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static List<Sample> parseSamples(Resources resources) {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(resources.openRawResource(R.raw.samples)));
// final StringBuilder json = new StringBuilder();
//
// String line;
// while ((line = reader.readLine()) != null) {
// json.append(line);
// }
// final List<Sample> samples = new ArrayList<Sample>();
// final JSONArray array = new JSONArray(json.toString());
// final int length = array.length();
// for (int i = 0; i < length; ++i) {
// samples.add(parseSample(array.getJSONObject(i)));
// }
// return samples;
//
// } catch (Exception e) {
// Log.e("PROMISE", "Can't parse the samples!", e);
// return Collections.emptyList();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TwoLineListItem;
import java.util.List;
import static org.codeandmagic.promise.sample.Utils.Sample;
import static org.codeandmagic.promise.sample.Utils.parseSamples; | package org.codeandmagic.promise.sample;
/**
* Created by evelina on 05/03/2014.
*/
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final ListView listView = (ListView) findViewById(android.R.id.list); | // Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static class Sample {
// public final String title;
// public final String subtitle;
// public final Class<? extends Activity> activity;
//
// public Sample(String title, String subtitle, Class<Activity> activity) {
// this.title = title;
// this.subtitle = subtitle;
// this.activity = activity;
// }
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static List<Sample> parseSamples(Resources resources) {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(resources.openRawResource(R.raw.samples)));
// final StringBuilder json = new StringBuilder();
//
// String line;
// while ((line = reader.readLine()) != null) {
// json.append(line);
// }
// final List<Sample> samples = new ArrayList<Sample>();
// final JSONArray array = new JSONArray(json.toString());
// final int length = array.length();
// for (int i = 0; i < length; ++i) {
// samples.add(parseSample(array.getJSONObject(i)));
// }
// return samples;
//
// } catch (Exception e) {
// Log.e("PROMISE", "Can't parse the samples!", e);
// return Collections.emptyList();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
// Path: sample/src/main/java/org/codeandmagic/promise/sample/MainActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TwoLineListItem;
import java.util.List;
import static org.codeandmagic.promise.sample.Utils.Sample;
import static org.codeandmagic.promise.sample.Utils.parseSamples;
package org.codeandmagic.promise.sample;
/**
* Created by evelina on 05/03/2014.
*/
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final ListView listView = (ListView) findViewById(android.R.id.list); | listView.setAdapter(new DemoAdapter(this, parseSamples(getResources()))); |
CodeAndMagic/android-deferred-object | sample/src/main/java/org/codeandmagic/promise/sample/MainActivity.java | // Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static class Sample {
// public final String title;
// public final String subtitle;
// public final Class<? extends Activity> activity;
//
// public Sample(String title, String subtitle, Class<Activity> activity) {
// this.title = title;
// this.subtitle = subtitle;
// this.activity = activity;
// }
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static List<Sample> parseSamples(Resources resources) {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(resources.openRawResource(R.raw.samples)));
// final StringBuilder json = new StringBuilder();
//
// String line;
// while ((line = reader.readLine()) != null) {
// json.append(line);
// }
// final List<Sample> samples = new ArrayList<Sample>();
// final JSONArray array = new JSONArray(json.toString());
// final int length = array.length();
// for (int i = 0; i < length; ++i) {
// samples.add(parseSample(array.getJSONObject(i)));
// }
// return samples;
//
// } catch (Exception e) {
// Log.e("PROMISE", "Can't parse the samples!", e);
// return Collections.emptyList();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
| import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TwoLineListItem;
import java.util.List;
import static org.codeandmagic.promise.sample.Utils.Sample;
import static org.codeandmagic.promise.sample.Utils.parseSamples; | package org.codeandmagic.promise.sample;
/**
* Created by evelina on 05/03/2014.
*/
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(new DemoAdapter(this, parseSamples(getResources())));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | // Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static class Sample {
// public final String title;
// public final String subtitle;
// public final Class<? extends Activity> activity;
//
// public Sample(String title, String subtitle, Class<Activity> activity) {
// this.title = title;
// this.subtitle = subtitle;
// this.activity = activity;
// }
// }
//
// Path: sample/src/main/java/org/codeandmagic/promise/sample/Utils.java
// public static List<Sample> parseSamples(Resources resources) {
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new InputStreamReader(resources.openRawResource(R.raw.samples)));
// final StringBuilder json = new StringBuilder();
//
// String line;
// while ((line = reader.readLine()) != null) {
// json.append(line);
// }
// final List<Sample> samples = new ArrayList<Sample>();
// final JSONArray array = new JSONArray(json.toString());
// final int length = array.length();
// for (int i = 0; i < length; ++i) {
// samples.add(parseSample(array.getJSONObject(i)));
// }
// return samples;
//
// } catch (Exception e) {
// Log.e("PROMISE", "Can't parse the samples!", e);
// return Collections.emptyList();
// } finally {
// if (reader != null) {
// try {
// reader.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// }
// Path: sample/src/main/java/org/codeandmagic/promise/sample/MainActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TwoLineListItem;
import java.util.List;
import static org.codeandmagic.promise.sample.Utils.Sample;
import static org.codeandmagic.promise.sample.Utils.parseSamples;
package org.codeandmagic.promise.sample;
/**
* Created by evelina on 05/03/2014.
*/
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
final ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(new DemoAdapter(this, parseSamples(getResources())));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | startActivity(new Intent(MainActivity.this, ((Sample) parent.getItemAtPosition(position)).activity)); |
CodeAndMagic/android-deferred-object | core/src/test/java/org/codeandmagic/promise/tests/CallbackTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
| import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*; | /*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class CallbackTests {
@Test
public void testCallbacks() { | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
// Path: core/src/test/java/org/codeandmagic/promise/tests/CallbackTests.java
import org.codeandmagic.promise.Callback;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
/*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class CallbackTests {
@Test
public void testCallbacks() { | DeferredObject3<Integer, Void, Void> promise = new DeferredObject3<Integer, Void, Void>(); |
CodeAndMagic/android-deferred-object | core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
| import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*; | /*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try { | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
// Path: core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
/*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try { | return new Right<Throwable, Integer>(Integer.parseInt(value)); |
CodeAndMagic/android-deferred-object | core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
| import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*; | /*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try {
return new Right<Throwable, Integer>(Integer.parseInt(value));
} catch (NumberFormatException e) { | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
// Path: core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
/*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try {
return new Right<Throwable, Integer>(Integer.parseInt(value));
} catch (NumberFormatException e) { | return new Left<Throwable, Integer>(e); |
CodeAndMagic/android-deferred-object | core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
| import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*; | /*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try {
return new Right<Throwable, Integer>(Integer.parseInt(value));
} catch (NumberFormatException e) {
return new Left<Throwable, Integer>(e);
}
}
};
@Test
public void testMapSuccess() {
Callback<String> onSuccess = mock(Callback.class); | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/impl/DeferredObject3.java
// public class DeferredObject3<Success, Failure, Progress> extends AbstractPromise3<Success, Failure, Progress> {
//
// public static <S, F, P> DeferredObject3<S, F, P> successful(S value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.success(value);
// return deferredObject;
// }
//
// public static <S, F, P> DeferredObject3<S, F, P> failed(F value) {
// final DeferredObject3<S, F, P> deferredObject = new DeferredObject3<S, F, P>();
// deferredObject.failure(value);
// return deferredObject;
// }
//
// @Override
// public final void progress(Progress progress) {
// super.progress(progress);
// }
//
// @Override
// public final void success(Success resolved) {
// super.success(resolved);
// }
//
// @Override
// public final void failure(Failure failure) {
// super.failure(failure);
// }
// }
// Path: core/src/test/java/org/codeandmagic/promise/tests/TransformationTests.java
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.impl.DeferredObject3;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
/*
* Copyright (c) 2014 Cristian Vrabie, Evelina Vrabie.
*
* This file is part of android-promise.
* android-deferred-object is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with android-promise
* If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.tests;
/**
* Created by cristian on 10/02/2014.
*/
@RunWith(JUnit4.class)
public class TransformationTests {
private Transformation<Integer, String> intToString = new Transformation<Integer, String>() {
@Override
public String transform(Integer success) {
return (success * 2) + "!";
}
};
private Transformation<String, Either<Throwable, Integer>> stringToInt = new Transformation<String, Either<Throwable,Integer>>() {
@Override
public Either<Throwable, Integer> transform(String value) {
try {
return new Right<Throwable, Integer>(Integer.parseInt(value));
} catch (NumberFormatException e) {
return new Left<Throwable, Integer>(e);
}
}
};
@Test
public void testMapSuccess() {
Callback<String> onSuccess = mock(Callback.class); | DeferredObject3<Integer, Void, Void> promise = new DeferredObject3<Integer, Void, Void>(); |
CodeAndMagic/android-deferred-object | sample/src/main/java/org/codeandmagic/promise/sample/patterns/PatternsActivity.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
| import org.codeandmagic.promise.sample.R;
import org.codeandmagic.promise.volley.BitmapLruCache;
import org.codeandmagic.promise.volley.ImageResult;
import org.codeandmagic.promise.volley.VolleyImagePromise;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import static org.codeandmagic.promise.Either.trying;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley; | }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.patterns_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mAdapter == null) {
mRequestQueue = Volley.newRequestQueue(getActivity());
mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache());
mAdapter = new ImageAdapter(getActivity());
((GridView) getView().findViewById(R.id.grid)).setAdapter(mAdapter);
doMagic();
} else {
((GridView) getView().findViewById(R.id.grid)).setAdapter(mAdapter);
}
}
/**
* The ENTIRE code needed to:
* 1. Retrieve a JSON
* 2. Parse the JSON and for each element which contains an URL
* 2.1. Download an image and add it to the GridView adapter
*/
private void doMagic() {
VolleyJsonPromise
.jsonArrayPromise(mRequestQueue, URL) | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
// Path: sample/src/main/java/org/codeandmagic/promise/sample/patterns/PatternsActivity.java
import org.codeandmagic.promise.sample.R;
import org.codeandmagic.promise.volley.BitmapLruCache;
import org.codeandmagic.promise.volley.ImageResult;
import org.codeandmagic.promise.volley.VolleyImagePromise;
import org.codeandmagic.promise.volley.VolleyJsonPromise;
import static org.codeandmagic.promise.Either.trying;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.patterns_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mAdapter == null) {
mRequestQueue = Volley.newRequestQueue(getActivity());
mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache());
mAdapter = new ImageAdapter(getActivity());
((GridView) getView().findViewById(R.id.grid)).setAdapter(mAdapter);
doMagic();
} else {
((GridView) getView().findViewById(R.id.grid)).setAdapter(mAdapter);
}
}
/**
* The ENTIRE code needed to:
* 1. Retrieve a JSON
* 2. Parse the JSON and for each element which contains an URL
* 2.1. Download an image and add it to the GridView adapter
*/
private void doMagic() {
VolleyJsonPromise
.jsonArrayPromise(mRequestQueue, URL) | .flatMap(value -> trying(() -> PatternDeserializer.getInstance().deserialize(value))) |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/http/StatusCodeSelector.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
| import org.apache.http.HttpResponse;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.Transformation;
import java.util.Arrays; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.http;
/**
* Created by evelina on 26/02/2014.
*/
public abstract class StatusCodeSelector implements Transformation<HttpResponse, Either<Throwable, HttpResponse>> {
public abstract boolean isAcceptable(int statusCode);
@Override
public Either<Throwable, HttpResponse> transform(HttpResponse value) {
final int statusCode = value.getStatusLine().getStatusCode(); | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
// Path: core/src/main/java/org/codeandmagic/promise/http/StatusCodeSelector.java
import org.apache.http.HttpResponse;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.Transformation;
import java.util.Arrays;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.http;
/**
* Created by evelina on 26/02/2014.
*/
public abstract class StatusCodeSelector implements Transformation<HttpResponse, Either<Throwable, HttpResponse>> {
public abstract boolean isAcceptable(int statusCode);
@Override
public Either<Throwable, HttpResponse> transform(HttpResponse value) {
final int statusCode = value.getStatusLine().getStatusCode(); | return isAcceptable(statusCode) ? new Right<Throwable, HttpResponse>(value) : |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/http/StatusCodeSelector.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
| import org.apache.http.HttpResponse;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.Transformation;
import java.util.Arrays; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.http;
/**
* Created by evelina on 26/02/2014.
*/
public abstract class StatusCodeSelector implements Transformation<HttpResponse, Either<Throwable, HttpResponse>> {
public abstract boolean isAcceptable(int statusCode);
@Override
public Either<Throwable, HttpResponse> transform(HttpResponse value) {
final int statusCode = value.getStatusLine().getStatusCode();
return isAcceptable(statusCode) ? new Right<Throwable, HttpResponse>(value) : | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public abstract class Either<T1, T2> {
//
// public static interface F0<T1> {
// T1 apply() throws Exception;
// }
//
// public static <T1> Either<Throwable, T1> trying(F0<T1> block) {
// try {
// return new Right<>(block.apply());
// } catch (Throwable e) {
// return new Left<>(e);
// }
// }
//
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
//
// public boolean isLeft() {
// return false;
// }
//
// public T1 getLeft() {
// return null;
// }
//
// public boolean isRight() {
// return false;
// }
//
// public T2 getRight() {
// return null;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Transformation.java
// public interface Transformation<T1, T2> {
//
// T2 transform(T1 value);
//
// }
// Path: core/src/main/java/org/codeandmagic/promise/http/StatusCodeSelector.java
import org.apache.http.HttpResponse;
import org.codeandmagic.promise.Either;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import org.codeandmagic.promise.Transformation;
import java.util.Arrays;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.http;
/**
* Created by evelina on 26/02/2014.
*/
public abstract class StatusCodeSelector implements Transformation<HttpResponse, Either<Throwable, HttpResponse>> {
public abstract boolean isAcceptable(int statusCode);
@Override
public Either<Throwable, HttpResponse> transform(HttpResponse value) {
final int statusCode = value.getStatusLine().getStatusCode();
return isAcceptable(statusCode) ? new Right<Throwable, HttpResponse>(value) : | new Left<Throwable, HttpResponse>(new IllegalStateException("Expecting status code '" + toString() |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/util/TextViewUtils.java | // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
| import android.widget.TextView;
import org.codeandmagic.promise.Callback; | /*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.util;
/**
* Created by evelina on 24/02/2014.
*/
public final class TextViewUtils {
private TextViewUtils() {
}
| // Path: core/src/main/java/org/codeandmagic/promise/Callback.java
// public interface Callback<T> {
//
// void onCallback(final T result);
// }
// Path: core/src/main/java/org/codeandmagic/promise/util/TextViewUtils.java
import android.widget.TextView;
import org.codeandmagic.promise.Callback;
/*
* Copyright (c) 2014 CodeAndMagic
* Cristian Vrabie, Evelina Vrabie
*
* This file is part of android-promise.
* android-promise is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License,or (at your option)
* any later version.
*
* android-promise is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with android-promise. If not, see <http://www.gnu.org/licenses/>.
*/
package org.codeandmagic.promise.util;
/**
* Created by evelina on 24/02/2014.
*/
public final class TextViewUtils {
private TextViewUtils() {
}
| public static Callback<Float> setPercent(final TextView textView) { |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/AbstractPromise3.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
| import android.os.Handler;
import android.os.Looper;
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; | triggerCompleted();
for (final Callback<Success> s : mSuccessCallbacks) {
s.onCallback(mResult);
}
}
protected void failure(final Failure failure) {
if (mState == State.PENDING) {
this.mFailure = failure;
this.mState = State.FAILED;
triggerFailure();
} else {
throw new IllegalStateException("Can't fail a Promise3 which is in mState '" + mState.name() + "'.");
}
}
protected final void triggerFailure() {
triggerCompleted();
for (final Callback<Failure> f : mFailureCallbacks) {
f.onCallback(mFailure);
}
}
protected final void complete(Either<Failure, Success> either) {
if (either.isLeft()) failure(either.getLeft());
else success(either.getRight());
}
protected final void triggerCompleted() {
for (final Callback<Either<Failure, Success>> c : mCompleteCallbacks) { | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/AbstractPromise3.java
import android.os.Handler;
import android.os.Looper;
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
triggerCompleted();
for (final Callback<Success> s : mSuccessCallbacks) {
s.onCallback(mResult);
}
}
protected void failure(final Failure failure) {
if (mState == State.PENDING) {
this.mFailure = failure;
this.mState = State.FAILED;
triggerFailure();
} else {
throw new IllegalStateException("Can't fail a Promise3 which is in mState '" + mState.name() + "'.");
}
}
protected final void triggerFailure() {
triggerCompleted();
for (final Callback<Failure> f : mFailureCallbacks) {
f.onCallback(mFailure);
}
}
protected final void complete(Either<Failure, Success> either) {
if (either.isLeft()) failure(either.getLeft());
else success(either.getRight());
}
protected final void triggerCompleted() {
for (final Callback<Either<Failure, Success>> c : mCompleteCallbacks) { | c.onCallback(isSuccess() ? new Right<Failure, Success>(mResult) : new Left<Failure, Success>(mFailure)); |
CodeAndMagic/android-deferred-object | core/src/main/java/org/codeandmagic/promise/impl/AbstractPromise3.java | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
| import android.os.Handler;
import android.os.Looper;
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; | triggerCompleted();
for (final Callback<Success> s : mSuccessCallbacks) {
s.onCallback(mResult);
}
}
protected void failure(final Failure failure) {
if (mState == State.PENDING) {
this.mFailure = failure;
this.mState = State.FAILED;
triggerFailure();
} else {
throw new IllegalStateException("Can't fail a Promise3 which is in mState '" + mState.name() + "'.");
}
}
protected final void triggerFailure() {
triggerCompleted();
for (final Callback<Failure> f : mFailureCallbacks) {
f.onCallback(mFailure);
}
}
protected final void complete(Either<Failure, Success> either) {
if (either.isLeft()) failure(either.getLeft());
else success(either.getRight());
}
protected final void triggerCompleted() {
for (final Callback<Either<Failure, Success>> c : mCompleteCallbacks) { | // Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Left<T1, T2> extends Either<T1, T2> {
//
// private final T1 left;
//
// public Left(T1 left) {
// this.left = left;
// }
//
// @Override
// public boolean isLeft() {
// return true;
// }
//
// @Override
// public T1 getLeft() {
// return left;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Left left1 = (Left) o;
//
// if (left != null ? !left.equals(left1.left) : left1.left != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return left != null ? left.hashCode() : 0;
// }
// }
//
// Path: core/src/main/java/org/codeandmagic/promise/Either.java
// public static final class Right<T1, T2> extends Either<T1, T2> {
//
// private final T2 right;
//
// public Right(T2 right) {
// this.right = right;
// }
//
// @Override
// public boolean isRight() {
// return true;
// }
//
// @Override
// public T2 getRight() {
// return right;
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// Right right1 = (Right) o;
//
// if (right != null ? !right.equals(right1.right) : right1.right != null) return false;
//
// return true;
// }
//
// @Override
// public int hashCode() {
// return right != null ? right.hashCode() : 0;
// }
// }
// Path: core/src/main/java/org/codeandmagic/promise/impl/AbstractPromise3.java
import android.os.Handler;
import android.os.Looper;
import org.codeandmagic.promise.*;
import org.codeandmagic.promise.Either.Left;
import org.codeandmagic.promise.Either.Right;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
triggerCompleted();
for (final Callback<Success> s : mSuccessCallbacks) {
s.onCallback(mResult);
}
}
protected void failure(final Failure failure) {
if (mState == State.PENDING) {
this.mFailure = failure;
this.mState = State.FAILED;
triggerFailure();
} else {
throw new IllegalStateException("Can't fail a Promise3 which is in mState '" + mState.name() + "'.");
}
}
protected final void triggerFailure() {
triggerCompleted();
for (final Callback<Failure> f : mFailureCallbacks) {
f.onCallback(mFailure);
}
}
protected final void complete(Either<Failure, Success> either) {
if (either.isLeft()) failure(either.getLeft());
else success(either.getRight());
}
protected final void triggerCompleted() {
for (final Callback<Either<Failure, Success>> c : mCompleteCallbacks) { | c.onCallback(isSuccess() ? new Right<Failure, Success>(mResult) : new Left<Failure, Success>(mFailure)); |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/support/archiver/Archiver.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
| import br.com.trustsystems.elfinder.core.Target;
import java.io.IOException; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Archiver interface.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public interface Archiver {
/**
* Gets the archive name.
*
* @return the archive name
*/
String getArchiveName();
/**
* Gets the archive mimetype.
*
* @return the archive mimetype
*/
String getMimeType();
/**
* Gets the archive extension.
*
* @return the archive extension
*/
String getExtension();
/**
* Creates the compress archive for the given targets.
*
* @param targets the targets to compress.
* @return the target of the compress archive.
* @throws IOException if something goes wrong.
*/ | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
// Path: src/main/java/br/com/trustsystems/elfinder/support/archiver/Archiver.java
import br.com.trustsystems.elfinder.core.Target;
import java.io.IOException;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Archiver interface.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public interface Archiver {
/**
* Gets the archive name.
*
* @return the archive name
*/
String getArchiveName();
/**
* Gets the archive mimetype.
*
* @return the archive mimetype
*/
String getMimeType();
/**
* Gets the archive extension.
*
* @return the archive extension
*/
String getExtension();
/**
* Creates the compress archive for the given targets.
*
* @param targets the targets to compress.
* @return the target of the compress archive.
* @throws IOException if something goes wrong.
*/ | Target compress(Target... targets) throws IOException; |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/support/archiver/ZipArchiver.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry; | return ".zip";
}
@Override
public ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetBytes) {
ZipArchiveEntry zipEntry = new ZipArchiveEntry(targetPath);
zipEntry.setSize(targetSize);
zipEntry.setMethod(ZipEntry.STORED);
if (targetBytes != null) {
zipEntry.setCrc(crc32Checksum(targetBytes));
}
return zipEntry;
}
@Override
public ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) {
return new ZipArchiveOutputStream(bufferedOutputStream);
}
// for some internal optimizations should use the constructor that accepts a File argument
public ArchiveOutputStream createArchiveOutputStream(Path path) throws IOException {
return new ZipArchiveOutputStream(path.toFile());
}
@Override
public ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException {
return new ZipArchiveInputStream(bufferedInputStream);
}
@Override | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
// Path: src/main/java/br/com/trustsystems/elfinder/support/archiver/ZipArchiver.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
return ".zip";
}
@Override
public ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetBytes) {
ZipArchiveEntry zipEntry = new ZipArchiveEntry(targetPath);
zipEntry.setSize(targetSize);
zipEntry.setMethod(ZipEntry.STORED);
if (targetBytes != null) {
zipEntry.setCrc(crc32Checksum(targetBytes));
}
return zipEntry;
}
@Override
public ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) {
return new ZipArchiveOutputStream(bufferedOutputStream);
}
// for some internal optimizations should use the constructor that accepts a File argument
public ArchiveOutputStream createArchiveOutputStream(Path path) throws IOException {
return new ZipArchiveOutputStream(path.toFile());
}
@Override
public ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException {
return new ZipArchiveInputStream(bufferedInputStream);
}
@Override | public Target compress(Target... targets) throws IOException { |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/support/archiver/ZipArchiver.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry; | }
return zipEntry;
}
@Override
public ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) {
return new ZipArchiveOutputStream(bufferedOutputStream);
}
// for some internal optimizations should use the constructor that accepts a File argument
public ArchiveOutputStream createArchiveOutputStream(Path path) throws IOException {
return new ZipArchiveOutputStream(path.toFile());
}
@Override
public ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException {
return new ZipArchiveInputStream(bufferedInputStream);
}
@Override
public Target compress(Target... targets) throws IOException {
Target compressTarget = null;
Path compressFile = null;
ArchiveOutputStream archiveOutputStream = null;
try {
for (Target target : targets) {
// get target volume | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
// Path: src/main/java/br/com/trustsystems/elfinder/support/archiver/ZipArchiver.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
}
return zipEntry;
}
@Override
public ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) {
return new ZipArchiveOutputStream(bufferedOutputStream);
}
// for some internal optimizations should use the constructor that accepts a File argument
public ArchiveOutputStream createArchiveOutputStream(Path path) throws IOException {
return new ZipArchiveOutputStream(path.toFile());
}
@Override
public ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException {
return new ZipArchiveInputStream(bufferedInputStream);
}
@Override
public Target compress(Target... targets) throws IOException {
Target compressTarget = null;
Path compressFile = null;
ArchiveOutputStream archiveOutputStream = null;
try {
for (Target target : targets) {
// get target volume | final Volume targetVolume = target.getVolume(); |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/command/CommandFactory.java | // Path: src/main/java/br/com/trustsystems/elfinder/support/concurrency/GenericCache.java
// public class GenericCache<K, V> {
//
// private final ConcurrentMap<K, Future<V>> cache = new ConcurrentHashMap<>();
//
// private Future<V> createFutureIfAbsent(final K key, final Callable<V> callable) {
// Future<V> future = cache.get(key);
// if (future == null) {
// final FutureTask<V> futureTask = new FutureTask<>(callable);
// future = cache.putIfAbsent(key, futureTask);
// if (future == null) {
// future = futureTask;
// futureTask.run();
// }
// }
// return future;
// }
//
// public V getValue(final K key, final Callable<V> callable) throws InterruptedException, ExecutionException {
// try {
// final Future<V> future = createFutureIfAbsent(key, callable);
// return future.get();
// } catch (final InterruptedException | ExecutionException | RuntimeException e) {
// cache.remove(key);
// throw e;
// }
// }
//
// public void setValueIfAbsent(final K key, final V value) {
// createFutureIfAbsent(key, new Callable<V>() {
// @Override
// public V call() throws Exception {
// return value;
// }
// });
// }
//
// public void removeValue(final K key) {
// cache.remove(key);
// }
// }
| import br.com.trustsystems.elfinder.support.concurrency.GenericCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.command;
public class CommandFactory implements ElfinderCommandFactory {
private static final Logger logger = LoggerFactory.getLogger(CommandFactory.class);
private String classNamePattern;
| // Path: src/main/java/br/com/trustsystems/elfinder/support/concurrency/GenericCache.java
// public class GenericCache<K, V> {
//
// private final ConcurrentMap<K, Future<V>> cache = new ConcurrentHashMap<>();
//
// private Future<V> createFutureIfAbsent(final K key, final Callable<V> callable) {
// Future<V> future = cache.get(key);
// if (future == null) {
// final FutureTask<V> futureTask = new FutureTask<>(callable);
// future = cache.putIfAbsent(key, futureTask);
// if (future == null) {
// future = futureTask;
// futureTask.run();
// }
// }
// return future;
// }
//
// public V getValue(final K key, final Callable<V> callable) throws InterruptedException, ExecutionException {
// try {
// final Future<V> future = createFutureIfAbsent(key, callable);
// return future.get();
// } catch (final InterruptedException | ExecutionException | RuntimeException e) {
// cache.remove(key);
// throw e;
// }
// }
//
// public void setValueIfAbsent(final K key, final V value) {
// createFutureIfAbsent(key, new Callable<V>() {
// @Override
// public V call() throws Exception {
// return value;
// }
// });
// }
//
// public void removeValue(final K key) {
// cache.remove(key);
// }
// }
// Path: src/main/java/br/com/trustsystems/elfinder/command/CommandFactory.java
import br.com.trustsystems.elfinder.support.concurrency.GenericCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.command;
public class CommandFactory implements ElfinderCommandFactory {
private static final Logger logger = LoggerFactory.getLogger(CommandFactory.class);
private String classNamePattern;
| private final GenericCache<String, ElfinderCommand> cache = new GenericCache<>(); |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/command/FileCommand.java | // Path: src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java
// public interface ElfinderStorage {
//
// Target fromHash(String hash);
//
// String getHash(Target target) throws IOException;
//
// String getVolumeId(Volume volume);
//
// Locale getVolumeLocale(Volume volume);
//
// VolumeSecurity getVolumeSecurity(Target target);
//
// List<Volume> getVolumes();
//
// List<VolumeSecurity> getVolumeSecurities();
//
// ThumbnailWidth getThumbnailWidth();
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/service/VolumeHandler.java
// public class VolumeHandler {
//
// private final Volume volume;
// private final Target target;
// private final VolumeSecurity volumeSecurity;
// private final ElfinderStorage elfinderStorage;
//
// public VolumeHandler(Target target, ElfinderStorage elfinderStorage) {
// this.target = target;
// this.volume = target.getVolume();
// this.volumeSecurity = elfinderStorage.getVolumeSecurity(target);
// this.elfinderStorage = elfinderStorage;
// }
//
// public VolumeHandler(VolumeHandler parent, String name) throws IOException {
// this.volume = parent.volume;
// this.elfinderStorage = parent.elfinderStorage;
// this.target = volume.fromPath(volume.getPath(parent.target) + ElFinderConstants.ELFINDER_PARAMETER_FILE_SEPARATOR + name);
// this.volumeSecurity = elfinderStorage.getVolumeSecurity(target);
// }
//
// public void createFile() throws IOException {
// volume.createFile(target);
// }
//
// public void createFolder() throws IOException {
// volume.createFolder(target);
// }
//
// public void delete() throws IOException {
// if (volume.isFolder(target)) {
// volume.deleteFolder(target);
// } else {
// volume.deleteFile(target);
// }
// }
//
// public boolean exists() {
// return volume.exists(target);
// }
//
// public String getHash() throws IOException {
// return elfinderStorage.getHash(target);
// }
//
// public long getLastModified() throws IOException {
// return volume.getLastModified(target);
// }
//
// public String getMimeType() throws IOException {
// return volume.getMimeType(target);
// }
//
// public String getName() {
// return volume.getName(target);
// }
//
// public VolumeHandler getParent() {
// return new VolumeHandler(volume.getParent(target), elfinderStorage);
// }
//
// public long getSize() throws IOException {
// return volume.getSize(target);
// }
//
// public String getVolumeId() {
// return elfinderStorage.getVolumeId(volume);
// }
//
// public boolean hasChildFolder() throws IOException {
// return volume.hasChildFolder(target);
// }
//
// public boolean isFolder() {
// return volume.isFolder(target);
// }
//
// public boolean isLocked() {
// return this.volumeSecurity.getSecurityConstraint().isLocked();
// }
//
// public boolean isReadable() {
// return this.volumeSecurity.getSecurityConstraint().isReadable();
// }
//
// public boolean isWritable() {
// return this.volumeSecurity.getSecurityConstraint().isWritable();
// }
//
// public boolean isRoot() throws IOException {
// return volume.isRoot(target);
// }
//
// public List<VolumeHandler> listChildren() throws IOException {
// List<VolumeHandler> list = new ArrayList<>();
// for (Target child : volume.listChildren(target)) {
// list.add(new VolumeHandler(child, elfinderStorage));
// }
// return list;
// }
//
// public InputStream openInputStream() throws IOException {
// return volume.openInputStream(target);
// }
//
// public OutputStream openOutputStream() throws IOException {
// return volume.openOutputStream(target);
// }
//
// public void renameTo(VolumeHandler dst) throws IOException {
// volume.rename(target, dst.target);
// }
//
// public String getVolumeAlias() {
// return volume.getAlias();
// }
// }
| import br.com.trustsystems.elfinder.service.ElfinderStorage;
import br.com.trustsystems.elfinder.service.VolumeHandler;
import org.apache.commons.io.IOUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.command;
public class FileCommand extends AbstractCommand implements ElfinderCommand {
public static final String STREAM = "1";
@Override | // Path: src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java
// public interface ElfinderStorage {
//
// Target fromHash(String hash);
//
// String getHash(Target target) throws IOException;
//
// String getVolumeId(Volume volume);
//
// Locale getVolumeLocale(Volume volume);
//
// VolumeSecurity getVolumeSecurity(Target target);
//
// List<Volume> getVolumes();
//
// List<VolumeSecurity> getVolumeSecurities();
//
// ThumbnailWidth getThumbnailWidth();
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/service/VolumeHandler.java
// public class VolumeHandler {
//
// private final Volume volume;
// private final Target target;
// private final VolumeSecurity volumeSecurity;
// private final ElfinderStorage elfinderStorage;
//
// public VolumeHandler(Target target, ElfinderStorage elfinderStorage) {
// this.target = target;
// this.volume = target.getVolume();
// this.volumeSecurity = elfinderStorage.getVolumeSecurity(target);
// this.elfinderStorage = elfinderStorage;
// }
//
// public VolumeHandler(VolumeHandler parent, String name) throws IOException {
// this.volume = parent.volume;
// this.elfinderStorage = parent.elfinderStorage;
// this.target = volume.fromPath(volume.getPath(parent.target) + ElFinderConstants.ELFINDER_PARAMETER_FILE_SEPARATOR + name);
// this.volumeSecurity = elfinderStorage.getVolumeSecurity(target);
// }
//
// public void createFile() throws IOException {
// volume.createFile(target);
// }
//
// public void createFolder() throws IOException {
// volume.createFolder(target);
// }
//
// public void delete() throws IOException {
// if (volume.isFolder(target)) {
// volume.deleteFolder(target);
// } else {
// volume.deleteFile(target);
// }
// }
//
// public boolean exists() {
// return volume.exists(target);
// }
//
// public String getHash() throws IOException {
// return elfinderStorage.getHash(target);
// }
//
// public long getLastModified() throws IOException {
// return volume.getLastModified(target);
// }
//
// public String getMimeType() throws IOException {
// return volume.getMimeType(target);
// }
//
// public String getName() {
// return volume.getName(target);
// }
//
// public VolumeHandler getParent() {
// return new VolumeHandler(volume.getParent(target), elfinderStorage);
// }
//
// public long getSize() throws IOException {
// return volume.getSize(target);
// }
//
// public String getVolumeId() {
// return elfinderStorage.getVolumeId(volume);
// }
//
// public boolean hasChildFolder() throws IOException {
// return volume.hasChildFolder(target);
// }
//
// public boolean isFolder() {
// return volume.isFolder(target);
// }
//
// public boolean isLocked() {
// return this.volumeSecurity.getSecurityConstraint().isLocked();
// }
//
// public boolean isReadable() {
// return this.volumeSecurity.getSecurityConstraint().isReadable();
// }
//
// public boolean isWritable() {
// return this.volumeSecurity.getSecurityConstraint().isWritable();
// }
//
// public boolean isRoot() throws IOException {
// return volume.isRoot(target);
// }
//
// public List<VolumeHandler> listChildren() throws IOException {
// List<VolumeHandler> list = new ArrayList<>();
// for (Target child : volume.listChildren(target)) {
// list.add(new VolumeHandler(child, elfinderStorage));
// }
// return list;
// }
//
// public InputStream openInputStream() throws IOException {
// return volume.openInputStream(target);
// }
//
// public OutputStream openOutputStream() throws IOException {
// return volume.openOutputStream(target);
// }
//
// public void renameTo(VolumeHandler dst) throws IOException {
// volume.rename(target, dst.target);
// }
//
// public String getVolumeAlias() {
// return volume.getAlias();
// }
// }
// Path: src/main/java/br/com/trustsystems/elfinder/command/FileCommand.java
import br.com.trustsystems.elfinder.service.ElfinderStorage;
import br.com.trustsystems.elfinder.service.VolumeHandler;
import org.apache.commons.io.IOUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.command;
public class FileCommand extends AbstractCommand implements ElfinderCommand {
public static final String STREAM = "1";
@Override | public void execute(ElfinderStorage elfinderStorage, HttpServletRequest request, HttpServletResponse response) throws Exception { |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/support/archiver/AbstractArchiver.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Abstract Archiver defines some archive behaviors and this class has some
* convenient methods. This class must be extended by concrete archive
* implementations.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public abstract class AbstractArchiver implements Archiver {
public static final String DEFAULT_ARCHIVE_NAME = "Archive";
private AtomicInteger count = new AtomicInteger(1);
/**
* Defines how to create a archive inputstream.
*
* @param bufferedInputStream the inputstream.
* @return the archive inputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException;
/**
* Defines how to create a archive outputstream.
*
* @param bufferedOutputStream the outputstream.
* @return the archive outputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) throws IOException;
/**
* Defines how to create a archive entry.
*
* @param targetPath the target path.
* @param targetSize the target size.
* @param targetContent the target bytes.
* @return the archive entry.
*/
public abstract ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetContent);
@Override
public String getArchiveName() {
return DEFAULT_ARCHIVE_NAME;
}
/**
* Default compress implementation used by .tar and .tgz
*
* @return the compress archive target.
*/
@Override | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
// Path: src/main/java/br/com/trustsystems/elfinder/support/archiver/AbstractArchiver.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Abstract Archiver defines some archive behaviors and this class has some
* convenient methods. This class must be extended by concrete archive
* implementations.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public abstract class AbstractArchiver implements Archiver {
public static final String DEFAULT_ARCHIVE_NAME = "Archive";
private AtomicInteger count = new AtomicInteger(1);
/**
* Defines how to create a archive inputstream.
*
* @param bufferedInputStream the inputstream.
* @return the archive inputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException;
/**
* Defines how to create a archive outputstream.
*
* @param bufferedOutputStream the outputstream.
* @return the archive outputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) throws IOException;
/**
* Defines how to create a archive entry.
*
* @param targetPath the target path.
* @param targetSize the target size.
* @param targetContent the target bytes.
* @return the archive entry.
*/
public abstract ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetContent);
@Override
public String getArchiveName() {
return DEFAULT_ARCHIVE_NAME;
}
/**
* Default compress implementation used by .tar and .tgz
*
* @return the compress archive target.
*/
@Override | public Target compress(Target... targets) throws IOException { |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/support/archiver/AbstractArchiver.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Abstract Archiver defines some archive behaviors and this class has some
* convenient methods. This class must be extended by concrete archive
* implementations.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public abstract class AbstractArchiver implements Archiver {
public static final String DEFAULT_ARCHIVE_NAME = "Archive";
private AtomicInteger count = new AtomicInteger(1);
/**
* Defines how to create a archive inputstream.
*
* @param bufferedInputStream the inputstream.
* @return the archive inputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException;
/**
* Defines how to create a archive outputstream.
*
* @param bufferedOutputStream the outputstream.
* @return the archive outputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) throws IOException;
/**
* Defines how to create a archive entry.
*
* @param targetPath the target path.
* @param targetSize the target size.
* @param targetContent the target bytes.
* @return the archive entry.
*/
public abstract ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetContent);
@Override
public String getArchiveName() {
return DEFAULT_ARCHIVE_NAME;
}
/**
* Default compress implementation used by .tar and .tgz
*
* @return the compress archive target.
*/
@Override
public Target compress(Target... targets) throws IOException {
Target compressTarget = null;
OutputStream outputStream = null;
BufferedOutputStream bufferedOutputStream = null;
ArchiveOutputStream archiveOutputStream = null;
try {
for (Target target : targets) {
// get target volume | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
// Path: src/main/java/br/com/trustsystems/elfinder/support/archiver/AbstractArchiver.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.support.archiver;
/**
* Abstract Archiver defines some archive behaviors and this class has some
* convenient methods. This class must be extended by concrete archive
* implementations.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public abstract class AbstractArchiver implements Archiver {
public static final String DEFAULT_ARCHIVE_NAME = "Archive";
private AtomicInteger count = new AtomicInteger(1);
/**
* Defines how to create a archive inputstream.
*
* @param bufferedInputStream the inputstream.
* @return the archive inputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveInputStream createArchiveInputStream(BufferedInputStream bufferedInputStream) throws IOException;
/**
* Defines how to create a archive outputstream.
*
* @param bufferedOutputStream the outputstream.
* @return the archive outputstream.
* @throws IOException if something goes wrong.
*/
public abstract ArchiveOutputStream createArchiveOutputStream(BufferedOutputStream bufferedOutputStream) throws IOException;
/**
* Defines how to create a archive entry.
*
* @param targetPath the target path.
* @param targetSize the target size.
* @param targetContent the target bytes.
* @return the archive entry.
*/
public abstract ArchiveEntry createArchiveEntry(String targetPath, long targetSize, byte[] targetContent);
@Override
public String getArchiveName() {
return DEFAULT_ARCHIVE_NAME;
}
/**
* Default compress implementation used by .tar and .tgz
*
* @return the compress archive target.
*/
@Override
public Target compress(Target... targets) throws IOException {
Target compressTarget = null;
OutputStream outputStream = null;
BufferedOutputStream bufferedOutputStream = null;
ArchiveOutputStream archiveOutputStream = null;
try {
for (Target target : targets) {
// get target volume | final Volume targetVolume = target.getVolume(); |
trustsystems/elfinder-java-connector | src/test/java/br/com/trustsystems/elfinder/service/VolumeSourcesTest.java | // Path: src/main/java/br/com/trustsystems/elfinder/exception/VolumeSourceException.java
// public class VolumeSourceException extends RuntimeException {
//
// private static final long serialVersionUID = -2443056237600812799L;
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public VolumeSourceException() {
// super();
// }
//
// /**
// * Constructs a new runtime exception with the specified detail message.
// * The cause is not initialized, and may subsequently be initialized by a
// * call to {@link #initCause}.
// *
// * @param message the detail message. The detail message is saved for
// * later retrieval by the {@link #getMessage()} method.
// */
// public VolumeSourceException(String message) {
// super(message);
// }
//
// /**
// * Constructs a new runtime exception with the specified detail message and
// * cause. <p>Note that the detail message associated with
// * {@code cause} is <i>not</i> automatically incorporated in
// * this runtime exception's detail message.
// *
// * @param message the detail message (which is saved for later retrieval
// * by the {@link #getMessage()} method).
// * @param cause the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// * @since 1.4
// */
// public VolumeSourceException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Constructs a new runtime exception with the specified cause and a
// * detail message of <tt>(cause==null ? null : cause.toString())</tt>
// * (which typically contains the class and detail message of
// * <tt>cause</tt>). This constructor is useful for runtime exceptions
// * that are little more than wrappers for other throwables.
// *
// * @param cause the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// * @since 1.4
// */
// public VolumeSourceException(Throwable cause) {
// super(cause);
// }
//
// /**
// * Constructs a new runtime exception with the specified detail
// * message, cause, suppression enabled or disabled, and writable
// * stack trace enabled or disabled.
// *
// * @param message the detail message.
// * @param cause the cause. (A {@code null} value is permitted,
// * and indicates that the cause is nonexistent or unknown.)
// * @param enableSuppression whether or not suppression is enabled
// * or disabled
// * @param writableStackTrace whether or not the stack trace should
// * be writable
// * @since 1.7
// */
// protected VolumeSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
// }
| import br.com.trustsystems.elfinder.exception.VolumeSourceException;
import org.testng.Assert;
import org.testng.annotations.Test; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
/**
* Volume Sources Test.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public class VolumeSourcesTest {
@Test
public void normalizeSource() {
String[] sources = {"FILESYSTEM", "filesystem", "FileSystem", " File System", "file_system", "file- system"};
Assert.assertNotNull(sources);
for (String source : sources) {
Assert.assertEquals(VolumeSources.of(source), VolumeSources.FILESYSTEM);
}
}
| // Path: src/main/java/br/com/trustsystems/elfinder/exception/VolumeSourceException.java
// public class VolumeSourceException extends RuntimeException {
//
// private static final long serialVersionUID = -2443056237600812799L;
//
// /**
// * Constructs a new runtime exception with {@code null} as its
// * detail message. The cause is not initialized, and may subsequently be
// * initialized by a call to {@link #initCause}.
// */
// public VolumeSourceException() {
// super();
// }
//
// /**
// * Constructs a new runtime exception with the specified detail message.
// * The cause is not initialized, and may subsequently be initialized by a
// * call to {@link #initCause}.
// *
// * @param message the detail message. The detail message is saved for
// * later retrieval by the {@link #getMessage()} method.
// */
// public VolumeSourceException(String message) {
// super(message);
// }
//
// /**
// * Constructs a new runtime exception with the specified detail message and
// * cause. <p>Note that the detail message associated with
// * {@code cause} is <i>not</i> automatically incorporated in
// * this runtime exception's detail message.
// *
// * @param message the detail message (which is saved for later retrieval
// * by the {@link #getMessage()} method).
// * @param cause the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// * @since 1.4
// */
// public VolumeSourceException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Constructs a new runtime exception with the specified cause and a
// * detail message of <tt>(cause==null ? null : cause.toString())</tt>
// * (which typically contains the class and detail message of
// * <tt>cause</tt>). This constructor is useful for runtime exceptions
// * that are little more than wrappers for other throwables.
// *
// * @param cause the cause (which is saved for later retrieval by the
// * {@link #getCause()} method). (A <tt>null</tt> value is
// * permitted, and indicates that the cause is nonexistent or
// * unknown.)
// * @since 1.4
// */
// public VolumeSourceException(Throwable cause) {
// super(cause);
// }
//
// /**
// * Constructs a new runtime exception with the specified detail
// * message, cause, suppression enabled or disabled, and writable
// * stack trace enabled or disabled.
// *
// * @param message the detail message.
// * @param cause the cause. (A {@code null} value is permitted,
// * and indicates that the cause is nonexistent or unknown.)
// * @param enableSuppression whether or not suppression is enabled
// * or disabled
// * @param writableStackTrace whether or not the stack trace should
// * be writable
// * @since 1.7
// */
// protected VolumeSourceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
// }
// Path: src/test/java/br/com/trustsystems/elfinder/service/VolumeSourcesTest.java
import br.com.trustsystems.elfinder.exception.VolumeSourceException;
import org.testng.Assert;
import org.testng.annotations.Test;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
/**
* Volume Sources Test.
*
* @author Thiago Gutenberg Carvalho da Costa
*/
public class VolumeSourcesTest {
@Test
public void normalizeSource() {
String[] sources = {"FILESYSTEM", "filesystem", "FileSystem", " File System", "file_system", "file- system"};
Assert.assertNotNull(sources);
for (String source : sources) {
Assert.assertEquals(VolumeSources.of(source), VolumeSources.FILESYSTEM);
}
}
| @Test(expectedExceptions = VolumeSourceException.class) |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/core/impl/NIO2FileSystemTarget.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import java.nio.file.Path; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.core.impl;
public class NIO2FileSystemTarget implements Target {
private final Path path; | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
// Path: src/main/java/br/com/trustsystems/elfinder/core/impl/NIO2FileSystemTarget.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import java.nio.file.Path;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.core.impl;
public class NIO2FileSystemTarget implements Target {
private final Path path; | private final Volume volume; |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java
// public interface VolumeSecurity {
//
// String getVolumePattern();
//
// SecurityConstraint getSecurityConstraint();
//
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import br.com.trustsystems.elfinder.core.VolumeSecurity;
import java.io.IOException;
import java.util.List;
import java.util.Locale; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
public interface ElfinderStorage {
Target fromHash(String hash);
String getHash(Target target) throws IOException;
| // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java
// public interface VolumeSecurity {
//
// String getVolumePattern();
//
// SecurityConstraint getSecurityConstraint();
//
// }
// Path: src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import br.com.trustsystems.elfinder.core.VolumeSecurity;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
public interface ElfinderStorage {
Target fromHash(String hash);
String getHash(Target target) throws IOException;
| String getVolumeId(Volume volume); |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java
// public interface VolumeSecurity {
//
// String getVolumePattern();
//
// SecurityConstraint getSecurityConstraint();
//
// }
| import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import br.com.trustsystems.elfinder.core.VolumeSecurity;
import java.io.IOException;
import java.util.List;
import java.util.Locale; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
public interface ElfinderStorage {
Target fromHash(String hash);
String getHash(Target target) throws IOException;
String getVolumeId(Volume volume);
Locale getVolumeLocale(Volume volume);
| // Path: src/main/java/br/com/trustsystems/elfinder/core/Target.java
// public interface Target {
//
// Volume getVolume();
//
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/Volume.java
// public interface Volume {
//
// void createFile(Target target) throws IOException;
//
// void createFolder(Target target) throws IOException;
//
// void deleteFile(Target target) throws IOException;
//
// void deleteFolder(Target target) throws IOException;
//
// boolean exists(Target target);
//
// Target fromPath(String path);
//
// long getLastModified(Target target) throws IOException;
//
// String getMimeType(Target target) throws IOException;
//
// String getAlias();
//
// String getName(Target target);
//
// Target getParent(Target target);
//
// String getPath(Target target) throws IOException;
//
// Target getRoot();
//
// long getSize(Target target) throws IOException;
//
// boolean hasChildFolder(Target target) throws IOException;
//
// boolean isFolder(Target target);
//
// boolean isRoot(Target target) throws IOException;
//
// Target[] listChildren(Target target) throws IOException;
//
// InputStream openInputStream(Target target) throws IOException;
//
// OutputStream openOutputStream(Target target) throws IOException;
//
// void rename(Target origin, Target destination) throws IOException;
//
// List<Target> search(String target) throws IOException;
// }
//
// Path: src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java
// public interface VolumeSecurity {
//
// String getVolumePattern();
//
// SecurityConstraint getSecurityConstraint();
//
// }
// Path: src/main/java/br/com/trustsystems/elfinder/service/ElfinderStorage.java
import br.com.trustsystems.elfinder.core.Target;
import br.com.trustsystems.elfinder.core.Volume;
import br.com.trustsystems.elfinder.core.VolumeSecurity;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.service;
public interface ElfinderStorage {
Target fromHash(String hash);
String getHash(Target target) throws IOException;
String getVolumeId(Volume volume);
Locale getVolumeLocale(Volume volume);
| VolumeSecurity getVolumeSecurity(Target target); |
trustsystems/elfinder-java-connector | src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java | // Path: src/main/java/br/com/trustsystems/elfinder/core/impl/SecurityConstraint.java
// public class SecurityConstraint {
//
// private boolean locked = false;
// private boolean readable = true;
// private boolean writable = true;
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public boolean isWritable() {
// return writable;
// }
//
// public void setWritable(boolean writable) {
// this.writable = writable;
// }
// }
| import br.com.trustsystems.elfinder.core.impl.SecurityConstraint; | /*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.core;
public interface VolumeSecurity {
String getVolumePattern();
| // Path: src/main/java/br/com/trustsystems/elfinder/core/impl/SecurityConstraint.java
// public class SecurityConstraint {
//
// private boolean locked = false;
// private boolean readable = true;
// private boolean writable = true;
//
// public boolean isLocked() {
// return locked;
// }
//
// public void setLocked(boolean locked) {
// this.locked = locked;
// }
//
// public boolean isReadable() {
// return readable;
// }
//
// public void setReadable(boolean readable) {
// this.readable = readable;
// }
//
// public boolean isWritable() {
// return writable;
// }
//
// public void setWritable(boolean writable) {
// this.writable = writable;
// }
// }
// Path: src/main/java/br/com/trustsystems/elfinder/core/VolumeSecurity.java
import br.com.trustsystems.elfinder.core.impl.SecurityConstraint;
/*
* #%L
* %%
* Copyright (C) 2015 Trustsystems Desenvolvimento de Sistemas, LTDA.
* %%
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the Trustsystems Desenvolvimento de Sistemas, LTDA. nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package br.com.trustsystems.elfinder.core;
public interface VolumeSecurity {
String getVolumePattern();
| SecurityConstraint getSecurityConstraint(); |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/PluginEntryFactory.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigReader.java
// public class ConfigReader {
// private static final Logger logger = LoggerFactory.getLogger("ConfigReader");
//
// public ConfigReader() {}
//
// public static String[] windowsTerminal() {
// return readConfig(FileTools.toAbsolute("jde/user/windows_terminal_emulator.cfg"))
// .findFirst()
// .map(s -> s.split(" "))
// .orElseGet(() -> new String[] {"cmd", "/K", "start", "powershell", "./run_jetty.ps1"});
// }
//
// public static String[] linuxTerminal() {
// return readConfig(FileTools.toAbsolute("jde/user/linux_terminal_emulator.cfg"))
// .findFirst()
// .map(s -> s.split(" "))
// .orElseGet(() -> new String[] {"gnome-terminal", "--", "./run_jetty.sh"});
// }
//
// public static String javaPath() {
// return readConfig(FileTools.toAbsolute("jde/user/java_command.cfg"))
// .findFirst()
// .orElseGet(ConfigReader::defaultJava);
// }
//
// /**
// * This returns a list because we need to have a possible null-check when writing to the jtwig
// * templates. Otherwise, this method would be a lot cleaner.
// *
// * <p>TODO: Move empty check to template
// */
// public static List<String> runtimeParameters() {
// List<String> lines =
// readConfig(FileTools.toAbsolute("jde/user/run_time_parameters.cfg"))
// .collect(Collectors.toList());
//
// return !lines.isEmpty() ? lines : null;
// }
//
// public static Stream<String> flattenConfigs(String directory) {
// return flattenConfigs(FileTools.toAbsolute(directory));
// }
//
// public static Stream<String> flattenConfigs(File directory) {
// File[] files = directory.listFiles();
// return Arrays.stream(files)
// .map(f -> Files.asCharSource(f, StandardCharsets.UTF_8))
// .flatMap(FileReader::read)
// .filter(ConfigReader::isConfigLine);
// }
//
// public static Stream<IniEntry> userConfiguration() {
// return flattenConfigs(FileTools.toAbsolute("jde/user/workspaces"))
// .filter(ConfigReader::isConfigLine)
// .map(File::new)
// .map(PluginEntryFactory::getEntry);
// }
//
// public static Stream<String> sdkFiles(String version) {
// return FileReader.read(
// FileTools.toAbsolute(String.format("tool/sdk_files/sdk_files_%s.cfg", version)));
// }
//
// public static Stream<String> readConfig(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return FileReader.read(source).filter(ConfigReader::isConfigLine);
// }
//
// private static String defaultJava() {
// if (DetectOperatingSystem.isWindows()) {
// return "jre\\bin\\java.exe";
// }
//
// if (DetectOperatingSystem.isLinux()) {
// return "jre/bin/java";
// }
//
// throw new RuntimeException("Unknown operating system");
// }
//
// private static boolean isConfigLine(String in) {
// return !in.trim().startsWith("#") && !in.trim().isEmpty();
// }
// }
| import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.jazzcommunity.development.library.config.ConfigReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development.library.config.plugin;
public final class PluginEntryFactory {
private static final Logger logger = LoggerFactory.getLogger("PluginEntryFactory");
private PluginEntryFactory() {}
private static boolean isSubModule(String path, File directory) {
try {
return directory.getCanonicalPath().contains(path)
&& directory.getCanonicalPath().length() > path.length();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public static IniEntry getEntry(File directory) {
File[] files = directory.listFiles();
if (!directory.isDirectory() || files == null) {
return new InvalidEntry(directory);
}
List<String> parentCandidates = | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigReader.java
// public class ConfigReader {
// private static final Logger logger = LoggerFactory.getLogger("ConfigReader");
//
// public ConfigReader() {}
//
// public static String[] windowsTerminal() {
// return readConfig(FileTools.toAbsolute("jde/user/windows_terminal_emulator.cfg"))
// .findFirst()
// .map(s -> s.split(" "))
// .orElseGet(() -> new String[] {"cmd", "/K", "start", "powershell", "./run_jetty.ps1"});
// }
//
// public static String[] linuxTerminal() {
// return readConfig(FileTools.toAbsolute("jde/user/linux_terminal_emulator.cfg"))
// .findFirst()
// .map(s -> s.split(" "))
// .orElseGet(() -> new String[] {"gnome-terminal", "--", "./run_jetty.sh"});
// }
//
// public static String javaPath() {
// return readConfig(FileTools.toAbsolute("jde/user/java_command.cfg"))
// .findFirst()
// .orElseGet(ConfigReader::defaultJava);
// }
//
// /**
// * This returns a list because we need to have a possible null-check when writing to the jtwig
// * templates. Otherwise, this method would be a lot cleaner.
// *
// * <p>TODO: Move empty check to template
// */
// public static List<String> runtimeParameters() {
// List<String> lines =
// readConfig(FileTools.toAbsolute("jde/user/run_time_parameters.cfg"))
// .collect(Collectors.toList());
//
// return !lines.isEmpty() ? lines : null;
// }
//
// public static Stream<String> flattenConfigs(String directory) {
// return flattenConfigs(FileTools.toAbsolute(directory));
// }
//
// public static Stream<String> flattenConfigs(File directory) {
// File[] files = directory.listFiles();
// return Arrays.stream(files)
// .map(f -> Files.asCharSource(f, StandardCharsets.UTF_8))
// .flatMap(FileReader::read)
// .filter(ConfigReader::isConfigLine);
// }
//
// public static Stream<IniEntry> userConfiguration() {
// return flattenConfigs(FileTools.toAbsolute("jde/user/workspaces"))
// .filter(ConfigReader::isConfigLine)
// .map(File::new)
// .map(PluginEntryFactory::getEntry);
// }
//
// public static Stream<String> sdkFiles(String version) {
// return FileReader.read(
// FileTools.toAbsolute(String.format("tool/sdk_files/sdk_files_%s.cfg", version)));
// }
//
// public static Stream<String> readConfig(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return FileReader.read(source).filter(ConfigReader::isConfigLine);
// }
//
// private static String defaultJava() {
// if (DetectOperatingSystem.isWindows()) {
// return "jre\\bin\\java.exe";
// }
//
// if (DetectOperatingSystem.isLinux()) {
// return "jre/bin/java";
// }
//
// throw new RuntimeException("Unknown operating system");
// }
//
// private static boolean isConfigLine(String in) {
// return !in.trim().startsWith("#") && !in.trim().isEmpty();
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/PluginEntryFactory.java
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.jazzcommunity.development.library.config.ConfigReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development.library.config.plugin;
public final class PluginEntryFactory {
private static final Logger logger = LoggerFactory.getLogger("PluginEntryFactory");
private PluginEntryFactory() {}
private static boolean isSubModule(String path, File directory) {
try {
return directory.getCanonicalPath().contains(path)
&& directory.getCanonicalPath().length() > path.length();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public static IniEntry getEntry(File directory) {
File[] files = directory.listFiles();
if (!directory.isDirectory() || files == null) {
return new InvalidEntry(directory);
}
List<String> parentCandidates = | ConfigReader.flattenConfigs("jde/user/workspaces") |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
| import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development.library.config.plugin;
class ServiceEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final File directory;
public ServiceEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
| // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development.library.config.plugin;
class ServiceEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final File directory;
public ServiceEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
| if (DetectOperatingSystem.isWindows()) { |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
| import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development.library.config.plugin;
class ServiceEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final File directory;
public ServiceEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s/plugin@start", formatted);
}
@Override
public String getPropertiesLine() {
File manifest = new File(directory, "plugin/META-INF/MANIFEST.MF"); | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development.library.config.plugin;
class ServiceEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final File directory;
public ServiceEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s/plugin@start", formatted);
}
@Override
public String getPropertiesLine() {
File manifest = new File(directory, "plugin/META-INF/MANIFEST.MF"); | return FileReader.read(manifest) |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
| import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s/plugin@start", formatted);
}
@Override
public String getPropertiesLine() {
File manifest = new File(directory, "plugin/META-INF/MANIFEST.MF");
return FileReader.read(manifest)
.filter(l -> l.startsWith("Bundle-SymbolicName"))
.findFirst()
.map(line -> String.format("%s=target/classes,target/dependency", toSymbolicName(line)))
.orElseThrow(
() ->
new RuntimeException(
String.format(
"Missing Bundle-SymbolicName in %s. Malformed manifest", directory)));
}
@Override
public boolean needsPropertyEntry() {
return true;
}
@Override
public Stream<Path> getZip() {
Path path = Paths.get(directory.getAbsolutePath(), "/update-site/target"); | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileReader.java
// public class FileReader {
// private static final Logger logger = LoggerFactory.getLogger("FileReader");
//
// private FileReader() {}
//
// public static Stream<String> raw(File path) {
// if (!path.exists()) {
// logger.error("File {} does not exist", path);
// }
//
// CharSource source = Files.asCharSource(path, StandardCharsets.UTF_8);
// return raw(source);
// }
//
// public static Stream<String> raw(CharSource source) {
// try {
// return source.lines();
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.error("Error occurred reading files: {}", e.getMessage());
// return Stream.empty();
// }
// }
//
// public static Stream<String> read(File path) {
// return raw(path).map(String::trim);
// }
//
// public static Stream<String> read(CharSource source) {
// return raw(source).map(String::trim);
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/ServiceEntry.java
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileReader;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s/plugin@start", formatted);
}
@Override
public String getPropertiesLine() {
File manifest = new File(directory, "plugin/META-INF/MANIFEST.MF");
return FileReader.read(manifest)
.filter(l -> l.startsWith("Bundle-SymbolicName"))
.findFirst()
.map(line -> String.format("%s=target/classes,target/dependency", toSymbolicName(line)))
.orElseThrow(
() ->
new RuntimeException(
String.format(
"Missing Bundle-SymbolicName in %s. Malformed manifest", directory)));
}
@Override
public boolean needsPropertyEntry() {
return true;
}
@Override
public Stream<Path> getZip() {
Path path = Paths.get(directory.getAbsolutePath(), "/update-site/target"); | return FileResolver.findInDirectory(path, ".zip"); |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/RunTask.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/RuntimeDetector.java
// public final class RuntimeDetector {
// private RuntimeDetector() {}
//
// public static String getTargetPlatform(Project project) {
// String initializedVersion = FileTools.newestVersion("jde/dev/initialize");
// if (initializedVersion != null) {
// String path = String.format("jde/dev/initialize/%s/sdk", initializedVersion);
// return FileTools.toAbsolute(path).getAbsolutePath();
// }
//
// // fall back to default runtime
// String newestSdk = String.format("jde/runtime/%s/sdk", get(project).get());
// return FileTools.toAbsolute(newestSdk).getPath();
// }
//
// public static Optional<String> get(Project project) {
// String runtime =
// !project.hasProperty("runtime")
// ? FileTools.newestVersion("jde/runtime")
// : (String) project.getProperties().get("runtime");
//
// if (runtime == null) {
// return Optional.empty();
// }
//
// return Optional.of(runtime);
// }
//
// public static Stream<Runtime> getRuntimes() {
// return Arrays.stream(FileTools.getFiles("jde/runtime")).map(Runtime::new);
// }
//
// public static Runtime getRuntime(String version) {
// return getRuntimes()
// .filter(r -> r.getVersion().equals(version))
// .findFirst()
// .orElseThrow(
// () -> new RuntimeException(String.format("Invalid run time setup for %s", version)));
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigWriter.java
// public final class ConfigWriter {
// private static final Logger logger = LoggerFactory.getLogger("ConfigWriter");
//
// private ConfigWriter() {}
//
// public static void prepareConfigurations(String runtime) {
// String folder = runtime.isEmpty() ? FileTools.newestVersion("jde/runtime") : runtime;
// System.out.println("Generate run time configurations.");
// System.out.println(String.format("Preparing %s run time", folder));
//
// try {
// System.out.println("Writing config.ini");
// writeIni(folder);
// System.out.println("Writing dev.properties");
// writeProperties(folder);
// System.out.println("Copying log4j configuration");
// copyLogConfig(folder);
// System.out.println("Creating executable files");
// writeExecutables(folder);
// } catch (IOException e) {
// logger.error("Runtime configuration failed: {}", e.getMessage());
// }
// }
//
// private static void copyLogConfig(String folder) {
// String destination = String.format("jde/runtime/%s/conf/", folder);
// FileTools.copyFile("jde/user/log4j/log4j.properties", destination);
// }
//
// private static void writeExecutables(String folder) throws IOException {
// String to = String.format("jde/runtime/%s/", folder);
// Runtime runtime = RuntimeDetector.getRuntime(folder);
// String executable = ConfigReader.javaPath();
// makeScript("tool/scripts/run_jetty_bash.twig", to + "run_jetty.sh", executable, runtime);
// makeScript("tool/scripts/run_jetty_powershell.twig", to + "run_jetty.ps1", executable, runtime);
// FileTools.setExecutable(String.format("jde/runtime/%s/run_jetty.sh", folder));
// }
//
// private static void makeScript(
// String source, String destination, String executable, Runtime runtime) throws IOException {
// CharSink out = Files.asCharSink(FileTools.toAbsolute(destination), StandardCharsets.UTF_8);
// List<String> parameters = ConfigReader.runtimeParameters();
// JtwigTemplate template = JtwigTemplate.fileTemplate(FileTools.toAbsolute(source));
// JtwigModel model =
// JtwigModel.newModel()
// .with("executable", executable)
// .with("launcher", runtime.getLauncherPath())
// .with("parameters", parameters);
// out.write(template.render(model));
// }
//
// private static void writeProperties(String folder) throws IOException {
// CharSink file =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/dev.properties", folder)),
// StandardCharsets.UTF_8);
//
// List<String> properties =
// ConfigReader.userConfiguration()
// .filter(IniEntry::needsPropertyEntry)
// .map(IniEntry::getPropertiesLine)
// .collect(Collectors.toList());
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/dev.twig"));
// JtwigModel model = JtwigModel.newModel().with("properties", properties);
// file.write(template.render(model));
// }
//
// private static void writeIni(String folder) throws IOException {
// CharSink ini =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/config.ini", folder)),
// StandardCharsets.UTF_8);
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/config.twig"));
//
// Runtime runtime = RuntimeDetector.getRuntime(folder);
//
// JtwigModel model =
// JtwigModel.newModel()
// .with("osgiPath", runtime.getOsgi())
// .with("configurator", runtime.getConfigurator())
// .with("bundles", ConfigReader.sdkFiles(folder).collect(Collectors.toList()))
// .with(
// "configs",
// ConfigReader.userConfiguration()
// .map(IniEntry::getIniLine)
// .collect(Collectors.toList()));
// ini.write(template.render(model));
// }
// }
| import org.gradle.api.tasks.Exec;
import org.jazzcommunity.development.library.RuntimeDetector;
import org.jazzcommunity.development.library.config.ConfigWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development;
public class RunTask extends Exec {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
protected void exec() { | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/RuntimeDetector.java
// public final class RuntimeDetector {
// private RuntimeDetector() {}
//
// public static String getTargetPlatform(Project project) {
// String initializedVersion = FileTools.newestVersion("jde/dev/initialize");
// if (initializedVersion != null) {
// String path = String.format("jde/dev/initialize/%s/sdk", initializedVersion);
// return FileTools.toAbsolute(path).getAbsolutePath();
// }
//
// // fall back to default runtime
// String newestSdk = String.format("jde/runtime/%s/sdk", get(project).get());
// return FileTools.toAbsolute(newestSdk).getPath();
// }
//
// public static Optional<String> get(Project project) {
// String runtime =
// !project.hasProperty("runtime")
// ? FileTools.newestVersion("jde/runtime")
// : (String) project.getProperties().get("runtime");
//
// if (runtime == null) {
// return Optional.empty();
// }
//
// return Optional.of(runtime);
// }
//
// public static Stream<Runtime> getRuntimes() {
// return Arrays.stream(FileTools.getFiles("jde/runtime")).map(Runtime::new);
// }
//
// public static Runtime getRuntime(String version) {
// return getRuntimes()
// .filter(r -> r.getVersion().equals(version))
// .findFirst()
// .orElseThrow(
// () -> new RuntimeException(String.format("Invalid run time setup for %s", version)));
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigWriter.java
// public final class ConfigWriter {
// private static final Logger logger = LoggerFactory.getLogger("ConfigWriter");
//
// private ConfigWriter() {}
//
// public static void prepareConfigurations(String runtime) {
// String folder = runtime.isEmpty() ? FileTools.newestVersion("jde/runtime") : runtime;
// System.out.println("Generate run time configurations.");
// System.out.println(String.format("Preparing %s run time", folder));
//
// try {
// System.out.println("Writing config.ini");
// writeIni(folder);
// System.out.println("Writing dev.properties");
// writeProperties(folder);
// System.out.println("Copying log4j configuration");
// copyLogConfig(folder);
// System.out.println("Creating executable files");
// writeExecutables(folder);
// } catch (IOException e) {
// logger.error("Runtime configuration failed: {}", e.getMessage());
// }
// }
//
// private static void copyLogConfig(String folder) {
// String destination = String.format("jde/runtime/%s/conf/", folder);
// FileTools.copyFile("jde/user/log4j/log4j.properties", destination);
// }
//
// private static void writeExecutables(String folder) throws IOException {
// String to = String.format("jde/runtime/%s/", folder);
// Runtime runtime = RuntimeDetector.getRuntime(folder);
// String executable = ConfigReader.javaPath();
// makeScript("tool/scripts/run_jetty_bash.twig", to + "run_jetty.sh", executable, runtime);
// makeScript("tool/scripts/run_jetty_powershell.twig", to + "run_jetty.ps1", executable, runtime);
// FileTools.setExecutable(String.format("jde/runtime/%s/run_jetty.sh", folder));
// }
//
// private static void makeScript(
// String source, String destination, String executable, Runtime runtime) throws IOException {
// CharSink out = Files.asCharSink(FileTools.toAbsolute(destination), StandardCharsets.UTF_8);
// List<String> parameters = ConfigReader.runtimeParameters();
// JtwigTemplate template = JtwigTemplate.fileTemplate(FileTools.toAbsolute(source));
// JtwigModel model =
// JtwigModel.newModel()
// .with("executable", executable)
// .with("launcher", runtime.getLauncherPath())
// .with("parameters", parameters);
// out.write(template.render(model));
// }
//
// private static void writeProperties(String folder) throws IOException {
// CharSink file =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/dev.properties", folder)),
// StandardCharsets.UTF_8);
//
// List<String> properties =
// ConfigReader.userConfiguration()
// .filter(IniEntry::needsPropertyEntry)
// .map(IniEntry::getPropertiesLine)
// .collect(Collectors.toList());
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/dev.twig"));
// JtwigModel model = JtwigModel.newModel().with("properties", properties);
// file.write(template.render(model));
// }
//
// private static void writeIni(String folder) throws IOException {
// CharSink ini =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/config.ini", folder)),
// StandardCharsets.UTF_8);
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/config.twig"));
//
// Runtime runtime = RuntimeDetector.getRuntime(folder);
//
// JtwigModel model =
// JtwigModel.newModel()
// .with("osgiPath", runtime.getOsgi())
// .with("configurator", runtime.getConfigurator())
// .with("bundles", ConfigReader.sdkFiles(folder).collect(Collectors.toList()))
// .with(
// "configs",
// ConfigReader.userConfiguration()
// .map(IniEntry::getIniLine)
// .collect(Collectors.toList()));
// ini.write(template.render(model));
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/RunTask.java
import org.gradle.api.tasks.Exec;
import org.jazzcommunity.development.library.RuntimeDetector;
import org.jazzcommunity.development.library.config.ConfigWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development;
public class RunTask extends Exec {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
protected void exec() { | RuntimeDetector.get(getProject()).ifPresent(ConfigWriter::prepareConfigurations); |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/RunTask.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/RuntimeDetector.java
// public final class RuntimeDetector {
// private RuntimeDetector() {}
//
// public static String getTargetPlatform(Project project) {
// String initializedVersion = FileTools.newestVersion("jde/dev/initialize");
// if (initializedVersion != null) {
// String path = String.format("jde/dev/initialize/%s/sdk", initializedVersion);
// return FileTools.toAbsolute(path).getAbsolutePath();
// }
//
// // fall back to default runtime
// String newestSdk = String.format("jde/runtime/%s/sdk", get(project).get());
// return FileTools.toAbsolute(newestSdk).getPath();
// }
//
// public static Optional<String> get(Project project) {
// String runtime =
// !project.hasProperty("runtime")
// ? FileTools.newestVersion("jde/runtime")
// : (String) project.getProperties().get("runtime");
//
// if (runtime == null) {
// return Optional.empty();
// }
//
// return Optional.of(runtime);
// }
//
// public static Stream<Runtime> getRuntimes() {
// return Arrays.stream(FileTools.getFiles("jde/runtime")).map(Runtime::new);
// }
//
// public static Runtime getRuntime(String version) {
// return getRuntimes()
// .filter(r -> r.getVersion().equals(version))
// .findFirst()
// .orElseThrow(
// () -> new RuntimeException(String.format("Invalid run time setup for %s", version)));
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigWriter.java
// public final class ConfigWriter {
// private static final Logger logger = LoggerFactory.getLogger("ConfigWriter");
//
// private ConfigWriter() {}
//
// public static void prepareConfigurations(String runtime) {
// String folder = runtime.isEmpty() ? FileTools.newestVersion("jde/runtime") : runtime;
// System.out.println("Generate run time configurations.");
// System.out.println(String.format("Preparing %s run time", folder));
//
// try {
// System.out.println("Writing config.ini");
// writeIni(folder);
// System.out.println("Writing dev.properties");
// writeProperties(folder);
// System.out.println("Copying log4j configuration");
// copyLogConfig(folder);
// System.out.println("Creating executable files");
// writeExecutables(folder);
// } catch (IOException e) {
// logger.error("Runtime configuration failed: {}", e.getMessage());
// }
// }
//
// private static void copyLogConfig(String folder) {
// String destination = String.format("jde/runtime/%s/conf/", folder);
// FileTools.copyFile("jde/user/log4j/log4j.properties", destination);
// }
//
// private static void writeExecutables(String folder) throws IOException {
// String to = String.format("jde/runtime/%s/", folder);
// Runtime runtime = RuntimeDetector.getRuntime(folder);
// String executable = ConfigReader.javaPath();
// makeScript("tool/scripts/run_jetty_bash.twig", to + "run_jetty.sh", executable, runtime);
// makeScript("tool/scripts/run_jetty_powershell.twig", to + "run_jetty.ps1", executable, runtime);
// FileTools.setExecutable(String.format("jde/runtime/%s/run_jetty.sh", folder));
// }
//
// private static void makeScript(
// String source, String destination, String executable, Runtime runtime) throws IOException {
// CharSink out = Files.asCharSink(FileTools.toAbsolute(destination), StandardCharsets.UTF_8);
// List<String> parameters = ConfigReader.runtimeParameters();
// JtwigTemplate template = JtwigTemplate.fileTemplate(FileTools.toAbsolute(source));
// JtwigModel model =
// JtwigModel.newModel()
// .with("executable", executable)
// .with("launcher", runtime.getLauncherPath())
// .with("parameters", parameters);
// out.write(template.render(model));
// }
//
// private static void writeProperties(String folder) throws IOException {
// CharSink file =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/dev.properties", folder)),
// StandardCharsets.UTF_8);
//
// List<String> properties =
// ConfigReader.userConfiguration()
// .filter(IniEntry::needsPropertyEntry)
// .map(IniEntry::getPropertiesLine)
// .collect(Collectors.toList());
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/dev.twig"));
// JtwigModel model = JtwigModel.newModel().with("properties", properties);
// file.write(template.render(model));
// }
//
// private static void writeIni(String folder) throws IOException {
// CharSink ini =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/config.ini", folder)),
// StandardCharsets.UTF_8);
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/config.twig"));
//
// Runtime runtime = RuntimeDetector.getRuntime(folder);
//
// JtwigModel model =
// JtwigModel.newModel()
// .with("osgiPath", runtime.getOsgi())
// .with("configurator", runtime.getConfigurator())
// .with("bundles", ConfigReader.sdkFiles(folder).collect(Collectors.toList()))
// .with(
// "configs",
// ConfigReader.userConfiguration()
// .map(IniEntry::getIniLine)
// .collect(Collectors.toList()));
// ini.write(template.render(model));
// }
// }
| import org.gradle.api.tasks.Exec;
import org.jazzcommunity.development.library.RuntimeDetector;
import org.jazzcommunity.development.library.config.ConfigWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development;
public class RunTask extends Exec {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
protected void exec() { | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/RuntimeDetector.java
// public final class RuntimeDetector {
// private RuntimeDetector() {}
//
// public static String getTargetPlatform(Project project) {
// String initializedVersion = FileTools.newestVersion("jde/dev/initialize");
// if (initializedVersion != null) {
// String path = String.format("jde/dev/initialize/%s/sdk", initializedVersion);
// return FileTools.toAbsolute(path).getAbsolutePath();
// }
//
// // fall back to default runtime
// String newestSdk = String.format("jde/runtime/%s/sdk", get(project).get());
// return FileTools.toAbsolute(newestSdk).getPath();
// }
//
// public static Optional<String> get(Project project) {
// String runtime =
// !project.hasProperty("runtime")
// ? FileTools.newestVersion("jde/runtime")
// : (String) project.getProperties().get("runtime");
//
// if (runtime == null) {
// return Optional.empty();
// }
//
// return Optional.of(runtime);
// }
//
// public static Stream<Runtime> getRuntimes() {
// return Arrays.stream(FileTools.getFiles("jde/runtime")).map(Runtime::new);
// }
//
// public static Runtime getRuntime(String version) {
// return getRuntimes()
// .filter(r -> r.getVersion().equals(version))
// .findFirst()
// .orElseThrow(
// () -> new RuntimeException(String.format("Invalid run time setup for %s", version)));
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/ConfigWriter.java
// public final class ConfigWriter {
// private static final Logger logger = LoggerFactory.getLogger("ConfigWriter");
//
// private ConfigWriter() {}
//
// public static void prepareConfigurations(String runtime) {
// String folder = runtime.isEmpty() ? FileTools.newestVersion("jde/runtime") : runtime;
// System.out.println("Generate run time configurations.");
// System.out.println(String.format("Preparing %s run time", folder));
//
// try {
// System.out.println("Writing config.ini");
// writeIni(folder);
// System.out.println("Writing dev.properties");
// writeProperties(folder);
// System.out.println("Copying log4j configuration");
// copyLogConfig(folder);
// System.out.println("Creating executable files");
// writeExecutables(folder);
// } catch (IOException e) {
// logger.error("Runtime configuration failed: {}", e.getMessage());
// }
// }
//
// private static void copyLogConfig(String folder) {
// String destination = String.format("jde/runtime/%s/conf/", folder);
// FileTools.copyFile("jde/user/log4j/log4j.properties", destination);
// }
//
// private static void writeExecutables(String folder) throws IOException {
// String to = String.format("jde/runtime/%s/", folder);
// Runtime runtime = RuntimeDetector.getRuntime(folder);
// String executable = ConfigReader.javaPath();
// makeScript("tool/scripts/run_jetty_bash.twig", to + "run_jetty.sh", executable, runtime);
// makeScript("tool/scripts/run_jetty_powershell.twig", to + "run_jetty.ps1", executable, runtime);
// FileTools.setExecutable(String.format("jde/runtime/%s/run_jetty.sh", folder));
// }
//
// private static void makeScript(
// String source, String destination, String executable, Runtime runtime) throws IOException {
// CharSink out = Files.asCharSink(FileTools.toAbsolute(destination), StandardCharsets.UTF_8);
// List<String> parameters = ConfigReader.runtimeParameters();
// JtwigTemplate template = JtwigTemplate.fileTemplate(FileTools.toAbsolute(source));
// JtwigModel model =
// JtwigModel.newModel()
// .with("executable", executable)
// .with("launcher", runtime.getLauncherPath())
// .with("parameters", parameters);
// out.write(template.render(model));
// }
//
// private static void writeProperties(String folder) throws IOException {
// CharSink file =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/dev.properties", folder)),
// StandardCharsets.UTF_8);
//
// List<String> properties =
// ConfigReader.userConfiguration()
// .filter(IniEntry::needsPropertyEntry)
// .map(IniEntry::getPropertiesLine)
// .collect(Collectors.toList());
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/dev.twig"));
// JtwigModel model = JtwigModel.newModel().with("properties", properties);
// file.write(template.render(model));
// }
//
// private static void writeIni(String folder) throws IOException {
// CharSink ini =
// Files.asCharSink(
// FileTools.toAbsolute(String.format("jde/runtime/%s/conf/config.ini", folder)),
// StandardCharsets.UTF_8);
//
// JtwigTemplate template =
// JtwigTemplate.fileTemplate(FileTools.toAbsolute("tool/templates/config.twig"));
//
// Runtime runtime = RuntimeDetector.getRuntime(folder);
//
// JtwigModel model =
// JtwigModel.newModel()
// .with("osgiPath", runtime.getOsgi())
// .with("configurator", runtime.getConfigurator())
// .with("bundles", ConfigReader.sdkFiles(folder).collect(Collectors.toList()))
// .with(
// "configs",
// ConfigReader.userConfiguration()
// .map(IniEntry::getIniLine)
// .collect(Collectors.toList()));
// ini.write(template.render(model));
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/RunTask.java
import org.gradle.api.tasks.Exec;
import org.jazzcommunity.development.library.RuntimeDetector;
import org.jazzcommunity.development.library.config.ConfigWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development;
public class RunTask extends Exec {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
protected void exec() { | RuntimeDetector.get(getProject()).ifPresent(ConfigWriter::prepareConfigurations); |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/UiEntry.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
| import java.io.File;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development.library.config.plugin;
class UiEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final File directory;
public UiEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
| // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/UiEntry.java
import java.io.File;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development.library.config.plugin;
class UiEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final File directory;
public UiEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
| if (DetectOperatingSystem.isWindows()) { |
jazz-community/jazz-debug-environment | buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/UiEntry.java | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
| import java.io.File;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package org.jazzcommunity.development.library.config.plugin;
class UiEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final File directory;
public UiEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s@start", formatted);
}
@Override
public String getPropertiesLine() {
// UI plugins don't require an entry in the .properties file.
return "";
}
@Override
public boolean needsPropertyEntry() {
return false;
}
@Override
public Stream<Path> getZip() { | // Path: buildSrc/src/main/java/org/jazzcommunity/development/library/DetectOperatingSystem.java
// public class DetectOperatingSystem {
// public static boolean isWindows() {
// return OperatingSystem.current().isWindows();
// }
//
// public static boolean isLinux() {
// return OperatingSystem.current().isLinux();
// }
// }
//
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/file/FileResolver.java
// public final class FileResolver {
// private static final Logger logger = LoggerFactory.getLogger("FileResolver");
//
// private FileResolver() {}
//
// public static Stream<Path> findInDirectory(Path directory, String endsWith) {
// try {
// return Files.find(directory, 1, (p, b) -> p.getFileName().toString().endsWith(endsWith));
// } catch (IOException e) {
// if (logger.isDebugEnabled()) {
// e.printStackTrace();
// }
// logger.info(
// "File ending with '{}' in '{}' not found. Ignoring this entry.", directory, endsWith);
// return null;
// }
// }
// }
// Path: buildSrc/src/main/java/org/jazzcommunity/development/library/config/plugin/UiEntry.java
import java.io.File;
import java.nio.file.Path;
import java.util.stream.Stream;
import org.jazzcommunity.development.library.DetectOperatingSystem;
import org.jazzcommunity.development.library.file.FileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package org.jazzcommunity.development.library.config.plugin;
class UiEntry implements IniEntry {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final File directory;
public UiEntry(File directory) {
this.directory = directory;
}
@Override
public String getIniLine() {
// TODO: duplicated code
String formatted = directory.getPath();
if (DetectOperatingSystem.isWindows()) {
formatted = formatted.replaceAll("\\\\", "/");
formatted = formatted.replaceAll(":", "\\\\:");
}
return String.format("reference\\:file\\:%s@start", formatted);
}
@Override
public String getPropertiesLine() {
// UI plugins don't require an entry in the .properties file.
return "";
}
@Override
public boolean needsPropertyEntry() {
return false;
}
@Override
public Stream<Path> getZip() { | return FileResolver.findInDirectory(directory.toPath(), ".zip"); |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/LocalEnvironment.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
| import me.gregorias.dfuntest.util.FileUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.List; | package me.gregorias.dfuntest;
/**
* Environment on local host with specified home path
*/
public class LocalEnvironment extends AbstractConfigurationEnvironment {
private final int mId;
private final Path mDir; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
// Path: core/src/main/java/me/gregorias/dfuntest/LocalEnvironment.java
import me.gregorias.dfuntest.util.FileUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.List;
package me.gregorias.dfuntest;
/**
* Environment on local host with specified home path
*/
public class LocalEnvironment extends AbstractConfigurationEnvironment {
private final int mId;
private final Path mDir; | private final FileUtils mFileUtils; |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleSanityTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection; | package me.gregorias.dfuntest.example;
/**
* Basic test script checking whether application can be started up and shut down.
*/
public class ExampleSanityTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleSanityTestScript.class);
@Override | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleSanityTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
package me.gregorias.dfuntest.example;
/**
* Basic test script checking whether application can be started up and shut down.
*/
public class ExampleSanityTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleSanityTestScript.class);
@Override | public TestResult run(Collection<ExampleApp> apps) { |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleSanityTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection; | package me.gregorias.dfuntest.example;
/**
* Basic test script checking whether application can be started up and shut down.
*/
public class ExampleSanityTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleSanityTestScript.class);
@Override
public TestResult run(Collection<ExampleApp> apps) {
LOGGER.info("run()");
try {
startUpApps(apps); | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleSanityTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
package me.gregorias.dfuntest.example;
/**
* Basic test script checking whether application can be started up and shut down.
*/
public class ExampleSanityTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleSanityTestScript.class);
@Override
public TestResult run(Collection<ExampleApp> apps) {
LOGGER.info("run()");
try {
startUpApps(apps); | } catch (CommandException | IOException e) { |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleDistributedPingTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | package me.gregorias.dfuntest.example;
/**
* This test script tests whether all applications send their id to initial application.
*/
public class ExampleDistributedPingTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(
ExampleDistributedPingTestScript.class);
@Override | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleDistributedPingTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package me.gregorias.dfuntest.example;
/**
* This test script tests whether all applications send their id to initial application.
*/
public class ExampleDistributedPingTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(
ExampleDistributedPingTestScript.class);
@Override | public TestResult run(Collection<ExampleApp> apps) { |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleDistributedPingTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set; | package me.gregorias.dfuntest.example;
/**
* This test script tests whether all applications send their id to initial application.
*/
public class ExampleDistributedPingTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(
ExampleDistributedPingTestScript.class);
@Override
public TestResult run(Collection<ExampleApp> apps) {
List<ExampleApp> appList = new ArrayList<>(apps);
Set<Integer> expectedIDs = new HashSet<>();
TestResult result = new TestResult(TestResult.Type.SUCCESS, "Test was successful.");
try {
startUpApps(apps); | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleDistributedPingTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package me.gregorias.dfuntest.example;
/**
* This test script tests whether all applications send their id to initial application.
*/
public class ExampleDistributedPingTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(
ExampleDistributedPingTestScript.class);
@Override
public TestResult run(Collection<ExampleApp> apps) {
List<ExampleApp> appList = new ArrayList<>(apps);
Set<Integer> expectedIDs = new HashSet<>();
TestResult result = new TestResult(TestResult.Type.SUCCESS, "Test was successful.");
try {
startUpApps(apps); | } catch (CommandException | IOException e) { |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/SSHEnvironment.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.sftp.SFTPClient;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.xfer.FileSystemFile; | package me.gregorias.dfuntest;
/**
* An UNIX environment accessible through SSH with public key.
*/
public class SSHEnvironment extends AbstractConfigurationEnvironment {
private static final Logger LOGGER = LoggerFactory.getLogger(SSHEnvironment.class);
private final int mId;
private final String mRemoteHomePath;
private final String mUsername;
private final Path mPrivateKeyPath;
private final InetAddress mRemoteInetAddress;
private final Executor mExecutor; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/main/java/me/gregorias/dfuntest/SSHEnvironment.java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.sftp.SFTPClient;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.xfer.FileSystemFile;
package me.gregorias.dfuntest;
/**
* An UNIX environment accessible through SSH with public key.
*/
public class SSHEnvironment extends AbstractConfigurationEnvironment {
private static final Logger LOGGER = LoggerFactory.getLogger(SSHEnvironment.class);
private final int mId;
private final String mRemoteHomePath;
private final String mUsername;
private final Path mPrivateKeyPath;
private final InetAddress mRemoteInetAddress;
private final Executor mExecutor; | private final SSHClientFactory mSSHClientFactory; |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/SSHEnvironment.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.sftp.SFTPClient;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.xfer.FileSystemFile; | package me.gregorias.dfuntest;
/**
* An UNIX environment accessible through SSH with public key.
*/
public class SSHEnvironment extends AbstractConfigurationEnvironment {
private static final Logger LOGGER = LoggerFactory.getLogger(SSHEnvironment.class);
private final int mId;
private final String mRemoteHomePath;
private final String mUsername;
private final Path mPrivateKeyPath;
private final InetAddress mRemoteInetAddress;
private final Executor mExecutor;
private final SSHClientFactory mSSHClientFactory; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/main/java/me/gregorias/dfuntest/SSHEnvironment.java
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.sftp.SFTPClient;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.xfer.FileSystemFile;
package me.gregorias.dfuntest;
/**
* An UNIX environment accessible through SSH with public key.
*/
public class SSHEnvironment extends AbstractConfigurationEnvironment {
private static final Logger LOGGER = LoggerFactory.getLogger(SSHEnvironment.class);
private final int mId;
private final String mRemoteHomePath;
private final String mUsername;
private final Path mPrivateKeyPath;
private final InetAddress mRemoteInetAddress;
private final Executor mExecutor;
private final SSHClientFactory mSSHClientFactory; | private final FileUtils mFileUtils; |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/AbstractExampleTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestScript.java
// public interface TestScript<AppT extends App> {
// /**
// * @param apps applications to test
// * @return result of the test
// */
// TestResult run(Collection<AppT> apps);
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestScript;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; | package me.gregorias.dfuntest.example;
/**
* Base implementation for Example's test scripts which adds start up and shut down functionality.
*/
public abstract class AbstractExampleTestScript implements TestScript<ExampleApp> {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractExampleTestScript.class);
| // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestScript.java
// public interface TestScript<AppT extends App> {
// /**
// * @param apps applications to test
// * @return result of the test
// */
// TestResult run(Collection<AppT> apps);
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/AbstractExampleTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestScript;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
package me.gregorias.dfuntest.example;
/**
* Base implementation for Example's test scripts which adds start up and shut down functionality.
*/
public abstract class AbstractExampleTestScript implements TestScript<ExampleApp> {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractExampleTestScript.class);
| protected void startUpApps(Collection<ExampleApp> apps) throws CommandException, IOException { |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/MultiTestRunnerTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
| import me.gregorias.dfuntest.util.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyCollection;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class MultiTestRunnerTest {
private MultiTestRunner<Environment, App<Environment>> mMultiTestRunner = null;
private final TestScript<App<Environment>> mMockTestScript = mock(TestScript.class);
private final EnvironmentFactory<Environment> mMockEnvironmentFactory =
mock(EnvironmentFactory.class);
private final EnvironmentPreparator<Environment> mMockEnvironmentPreparator =
mock(EnvironmentPreparator.class);
private final ApplicationFactory<Environment, App<Environment>> mMockApplicationFactory =
mock(ApplicationFactory.class);
private final Path mReportPath = FileSystems.getDefault().getPath("reportDir"); | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
// Path: core/src/test/java/me/gregorias/dfuntest/MultiTestRunnerTest.java
import me.gregorias.dfuntest.util.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyCollection;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class MultiTestRunnerTest {
private MultiTestRunner<Environment, App<Environment>> mMultiTestRunner = null;
private final TestScript<App<Environment>> mMockTestScript = mock(TestScript.class);
private final EnvironmentFactory<Environment> mMockEnvironmentFactory =
mock(EnvironmentFactory.class);
private final EnvironmentPreparator<Environment> mMockEnvironmentPreparator =
mock(EnvironmentPreparator.class);
private final ApplicationFactory<Environment, App<Environment>> mMockApplicationFactory =
mock(ApplicationFactory.class);
private final Path mReportPath = FileSystems.getDefault().getPath("reportDir"); | private final FileUtils mMockFileUtils = mock(FileUtils.class); |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/LocalEnvironmentFactoryTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
| import me.gregorias.dfuntest.util.FileUtils;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class LocalEnvironmentFactoryTest {
@Test
public void createEnvironmentsShouldCreateLocalEnvironments() throws IOException {
final int envCount = 5;
final String dirPrefix = "unittest";
| // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
// Path: core/src/test/java/me/gregorias/dfuntest/LocalEnvironmentFactoryTest.java
import me.gregorias.dfuntest.util.FileUtils;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class LocalEnvironmentFactoryTest {
@Test
public void createEnvironmentsShouldCreateLocalEnvironments() throws IOException {
final int envCount = 5;
final String dirPrefix = "unittest";
| FileUtils mockFileUtils = mock(FileUtils.class); |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/SSHEnvironmentFactory.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import me.gregorias.dfuntest.util.SSHClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | @Named(HOSTS_ARGUMENT_NAME) Collection<String> hosts,
@Named(USERNAME_ARGUMENT_NAME) String username,
@Named(PRIVATE_KEY_PATH) Path privateKeyPath,
@Named(REMOTE_DIR_ARGUMENT_NAME) String remoteDir,
@Named(EXECUTOR_ARGUMENT_NAME) Executor executor) {
if (hosts.size() == 0) {
throw new IllegalArgumentException("Hosts collection is empty.");
}
mHostnames = new ArrayList<>(hosts);
mUsername = username;
mPrivateKeyPath = privateKeyPath;
mRemoteDir = remoteDir;
mExecutor = executor;
}
@Override
public Collection<Environment> create() throws IOException {
LOGGER.info("create()");
Collection<Environment> environments = new ArrayList<>();
for (int envIdx = 0; envIdx < mHostnames.size(); ++envIdx) {
LOGGER.trace("create(): Setting up environment for host: {}.", mHostnames.get(envIdx));
InetAddress hostInetAddress = InetAddress.getByName(mHostnames.get(envIdx));
final Environment env = new SSHEnvironment(envIdx,
mUsername,
mPrivateKeyPath,
hostInetAddress,
String.format("%s%04d", mRemoteDir, envIdx),
mExecutor, | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/main/java/me/gregorias/dfuntest/SSHEnvironmentFactory.java
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import me.gregorias.dfuntest.util.SSHClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Named(HOSTS_ARGUMENT_NAME) Collection<String> hosts,
@Named(USERNAME_ARGUMENT_NAME) String username,
@Named(PRIVATE_KEY_PATH) Path privateKeyPath,
@Named(REMOTE_DIR_ARGUMENT_NAME) String remoteDir,
@Named(EXECUTOR_ARGUMENT_NAME) Executor executor) {
if (hosts.size() == 0) {
throw new IllegalArgumentException("Hosts collection is empty.");
}
mHostnames = new ArrayList<>(hosts);
mUsername = username;
mPrivateKeyPath = privateKeyPath;
mRemoteDir = remoteDir;
mExecutor = executor;
}
@Override
public Collection<Environment> create() throws IOException {
LOGGER.info("create()");
Collection<Environment> environments = new ArrayList<>();
for (int envIdx = 0; envIdx < mHostnames.size(); ++envIdx) {
LOGGER.trace("create(): Setting up environment for host: {}.", mHostnames.get(envIdx));
InetAddress hostInetAddress = InetAddress.getByName(mHostnames.get(envIdx));
final Environment env = new SSHEnvironment(envIdx,
mUsername,
mPrivateKeyPath,
hostInetAddress,
String.format("%s%04d", mRemoteDir, envIdx),
mExecutor, | SSHClientFactory.getSSHClientFactory(), |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/SSHEnvironmentFactory.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import me.gregorias.dfuntest.util.SSHClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | @Named(USERNAME_ARGUMENT_NAME) String username,
@Named(PRIVATE_KEY_PATH) Path privateKeyPath,
@Named(REMOTE_DIR_ARGUMENT_NAME) String remoteDir,
@Named(EXECUTOR_ARGUMENT_NAME) Executor executor) {
if (hosts.size() == 0) {
throw new IllegalArgumentException("Hosts collection is empty.");
}
mHostnames = new ArrayList<>(hosts);
mUsername = username;
mPrivateKeyPath = privateKeyPath;
mRemoteDir = remoteDir;
mExecutor = executor;
}
@Override
public Collection<Environment> create() throws IOException {
LOGGER.info("create()");
Collection<Environment> environments = new ArrayList<>();
for (int envIdx = 0; envIdx < mHostnames.size(); ++envIdx) {
LOGGER.trace("create(): Setting up environment for host: {}.", mHostnames.get(envIdx));
InetAddress hostInetAddress = InetAddress.getByName(mHostnames.get(envIdx));
final Environment env = new SSHEnvironment(envIdx,
mUsername,
mPrivateKeyPath,
hostInetAddress,
String.format("%s%04d", mRemoteDir, envIdx),
mExecutor,
SSHClientFactory.getSSHClientFactory(), | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/main/java/me/gregorias/dfuntest/SSHEnvironmentFactory.java
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Executor;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import me.gregorias.dfuntest.util.SSHClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Named(USERNAME_ARGUMENT_NAME) String username,
@Named(PRIVATE_KEY_PATH) Path privateKeyPath,
@Named(REMOTE_DIR_ARGUMENT_NAME) String remoteDir,
@Named(EXECUTOR_ARGUMENT_NAME) Executor executor) {
if (hosts.size() == 0) {
throw new IllegalArgumentException("Hosts collection is empty.");
}
mHostnames = new ArrayList<>(hosts);
mUsername = username;
mPrivateKeyPath = privateKeyPath;
mRemoteDir = remoteDir;
mExecutor = executor;
}
@Override
public Collection<Environment> create() throws IOException {
LOGGER.info("create()");
Collection<Environment> environments = new ArrayList<>();
for (int envIdx = 0; envIdx < mHostnames.size(); ++envIdx) {
LOGGER.trace("create(): Setting up environment for host: {}.", mHostnames.get(envIdx));
InetAddress hostInetAddress = InetAddress.getByName(mHostnames.get(envIdx));
final Environment env = new SSHEnvironment(envIdx,
mUsername,
mPrivateKeyPath,
hostInetAddress,
String.format("%s%04d", mRemoteDir, envIdx),
mExecutor,
SSHClientFactory.getSSHClientFactory(), | FileUtilsImpl.getFileUtilsImpl()); |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/MultiTestRunner.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
| import com.google.inject.Inject;
import me.gregorias.dfuntest.util.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Named;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set; | package me.gregorias.dfuntest;
/**
* <p>
* Basic implementation of TestRunner which runs sequentially multiple test script on given
* environments and apps.
* </p>
*
* <p>
* It prepares the environment for the first time iff shouldPrepareEnvironments flag is set.
* Otherwise it always restores them.
*
* If both shouldPrepareEnvironments and shouldCleanEnvironments are set then environments are
* prepared and cleaned before and after every test. If shouldCleanEnvironments is set to false then
* only cleanOutput is called and environments are restored subsequently before next test.
*
* After all tests, environments are destroyed iff shouldCleanEnvironments flag is set to true.
* </p>
*
* @author Grzegorz Milka
*
* @param <EnvironmentT>
* @param <AppT>
*/
public class MultiTestRunner<EnvironmentT extends Environment, AppT extends App<EnvironmentT>>
implements TestRunner {
public static final String REPORT_FILENAME = "report.txt";
public static final String SCRIPTS_ARGUMENT_NAME = "MultiTestRunner.scripts";
public static final String SHOULD_PREPARE_ARGUMENT_NAME =
"MultiTestRunner.shouldPrepareEnvironments";
public static final String SHOULD_CLEAN_ARGUMENT_NAME =
"MultiTestRunner.shouldCleanEnvironments";
public static final String REPORT_PATH_ARGUMENT_NAME =
"MultiTestRunner.reportPath";
private static final Logger LOGGER = LoggerFactory.getLogger(MultiTestRunner.class);
private final Collection<TestScript<AppT>> mScripts;
private final EnvironmentFactory<EnvironmentT> mEnvironmentFactory;
private final EnvironmentPreparator<EnvironmentT> mEnvironmentPreparator;
private final ApplicationFactory<EnvironmentT, AppT> mApplicationFactory;
private final boolean mShouldPrepareEnvironments;
private final boolean mShouldCleanEnvironments;
private final Path mReportPath; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
// Path: core/src/main/java/me/gregorias/dfuntest/MultiTestRunner.java
import com.google.inject.Inject;
import me.gregorias.dfuntest.util.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Named;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
package me.gregorias.dfuntest;
/**
* <p>
* Basic implementation of TestRunner which runs sequentially multiple test script on given
* environments and apps.
* </p>
*
* <p>
* It prepares the environment for the first time iff shouldPrepareEnvironments flag is set.
* Otherwise it always restores them.
*
* If both shouldPrepareEnvironments and shouldCleanEnvironments are set then environments are
* prepared and cleaned before and after every test. If shouldCleanEnvironments is set to false then
* only cleanOutput is called and environments are restored subsequently before next test.
*
* After all tests, environments are destroyed iff shouldCleanEnvironments flag is set to true.
* </p>
*
* @author Grzegorz Milka
*
* @param <EnvironmentT>
* @param <AppT>
*/
public class MultiTestRunner<EnvironmentT extends Environment, AppT extends App<EnvironmentT>>
implements TestRunner {
public static final String REPORT_FILENAME = "report.txt";
public static final String SCRIPTS_ARGUMENT_NAME = "MultiTestRunner.scripts";
public static final String SHOULD_PREPARE_ARGUMENT_NAME =
"MultiTestRunner.shouldPrepareEnvironments";
public static final String SHOULD_CLEAN_ARGUMENT_NAME =
"MultiTestRunner.shouldCleanEnvironments";
public static final String REPORT_PATH_ARGUMENT_NAME =
"MultiTestRunner.reportPath";
private static final Logger LOGGER = LoggerFactory.getLogger(MultiTestRunner.class);
private final Collection<TestScript<AppT>> mScripts;
private final EnvironmentFactory<EnvironmentT> mEnvironmentFactory;
private final EnvironmentPreparator<EnvironmentT> mEnvironmentPreparator;
private final ApplicationFactory<EnvironmentT, AppT> mApplicationFactory;
private final boolean mShouldPrepareEnvironments;
private final boolean mShouldCleanEnvironments;
private final Path mReportPath; | private final FileUtils mFileUtils; |
gregorias/dfuntest | core/src/main/java/me/gregorias/dfuntest/LocalEnvironmentFactory.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
| import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package me.gregorias.dfuntest;
/**
* Factory of {@link LocalEnvironment} working in local temporary directories.
*
* @author Grzegorz Milka
*/
public class LocalEnvironmentFactory implements EnvironmentFactory<Environment> {
public static final String ENV_COUNT_ARGUMENT_NAME = "LocalEnvironmentFactory.environmentCount";
public static final String DIR_PREFIX_ARGUMENT_NAME = "LocalEnvironmentFactory.dirPrefix";
private static final Logger LOGGER = LoggerFactory.getLogger(LocalEnvironmentFactory.class);
private static final String ENV_CONFIG_ROOT_DIR = "localEnvironmentFactoryRootDir";
private final int mEnvironmentCount;
private final String mDirPrefix; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
// Path: core/src/main/java/me/gregorias/dfuntest/LocalEnvironmentFactory.java
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.NoSuchElementException;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package me.gregorias.dfuntest;
/**
* Factory of {@link LocalEnvironment} working in local temporary directories.
*
* @author Grzegorz Milka
*/
public class LocalEnvironmentFactory implements EnvironmentFactory<Environment> {
public static final String ENV_COUNT_ARGUMENT_NAME = "LocalEnvironmentFactory.environmentCount";
public static final String DIR_PREFIX_ARGUMENT_NAME = "LocalEnvironmentFactory.dirPrefix";
private static final Logger LOGGER = LoggerFactory.getLogger(LocalEnvironmentFactory.class);
private static final String ENV_CONFIG_ROOT_DIR = "localEnvironmentFactoryRootDir";
private final int mEnvironmentCount;
private final String mDirPrefix; | private final FileUtils mFileUtils; |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExamplePingGetIDTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set; | package me.gregorias.dfuntest.example;
/**
* This TestScript checks whether applications will return all ids that were pinged to them.
*/
public class ExamplePingGetIDTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExamplePingGetIDTestScript.class);
private static final int PING_ID = 1087;
@Override | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExamplePingGetIDTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
package me.gregorias.dfuntest.example;
/**
* This TestScript checks whether applications will return all ids that were pinged to them.
*/
public class ExamplePingGetIDTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExamplePingGetIDTestScript.class);
private static final int PING_ID = 1087;
@Override | public TestResult run(Collection<ExampleApp> apps) { |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExamplePingGetIDTestScript.java | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
| import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set; | package me.gregorias.dfuntest.example;
/**
* This TestScript checks whether applications will return all ids that were pinged to them.
*/
public class ExamplePingGetIDTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExamplePingGetIDTestScript.class);
private static final int PING_ID = 1087;
@Override
public TestResult run(Collection<ExampleApp> apps) {
LOGGER.info("run()");
try {
startUpApps(apps); | // Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/TestResult.java
// public class TestResult {
// private final Type mType;
// private final String mDescription;
//
// public enum Type {
// SUCCESS, FAILURE
// }
//
// public TestResult(Type type, String description) {
// mType = type;
// mDescription = description;
// }
//
// public String getDescription() {
// return mDescription;
// }
//
// public Type getType() {
// return mType;
// }
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExamplePingGetIDTestScript.java
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.TestResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
package me.gregorias.dfuntest.example;
/**
* This TestScript checks whether applications will return all ids that were pinged to them.
*/
public class ExamplePingGetIDTestScript extends AbstractExampleTestScript {
private static final Logger LOGGER = LoggerFactory.getLogger(ExamplePingGetIDTestScript.class);
private static final int PING_ID = 1087;
@Override
public TestResult run(Collection<ExampleApp> apps) {
LOGGER.info("run()");
try {
startUpApps(apps); | } catch (CommandException | IOException e) { |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleApp.java | // Path: core/src/main/java/me/gregorias/dfuntest/App.java
// public abstract class App<EnvironmentT extends Environment> {
// private final int mId;
// private final String mName;
//
// public App(int id, String name) {
// mId = id;
// mName = name;
// }
//
// /**
// * @return Underlying environment
// */
// public abstract EnvironmentT getEnvironment();
//
// /**
// * @return Number identifying this application.
// */
// public int getId() {
// return mId;
// }
//
// /**
// * @return Human readable name of this application.
// */
// public String getName() {
// return mName;
// }
//
// /**
// * Starts the application and allows it to run in background.
// */
// @SuppressWarnings("unused")
// public abstract void startUp() throws CommandException, IOException;
//
// /**
// * Shuts down started application and deallocates all resources associated
// * with running application.
// */
// @SuppressWarnings("unused")
// public abstract void shutDown() throws IOException, InterruptedException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/Environment.java
// public interface Environment {
//
// /**
// * Copies specified file or directory to destination directory on environment.
// *
// * @param srcPath Local source path.
// * @param destRelPath Relative destination directory on this environment.
// */
// void copyFilesFromLocalDisk(Path srcPath, String destRelPath) throws IOException;
//
// /**
// * Copies specified file or directory to destination directory on local host.
// *
// * @param srcRelPath Relative source path on this environment.
// * @param destPath Local destination directory.
// */
// void copyFilesToLocalDisk(String srcRelPath, Path destPath) throws IOException;
//
// /**
// * @return Hostname of this environment. May be IP address, WWW address etc.
// */
// String getHostname();
//
// /**
// * @return Numeric identifier of this environment
// */
// int getId();
//
// /**
// * @return Human readable name for this environment
// */
// String getName();
//
// /**
// * Gets saved property.
// *
// * @param key property's key
// * @return value corresponding to given key
// * @throws NoSuchElementException thrown when given key is not present
// */
// Object getProperty(String key) throws NoSuchElementException;
//
// /**
// * Synchronously runs arbitrary command on this environment's OS.
// *
// * @param command Command to run
// * @return Finished process.
// */
// RemoteProcess runCommand(List<String> command) throws InterruptedException, IOException;
//
// RemoteProcess runCommandAsynchronously(List<String> command) throws IOException;
//
// /**
// * Removes specified file. If path targets a directory its content is removed as well.
// *
// * @param relPath Relative path to file on this environment.
// */
// void removeFile(String relPath) throws InterruptedException, IOException;
//
// /**
// * Set arbitrary property of this environment.
// *
// * @param key property's key
// * @param value property's value
// */
// void setProperty(String key, Object value);
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/RemoteProcess.java
// @SuppressWarnings("unused")
// public interface RemoteProcess {
// /**
// * Forcibly terminates the process.
// */
// void destroy() throws IOException;
//
// InputStream getErrorStream();
//
// InputStream getInputStream();
//
// OutputStream getOutputStream();
//
// /**
// * Blocks till process finishes and returns its exit code.
// *
// * @return exit value of process
// */
// int waitFor() throws InterruptedException, IOException;
// }
| import me.gregorias.dfuntest.App;
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.Environment;
import me.gregorias.dfuntest.RemoteProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;
import java.util.List; | package me.gregorias.dfuntest.example;
/**
* App interface to PingApplication which translates from Java's method calling to
* PingApplication web interface allowing easy use in test scripts.
*/
public class ExampleApp extends App<Environment> {
public static final String LOG_FILE = "stdlog.log";
public static final String LOCAL_PORT_ENV_FIELD = "local-port";
public static final String SERVER_HOSTNAME_ENV_FIELD = "server-hostname";
public static final String SERVER_PORT_ENV_FIELD = "server-port";
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class);
private final Environment mEnvironment;
private final InetSocketAddress mThisAppSocketAddress;
private final String mServerHostname;
private final int mServerPort;
| // Path: core/src/main/java/me/gregorias/dfuntest/App.java
// public abstract class App<EnvironmentT extends Environment> {
// private final int mId;
// private final String mName;
//
// public App(int id, String name) {
// mId = id;
// mName = name;
// }
//
// /**
// * @return Underlying environment
// */
// public abstract EnvironmentT getEnvironment();
//
// /**
// * @return Number identifying this application.
// */
// public int getId() {
// return mId;
// }
//
// /**
// * @return Human readable name of this application.
// */
// public String getName() {
// return mName;
// }
//
// /**
// * Starts the application and allows it to run in background.
// */
// @SuppressWarnings("unused")
// public abstract void startUp() throws CommandException, IOException;
//
// /**
// * Shuts down started application and deallocates all resources associated
// * with running application.
// */
// @SuppressWarnings("unused")
// public abstract void shutDown() throws IOException, InterruptedException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/Environment.java
// public interface Environment {
//
// /**
// * Copies specified file or directory to destination directory on environment.
// *
// * @param srcPath Local source path.
// * @param destRelPath Relative destination directory on this environment.
// */
// void copyFilesFromLocalDisk(Path srcPath, String destRelPath) throws IOException;
//
// /**
// * Copies specified file or directory to destination directory on local host.
// *
// * @param srcRelPath Relative source path on this environment.
// * @param destPath Local destination directory.
// */
// void copyFilesToLocalDisk(String srcRelPath, Path destPath) throws IOException;
//
// /**
// * @return Hostname of this environment. May be IP address, WWW address etc.
// */
// String getHostname();
//
// /**
// * @return Numeric identifier of this environment
// */
// int getId();
//
// /**
// * @return Human readable name for this environment
// */
// String getName();
//
// /**
// * Gets saved property.
// *
// * @param key property's key
// * @return value corresponding to given key
// * @throws NoSuchElementException thrown when given key is not present
// */
// Object getProperty(String key) throws NoSuchElementException;
//
// /**
// * Synchronously runs arbitrary command on this environment's OS.
// *
// * @param command Command to run
// * @return Finished process.
// */
// RemoteProcess runCommand(List<String> command) throws InterruptedException, IOException;
//
// RemoteProcess runCommandAsynchronously(List<String> command) throws IOException;
//
// /**
// * Removes specified file. If path targets a directory its content is removed as well.
// *
// * @param relPath Relative path to file on this environment.
// */
// void removeFile(String relPath) throws InterruptedException, IOException;
//
// /**
// * Set arbitrary property of this environment.
// *
// * @param key property's key
// * @param value property's value
// */
// void setProperty(String key, Object value);
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/RemoteProcess.java
// @SuppressWarnings("unused")
// public interface RemoteProcess {
// /**
// * Forcibly terminates the process.
// */
// void destroy() throws IOException;
//
// InputStream getErrorStream();
//
// InputStream getInputStream();
//
// OutputStream getOutputStream();
//
// /**
// * Blocks till process finishes and returns its exit code.
// *
// * @return exit value of process
// */
// int waitFor() throws InterruptedException, IOException;
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleApp.java
import me.gregorias.dfuntest.App;
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.Environment;
import me.gregorias.dfuntest.RemoteProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;
import java.util.List;
package me.gregorias.dfuntest.example;
/**
* App interface to PingApplication which translates from Java's method calling to
* PingApplication web interface allowing easy use in test scripts.
*/
public class ExampleApp extends App<Environment> {
public static final String LOG_FILE = "stdlog.log";
public static final String LOCAL_PORT_ENV_FIELD = "local-port";
public static final String SERVER_HOSTNAME_ENV_FIELD = "server-hostname";
public static final String SERVER_PORT_ENV_FIELD = "server-port";
private static final Logger LOGGER = LoggerFactory.getLogger(ExampleApp.class);
private final Environment mEnvironment;
private final InetSocketAddress mThisAppSocketAddress;
private final String mServerHostname;
private final int mServerPort;
| private RemoteProcess mProcess; |
gregorias/dfuntest | example/src/main/java/me/gregorias/dfuntest/example/ExampleApp.java | // Path: core/src/main/java/me/gregorias/dfuntest/App.java
// public abstract class App<EnvironmentT extends Environment> {
// private final int mId;
// private final String mName;
//
// public App(int id, String name) {
// mId = id;
// mName = name;
// }
//
// /**
// * @return Underlying environment
// */
// public abstract EnvironmentT getEnvironment();
//
// /**
// * @return Number identifying this application.
// */
// public int getId() {
// return mId;
// }
//
// /**
// * @return Human readable name of this application.
// */
// public String getName() {
// return mName;
// }
//
// /**
// * Starts the application and allows it to run in background.
// */
// @SuppressWarnings("unused")
// public abstract void startUp() throws CommandException, IOException;
//
// /**
// * Shuts down started application and deallocates all resources associated
// * with running application.
// */
// @SuppressWarnings("unused")
// public abstract void shutDown() throws IOException, InterruptedException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/Environment.java
// public interface Environment {
//
// /**
// * Copies specified file or directory to destination directory on environment.
// *
// * @param srcPath Local source path.
// * @param destRelPath Relative destination directory on this environment.
// */
// void copyFilesFromLocalDisk(Path srcPath, String destRelPath) throws IOException;
//
// /**
// * Copies specified file or directory to destination directory on local host.
// *
// * @param srcRelPath Relative source path on this environment.
// * @param destPath Local destination directory.
// */
// void copyFilesToLocalDisk(String srcRelPath, Path destPath) throws IOException;
//
// /**
// * @return Hostname of this environment. May be IP address, WWW address etc.
// */
// String getHostname();
//
// /**
// * @return Numeric identifier of this environment
// */
// int getId();
//
// /**
// * @return Human readable name for this environment
// */
// String getName();
//
// /**
// * Gets saved property.
// *
// * @param key property's key
// * @return value corresponding to given key
// * @throws NoSuchElementException thrown when given key is not present
// */
// Object getProperty(String key) throws NoSuchElementException;
//
// /**
// * Synchronously runs arbitrary command on this environment's OS.
// *
// * @param command Command to run
// * @return Finished process.
// */
// RemoteProcess runCommand(List<String> command) throws InterruptedException, IOException;
//
// RemoteProcess runCommandAsynchronously(List<String> command) throws IOException;
//
// /**
// * Removes specified file. If path targets a directory its content is removed as well.
// *
// * @param relPath Relative path to file on this environment.
// */
// void removeFile(String relPath) throws InterruptedException, IOException;
//
// /**
// * Set arbitrary property of this environment.
// *
// * @param key property's key
// * @param value property's value
// */
// void setProperty(String key, Object value);
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/RemoteProcess.java
// @SuppressWarnings("unused")
// public interface RemoteProcess {
// /**
// * Forcibly terminates the process.
// */
// void destroy() throws IOException;
//
// InputStream getErrorStream();
//
// InputStream getInputStream();
//
// OutputStream getOutputStream();
//
// /**
// * Blocks till process finishes and returns its exit code.
// *
// * @return exit value of process
// */
// int waitFor() throws InterruptedException, IOException;
// }
| import me.gregorias.dfuntest.App;
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.Environment;
import me.gregorias.dfuntest.RemoteProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;
import java.util.List; | public ExampleApp(int id, String name, Environment environment) {
super(id, name);
mEnvironment = environment;
int localPort = (Integer) mEnvironment.getProperty(LOCAL_PORT_ENV_FIELD);
mThisAppSocketAddress = new InetSocketAddress(mEnvironment.getHostname(), localPort);
mServerHostname = (String) mEnvironment.getProperty(SERVER_HOSTNAME_ENV_FIELD);
mServerPort = (Integer) mEnvironment.getProperty(SERVER_PORT_ENV_FIELD);
}
@Override
public Environment getEnvironment() {
return mEnvironment;
}
public List<Integer> getPingedIDs() throws IOException {
ByteBuffer getIDMessage = ByteBuffer.allocateDirect(1);
getIDMessage.put(PingApplication.GET_ID_TYPE);
getIDMessage.flip();
return sendMessageAndGetResponse(getIDMessage);
}
public void ping(int id) throws IOException {
ByteBuffer pingMessage = ByteBuffer.allocateDirect(PingApplication.PING_MESSAGE_LENGTH);
pingMessage.put(PingApplication.PING_TYPE);
pingMessage.putInt(id);
pingMessage.flip();
sendMessageAndGetResponse(pingMessage);
}
@Override | // Path: core/src/main/java/me/gregorias/dfuntest/App.java
// public abstract class App<EnvironmentT extends Environment> {
// private final int mId;
// private final String mName;
//
// public App(int id, String name) {
// mId = id;
// mName = name;
// }
//
// /**
// * @return Underlying environment
// */
// public abstract EnvironmentT getEnvironment();
//
// /**
// * @return Number identifying this application.
// */
// public int getId() {
// return mId;
// }
//
// /**
// * @return Human readable name of this application.
// */
// public String getName() {
// return mName;
// }
//
// /**
// * Starts the application and allows it to run in background.
// */
// @SuppressWarnings("unused")
// public abstract void startUp() throws CommandException, IOException;
//
// /**
// * Shuts down started application and deallocates all resources associated
// * with running application.
// */
// @SuppressWarnings("unused")
// public abstract void shutDown() throws IOException, InterruptedException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/CommandException.java
// @SuppressWarnings("unused")
// public class CommandException extends Exception {
// private static final long serialVersionUID = 1L;
//
// public CommandException() {
// super();
// }
//
// public CommandException(String message, Throwable cause,
// boolean enableSuppression, boolean writableStackTrace) {
// super(message, cause, enableSuppression, writableStackTrace);
// }
//
// public CommandException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public CommandException(String message) {
// super(message);
// }
//
// public CommandException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/Environment.java
// public interface Environment {
//
// /**
// * Copies specified file or directory to destination directory on environment.
// *
// * @param srcPath Local source path.
// * @param destRelPath Relative destination directory on this environment.
// */
// void copyFilesFromLocalDisk(Path srcPath, String destRelPath) throws IOException;
//
// /**
// * Copies specified file or directory to destination directory on local host.
// *
// * @param srcRelPath Relative source path on this environment.
// * @param destPath Local destination directory.
// */
// void copyFilesToLocalDisk(String srcRelPath, Path destPath) throws IOException;
//
// /**
// * @return Hostname of this environment. May be IP address, WWW address etc.
// */
// String getHostname();
//
// /**
// * @return Numeric identifier of this environment
// */
// int getId();
//
// /**
// * @return Human readable name for this environment
// */
// String getName();
//
// /**
// * Gets saved property.
// *
// * @param key property's key
// * @return value corresponding to given key
// * @throws NoSuchElementException thrown when given key is not present
// */
// Object getProperty(String key) throws NoSuchElementException;
//
// /**
// * Synchronously runs arbitrary command on this environment's OS.
// *
// * @param command Command to run
// * @return Finished process.
// */
// RemoteProcess runCommand(List<String> command) throws InterruptedException, IOException;
//
// RemoteProcess runCommandAsynchronously(List<String> command) throws IOException;
//
// /**
// * Removes specified file. If path targets a directory its content is removed as well.
// *
// * @param relPath Relative path to file on this environment.
// */
// void removeFile(String relPath) throws InterruptedException, IOException;
//
// /**
// * Set arbitrary property of this environment.
// *
// * @param key property's key
// * @param value property's value
// */
// void setProperty(String key, Object value);
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/RemoteProcess.java
// @SuppressWarnings("unused")
// public interface RemoteProcess {
// /**
// * Forcibly terminates the process.
// */
// void destroy() throws IOException;
//
// InputStream getErrorStream();
//
// InputStream getInputStream();
//
// OutputStream getOutputStream();
//
// /**
// * Blocks till process finishes and returns its exit code.
// *
// * @return exit value of process
// */
// int waitFor() throws InterruptedException, IOException;
// }
// Path: example/src/main/java/me/gregorias/dfuntest/example/ExampleApp.java
import me.gregorias.dfuntest.App;
import me.gregorias.dfuntest.CommandException;
import me.gregorias.dfuntest.Environment;
import me.gregorias.dfuntest.RemoteProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.EOFException;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.LinkedList;
import java.util.List;
public ExampleApp(int id, String name, Environment environment) {
super(id, name);
mEnvironment = environment;
int localPort = (Integer) mEnvironment.getProperty(LOCAL_PORT_ENV_FIELD);
mThisAppSocketAddress = new InetSocketAddress(mEnvironment.getHostname(), localPort);
mServerHostname = (String) mEnvironment.getProperty(SERVER_HOSTNAME_ENV_FIELD);
mServerPort = (Integer) mEnvironment.getProperty(SERVER_PORT_ENV_FIELD);
}
@Override
public Environment getEnvironment() {
return mEnvironment;
}
public List<Integer> getPingedIDs() throws IOException {
ByteBuffer getIDMessage = ByteBuffer.allocateDirect(1);
getIDMessage.put(PingApplication.GET_ID_TYPE);
getIDMessage.flip();
return sendMessageAndGetResponse(getIDMessage);
}
public void ping(int id) throws IOException {
ByteBuffer pingMessage = ByteBuffer.allocateDirect(PingApplication.PING_MESSAGE_LENGTH);
pingMessage.put(PingApplication.PING_TYPE);
pingMessage.putInt(id);
pingMessage.flip();
sendMessageAndGetResponse(pingMessage);
}
@Override | public synchronized void startUp() throws CommandException, IOException { |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/LocalEnvironmentTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder; | package me.gregorias.dfuntest;
public class LocalEnvironmentTest {
@Rule
public TemporaryFolder mTempFolder = new TemporaryFolder();
private static final String PREFIX = "NEBTMP";
private Path mEnvDir;
private Path mLocalDir;
private Environment mLocalEnvironment;
@Before
public void setUp() throws IOException {
mEnvDir = mTempFolder.newFolder().toPath();
mLocalDir = mTempFolder.newFolder().toPath();
| // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtilsImpl.java
// public class FileUtilsImpl implements FileUtils {
// private static FileUtilsImpl FILE_UTILS_IMPL = new FileUtilsImpl();
//
// @Override
// public void copyDirectoryToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyDirectoryToDirectory(from, to);
// }
//
// @Override
// public void copyFileToDirectory(File from, File to) throws IOException {
// org.apache.commons.io.FileUtils.copyFileToDirectory(from, to);
// }
//
// @Override
// public void createDirectories(Path path) throws IOException {
// Files.createDirectories(path);
// }
//
// @Override
// public Path createTempDirectory(String dirPrefix) throws IOException {
// return Files.createTempDirectory(dirPrefix);
// }
//
// @Override
// public boolean deleteQuietly(File file) {
// return org.apache.commons.io.FileUtils.deleteQuietly(file);
// }
//
// @Override
// public boolean exists(Path path) {
// return Files.exists(path);
// }
//
// public static FileUtilsImpl getFileUtilsImpl() {
// return FILE_UTILS_IMPL;
// }
//
// @Override
// public boolean isDirectory(Path path) {
// return Files.isDirectory(path);
// }
//
// @Override
// public Process runCommand(List<String> command, File pwdFile) throws IOException {
// ProcessBuilder pb = new ProcessBuilder();
// pb.command(command).directory(pwdFile);
// return pb.start();
// }
//
// @Override
// public void write(Path path, String content) throws IOException {
// StandardOpenOption[] options = new StandardOpenOption[3];
//
// options[0] = StandardOpenOption.CREATE;
// options[1] = StandardOpenOption.WRITE;
// options[2] = StandardOpenOption.APPEND;
//
// Collection<String> lines = new ArrayList<>();
// lines.add(content);
// Files.write(path, lines, Charset.defaultCharset(), options);
// }
// }
// Path: core/src/test/java/me/gregorias/dfuntest/LocalEnvironmentTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.FileUtilsImpl;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
package me.gregorias.dfuntest;
public class LocalEnvironmentTest {
@Rule
public TemporaryFolder mTempFolder = new TemporaryFolder();
private static final String PREFIX = "NEBTMP";
private Path mEnvDir;
private Path mLocalDir;
private Environment mLocalEnvironment;
@Before
public void setUp() throws IOException {
mEnvDir = mTempFolder.newFolder().toPath();
mLocalDir = mTempFolder.newFolder().toPath();
| mLocalEnvironment = new LocalEnvironment(0, mEnvDir, FileUtilsImpl.getFileUtilsImpl()); |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/ManualTestRunnerBuilderTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/testrunnerbuilders/ManualTestRunnerBuilder.java
// public class ManualTestRunnerBuilder<EnvironmentT extends Environment,
// AppT extends App<EnvironmentT>> {
// private EnvironmentFactory<EnvironmentT> mEnvironmentFactory;
// private EnvironmentPreparator<EnvironmentT> mEnvironmentPreparator;
// private ApplicationFactory<EnvironmentT, AppT> mApplicationFactory;
// private final Set<TestScript<AppT>> mTestScripts = new HashSet<>();
// private boolean mShouldPrepareEnvironments = true;
// private boolean mShouldCleanEnvironments = true;
// private Path mReportPath;
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> addTestScript(TestScript<AppT> testScript) {
// mTestScripts.add(testScript);
// return this;
// }
//
// public TestRunner buildRunner() {
// if (mTestScripts.size() == 0
// || null == mEnvironmentFactory
// || null == mEnvironmentPreparator
// || null == mApplicationFactory
// || null == mReportPath) {
// throw new IllegalStateException("One of runner's dependencies was not set.");
// }
//
// return new MultiTestRunner<>(
// mTestScripts,
// mEnvironmentFactory,
// mEnvironmentPreparator,
// mApplicationFactory,
// mShouldPrepareEnvironments,
// mShouldCleanEnvironments,
// mReportPath,
// FileUtilsImpl.getFileUtilsImpl());
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setApplicationFactory(
// ApplicationFactory<EnvironmentT, AppT> applicationFactory) {
// mApplicationFactory = applicationFactory;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setEnvironmentFactory(
// EnvironmentFactory<EnvironmentT> environmentFactory) {
// mEnvironmentFactory = environmentFactory;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setEnvironmentPreparator(
// EnvironmentPreparator<EnvironmentT> environmentPreparator) {
// mEnvironmentPreparator = environmentPreparator;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setReportPath(Path reportPath) {
// mReportPath = reportPath;
// return this;
// }
//
// /**
// * Sets whether preparator should prepare or just restore environments. True on default.
// * @param should should runner prepare environments
// * @return this
// */
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setShouldPrepareEnvironments(boolean should) {
// mShouldPrepareEnvironments = should;
// return this;
// }
//
// /**
// * Sets whether preparator should clean environments completely. True on default.
// * @param should should runner clean environments
// * @return this
// */
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setShouldCleanEnvironments(boolean should) {
// mShouldCleanEnvironments = should;
// return this;
// }
// }
| import me.gregorias.dfuntest.testrunnerbuilders.ManualTestRunnerBuilder;
import org.junit.Test;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock; | package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class ManualTestRunnerBuilderTest {
private final EnvironmentFactory<Environment> mMockEnvironmentFactory = mock(
EnvironmentFactory.class);
private final EnvironmentPreparator<Environment> mMockEnvironmentPreparator = mock(
EnvironmentPreparator.class);
private final ApplicationFactory<Environment, App<Environment>> mMockApplicationFactory = mock(
ApplicationFactory.class);
private final TestScript<App<Environment>> mMockTestScript = mock(TestScript.class);
private final Path mReportPath = FileSystems.getDefault().getPath("report");
@Test
public void buildShouldCreateMultiTestRunner() { | // Path: core/src/main/java/me/gregorias/dfuntest/testrunnerbuilders/ManualTestRunnerBuilder.java
// public class ManualTestRunnerBuilder<EnvironmentT extends Environment,
// AppT extends App<EnvironmentT>> {
// private EnvironmentFactory<EnvironmentT> mEnvironmentFactory;
// private EnvironmentPreparator<EnvironmentT> mEnvironmentPreparator;
// private ApplicationFactory<EnvironmentT, AppT> mApplicationFactory;
// private final Set<TestScript<AppT>> mTestScripts = new HashSet<>();
// private boolean mShouldPrepareEnvironments = true;
// private boolean mShouldCleanEnvironments = true;
// private Path mReportPath;
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> addTestScript(TestScript<AppT> testScript) {
// mTestScripts.add(testScript);
// return this;
// }
//
// public TestRunner buildRunner() {
// if (mTestScripts.size() == 0
// || null == mEnvironmentFactory
// || null == mEnvironmentPreparator
// || null == mApplicationFactory
// || null == mReportPath) {
// throw new IllegalStateException("One of runner's dependencies was not set.");
// }
//
// return new MultiTestRunner<>(
// mTestScripts,
// mEnvironmentFactory,
// mEnvironmentPreparator,
// mApplicationFactory,
// mShouldPrepareEnvironments,
// mShouldCleanEnvironments,
// mReportPath,
// FileUtilsImpl.getFileUtilsImpl());
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setApplicationFactory(
// ApplicationFactory<EnvironmentT, AppT> applicationFactory) {
// mApplicationFactory = applicationFactory;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setEnvironmentFactory(
// EnvironmentFactory<EnvironmentT> environmentFactory) {
// mEnvironmentFactory = environmentFactory;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setEnvironmentPreparator(
// EnvironmentPreparator<EnvironmentT> environmentPreparator) {
// mEnvironmentPreparator = environmentPreparator;
// return this;
// }
//
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setReportPath(Path reportPath) {
// mReportPath = reportPath;
// return this;
// }
//
// /**
// * Sets whether preparator should prepare or just restore environments. True on default.
// * @param should should runner prepare environments
// * @return this
// */
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setShouldPrepareEnvironments(boolean should) {
// mShouldPrepareEnvironments = should;
// return this;
// }
//
// /**
// * Sets whether preparator should clean environments completely. True on default.
// * @param should should runner clean environments
// * @return this
// */
// public ManualTestRunnerBuilder<EnvironmentT, AppT> setShouldCleanEnvironments(boolean should) {
// mShouldCleanEnvironments = should;
// return this;
// }
// }
// Path: core/src/test/java/me/gregorias/dfuntest/ManualTestRunnerBuilderTest.java
import me.gregorias.dfuntest.testrunnerbuilders.ManualTestRunnerBuilder;
import org.junit.Test;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class ManualTestRunnerBuilderTest {
private final EnvironmentFactory<Environment> mMockEnvironmentFactory = mock(
EnvironmentFactory.class);
private final EnvironmentPreparator<Environment> mMockEnvironmentPreparator = mock(
EnvironmentPreparator.class);
private final ApplicationFactory<Environment, App<Environment>> mMockApplicationFactory = mock(
ApplicationFactory.class);
private final TestScript<App<Environment>> mMockTestScript = mock(TestScript.class);
private final Path mReportPath = FileSystems.getDefault().getPath("report");
@Test
public void buildShouldCreateMultiTestRunner() { | ManualTestRunnerBuilder<Environment, App<Environment>> builder = |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/SSHEnvironmentTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.ConnectionException;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile;
import net.schmizz.sshj.xfer.scp.SCPFileTransfer;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.contains;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class SSHEnvironmentTest {
private static final int ID = 0;
private static final String USERNAME = "username";
private static final Path PRIVATE_KEY_PATH = FileSystems.getDefault().getPath("key");
private static final InetAddress REMOTE_ADDRESS = InetAddress.getLoopbackAddress();
private static final String REMOTE_HOME_PATH = "home";
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
private SSHClient mMockSSHClient = null;
private SSHEnvironment mSSHEnv = null; | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/test/java/me/gregorias/dfuntest/SSHEnvironmentTest.java
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.ConnectionException;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile;
import net.schmizz.sshj.xfer.scp.SCPFileTransfer;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.contains;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class SSHEnvironmentTest {
private static final int ID = 0;
private static final String USERNAME = "username";
private static final Path PRIVATE_KEY_PATH = FileSystems.getDefault().getPath("key");
private static final InetAddress REMOTE_ADDRESS = InetAddress.getLoopbackAddress();
private static final String REMOTE_HOME_PATH = "home";
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
private SSHClient mMockSSHClient = null;
private SSHEnvironment mSSHEnv = null; | private FileUtils mMockFileUtils = null; |
gregorias/dfuntest | core/src/test/java/me/gregorias/dfuntest/SSHEnvironmentTest.java | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
| import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.ConnectionException;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile;
import net.schmizz.sshj.xfer.scp.SCPFileTransfer;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.contains;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class SSHEnvironmentTest {
private static final int ID = 0;
private static final String USERNAME = "username";
private static final Path PRIVATE_KEY_PATH = FileSystems.getDefault().getPath("key");
private static final InetAddress REMOTE_ADDRESS = InetAddress.getLoopbackAddress();
private static final String REMOTE_HOME_PATH = "home";
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
private SSHClient mMockSSHClient = null;
private SSHEnvironment mSSHEnv = null;
private FileUtils mMockFileUtils = null;
@Before
public void setUp() { | // Path: core/src/main/java/me/gregorias/dfuntest/util/FileUtils.java
// public interface FileUtils {
// /**
// * {@link org.apache.commons.io.FileUtils#copyDirectoryToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyDirectoryToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#copyFileToDirectory(java.io.File, java.io.File)}
// *
// * @param from Source path
// * @param to Target directory path
// */
// void copyFileToDirectory(File from, File to) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createDirectories(java.nio.file.Path,
// * java.nio.file.attribute.FileAttribute[])}
// *
// * @param path Path to create
// */
// void createDirectories(Path path) throws IOException;
//
// /**
// * {@link java.nio.file.Files#createTempDirectory(
// * String, java.nio.file.attribute.FileAttribute[])}
// *
// * @param dirPrefix prefix of temporary directory
// * @return Path to created directory
// */
// Path createTempDirectory(String dirPrefix) throws IOException;
//
// /**
// * {@link org.apache.commons.io.FileUtils#deleteQuietly(java.io.File)}
// *
// * @param file File to delete
// * @return true iff directory was deleted
// */
// boolean deleteQuietly(File file);
//
// /**
// * {@link java.nio.file.Files#exists(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff exists
// */
// boolean exists(Path path);
//
// /**
// * {@link java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...)}
// *
// * @param path path to check
// * @return true iff path is a directory
// */
// boolean isDirectory(Path path);
//
// /**
// * {@link java.lang.ProcessBuilder}
// *
// * @param command command to run
// * @param pwdFile working directory of the process
// * @return process running the command
// */
// Process runCommand(List<String> command, File pwdFile) throws IOException;
//
// /**
// * {@link java.nio.file.Files#write(java.nio.file.Path, Iterable, java.nio.charset.Charset,
// * java.nio.file.OpenOption...)}
// *
// * @param path Path of file to write to.
// * @param content String to be written to file.
// */
// void write(Path path, String content) throws IOException;
// }
//
// Path: core/src/main/java/me/gregorias/dfuntest/util/SSHClientFactory.java
// public class SSHClientFactory {
// private static SSHClientFactory SSH_CLIENT_FACTORY = null;
//
// public static synchronized SSHClientFactory getSSHClientFactory() {
// if (SSH_CLIENT_FACTORY == null) {
// SSH_CLIENT_FACTORY = new SSHClientFactory();
// }
// return SSH_CLIENT_FACTORY;
// }
//
// public SSHClient newSSHClient() {
// return new SSHClient();
// }
// }
// Path: core/src/test/java/me/gregorias/dfuntest/SSHEnvironmentTest.java
import me.gregorias.dfuntest.util.FileUtils;
import me.gregorias.dfuntest.util.SSHClientFactory;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.connection.ConnectionException;
import net.schmizz.sshj.connection.channel.direct.Session;
import net.schmizz.sshj.connection.channel.direct.Session.Command;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile;
import net.schmizz.sshj.xfer.scp.SCPFileTransfer;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.contains;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package me.gregorias.dfuntest;
@SuppressWarnings("unchecked")
public class SSHEnvironmentTest {
private static final int ID = 0;
private static final String USERNAME = "username";
private static final Path PRIVATE_KEY_PATH = FileSystems.getDefault().getPath("key");
private static final InetAddress REMOTE_ADDRESS = InetAddress.getLoopbackAddress();
private static final String REMOTE_HOME_PATH = "home";
private static final Executor EXECUTOR = Executors.newSingleThreadExecutor();
private SSHClient mMockSSHClient = null;
private SSHEnvironment mSSHEnv = null;
private FileUtils mMockFileUtils = null;
@Before
public void setUp() { | SSHClientFactory mockSSHClientFactory = mock(SSHClientFactory.class); |
Thomas-Bergmann/Tournament | de.hatoka.group/src/main/java/de/hatoka/group/capi/entities/MemberPO.java | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/IdentifiableEntity.java
// public interface IdentifiableEntity
// {
// String getId();
//
// void setId(String id);
// }
| import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import de.hatoka.common.capi.dao.IdentifiableEntity; | package de.hatoka.group.capi.entities;
@Entity
@NamedQueries(value = {
@NamedQuery(name = "MemberPO.findByUserRef", query = "select a from MemberPO a where a.userRef = :userRef")
}) | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/IdentifiableEntity.java
// public interface IdentifiableEntity
// {
// String getId();
//
// void setId(String id);
// }
// Path: de.hatoka.group/src/main/java/de/hatoka/group/capi/entities/MemberPO.java
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import de.hatoka.common.capi.dao.IdentifiableEntity;
package de.hatoka.group.capi.entities;
@Entity
@NamedQueries(value = {
@NamedQuery(name = "MemberPO.findByUserRef", query = "select a from MemberPO a where a.userRef = :userRef")
}) | public class MemberPO implements Serializable, IdentifiableEntity |
Thomas-Bergmann/Tournament | de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
| import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa; | package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton(); | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java
import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa;
package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton(); | binder.bind(PlayerDao.class).to(PlayerDaoJpa.class).asEagerSingleton(); |
Thomas-Bergmann/Tournament | de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
| import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa; | package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton(); | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java
import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa;
package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton(); | binder.bind(PlayerDao.class).to(PlayerDaoJpa.class).asEagerSingleton(); |
Thomas-Bergmann/Tournament | de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
| import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa; | package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton();
binder.bind(PlayerDao.class).to(PlayerDaoJpa.class).asEagerSingleton();
binder.bind(CompetitorDao.class).to(CompetitorDaoJpa.class).asEagerSingleton(); | // Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/HistoryDao.java
// public interface HistoryDao extends Dao<HistoryPO>
// {
// /**
// * Add history entry to tournament
// * @param tournamentPO
// * @param playerPO
// * @param date
// * @return
// */
// HistoryPO createAndInsert(TournamentPO tournamentPO, String player, Date date);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
// public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
// {
// @Inject
// private UUIDGenerator uuidGenerator;
//
// @Inject
// private CompetitorDao competitorDao;
//
// public PlayerDaoJpa()
// {
// super(PlayerPO.class);
// }
//
// @Override
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name)
// {
// PlayerPO result = create();
// result.setId(uuidGenerator.generate());
// result.setAccountRef(accountRef);
// result.setExternalRef(externalRef);
// result.setName(name);
// insert(result);
// return result;
// }
//
// @Override
// public PlayerPO findByExternalRef(String accountRef, String externalRef)
// {
// return getOptionalResult(createNamedQuery("PlayerPO.findByExternalRef").setParameter("accountRef", accountRef).setParameter("externalRef", externalRef));
// }
//
// @Override
// public PlayerPO findByName(String accountRef, String name)
// {
// return createNamedQuery("PlayerPO.findByName").setParameter("accountRef", accountRef).setParameter("name", name).getSingleResult();
// }
//
// @Override
// public List<PlayerPO> getByAccountRef(String accountRef)
// {
// return createNamedQuery("PlayerPO.findByAccountRef").setParameter("accountRef", accountRef).getResultList();
// }
//
// @Override
// public void remove(PlayerPO playerPO)
// {
// new ArrayList<>(playerPO.getCompetitors()).forEach(element -> competitorDao.remove(element));
// super.remove(playerPO);
// }
//
// }
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/modules/TournamentDaoJpaModule.java
import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.tournament.capi.dao.BlindLevelDao;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.HistoryDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.dao.RankDao;
import de.hatoka.tournament.capi.dao.TournamentDao;
import de.hatoka.tournament.internal.dao.BlindLevelDaoJpa;
import de.hatoka.tournament.internal.dao.CompetitorDaoJpa;
import de.hatoka.tournament.internal.dao.HistoryDaoJpa;
import de.hatoka.tournament.internal.dao.PlayerDaoJpa;
import de.hatoka.tournament.internal.dao.RankDaoJpa;
import de.hatoka.tournament.internal.dao.TournamentDaoJpa;
package de.hatoka.tournament.modules;
public class TournamentDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{
binder.bind(TournamentDao.class).to(TournamentDaoJpa.class).asEagerSingleton();
binder.bind(PlayerDao.class).to(PlayerDaoJpa.class).asEagerSingleton();
binder.bind(CompetitorDao.class).to(CompetitorDaoJpa.class).asEagerSingleton(); | binder.bind(HistoryDao.class).to(HistoryDaoJpa.class).asEagerSingleton(); |
Thomas-Bergmann/Tournament | de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/UUIDGenerator.java
// public interface UUIDGenerator
// {
// public String generate();
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/entities/PlayerPO.java
// @Entity
// @NamedQueries(value = {
// @NamedQuery(name = "PlayerPO.findByAccountRef", query = "select a from PlayerPO a where a.accountRef = :accountRef"),
// @NamedQuery(name = "PlayerPO.findByName", query = "select a from PlayerPO a where a.accountRef = :accountRef and a.name = :name"),
// @NamedQuery(name = "PlayerPO.findByExternalRef", query = "select a from PlayerPO a where a.accountRef = :accountRef and a.externalRef = :externalRef")
// })
// @XmlRootElement(name="player")
// public class PlayerPO implements Serializable, IdentifiableEntity
// {
// private static final long serialVersionUID = 1L;
//
// @XmlTransient
// @Id
// private String id;
//
// @NotNull
// @XmlID
// @XmlAttribute(name="id")
// private String externalRef;
//
// @NotNull
// private String accountRef;
//
// @NotNull
// @XmlAttribute
// private String name;
//
// @XmlAttribute
// private String eMail;
//
// @Override
// public int hashCode()
// {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((accountRef == null) ? 0 : accountRef.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj)
// {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PlayerPO other = (PlayerPO)obj;
// if (accountRef == null)
// {
// if (other.accountRef != null)
// return false;
// }
// else if (!accountRef.equals(other.accountRef))
// return false;
// if (name == null)
// {
// if (other.name != null)
// return false;
// }
// else if (!name.equals(other.name))
// return false;
// return true;
// }
//
// @OneToMany(mappedBy = "playerRef")
// @XmlTransient
// private Set<CompetitorPO> competitors = new HashSet<>();
//
// public PlayerPO()
// {
// }
//
// @XmlTransient
// public String getAccountRef()
// {
// return accountRef;
// }
//
// @XmlTransient
// public Set<CompetitorPO> getCompetitors()
// {
// return competitors;
// }
//
// @Override
// @XmlTransient
// public String getId()
// {
// return id;
// }
//
// @XmlTransient
// public String getName()
// {
// return name;
// }
//
// public void setAccountRef(String accountRef)
// {
// this.accountRef = accountRef;
// }
//
// public void setCompetitors(Set<CompetitorPO> competitors)
// {
// this.competitors = competitors;
// }
//
// @Override
// public void setId(String id)
// {
// this.id = id;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// @XmlTransient
// public String getExternalRef()
// {
// return externalRef;
// }
//
// public void setExternalRef(String externalRef)
// {
// this.externalRef = externalRef;
// }
//
// @XmlTransient
// public String getEMail()
// {
// return eMail;
// }
//
// public void setEMail(String eMail)
// {
// this.eMail = eMail;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import de.hatoka.common.capi.dao.GenericJPADao;
import de.hatoka.common.capi.dao.UUIDGenerator;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.entities.PlayerPO; | package de.hatoka.tournament.internal.dao;
public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
{
@Inject | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/UUIDGenerator.java
// public interface UUIDGenerator
// {
// public String generate();
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/dao/PlayerDao.java
// public interface PlayerDao extends Dao<PlayerPO>
// {
// /**
// * @param accountRef
// * @param name
// * of player
// * @return
// */
// public PlayerPO createAndInsert(String accountRef, String externalRef, String name);
//
// public PlayerPO findByName(String accountRef, String name);
//
// public PlayerPO findByExternalRef(String accountRef, String externalRef);
//
// public Collection<PlayerPO> getByAccountRef(String accountRef);
// }
//
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/capi/entities/PlayerPO.java
// @Entity
// @NamedQueries(value = {
// @NamedQuery(name = "PlayerPO.findByAccountRef", query = "select a from PlayerPO a where a.accountRef = :accountRef"),
// @NamedQuery(name = "PlayerPO.findByName", query = "select a from PlayerPO a where a.accountRef = :accountRef and a.name = :name"),
// @NamedQuery(name = "PlayerPO.findByExternalRef", query = "select a from PlayerPO a where a.accountRef = :accountRef and a.externalRef = :externalRef")
// })
// @XmlRootElement(name="player")
// public class PlayerPO implements Serializable, IdentifiableEntity
// {
// private static final long serialVersionUID = 1L;
//
// @XmlTransient
// @Id
// private String id;
//
// @NotNull
// @XmlID
// @XmlAttribute(name="id")
// private String externalRef;
//
// @NotNull
// private String accountRef;
//
// @NotNull
// @XmlAttribute
// private String name;
//
// @XmlAttribute
// private String eMail;
//
// @Override
// public int hashCode()
// {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((accountRef == null) ? 0 : accountRef.hashCode());
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj)
// {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// PlayerPO other = (PlayerPO)obj;
// if (accountRef == null)
// {
// if (other.accountRef != null)
// return false;
// }
// else if (!accountRef.equals(other.accountRef))
// return false;
// if (name == null)
// {
// if (other.name != null)
// return false;
// }
// else if (!name.equals(other.name))
// return false;
// return true;
// }
//
// @OneToMany(mappedBy = "playerRef")
// @XmlTransient
// private Set<CompetitorPO> competitors = new HashSet<>();
//
// public PlayerPO()
// {
// }
//
// @XmlTransient
// public String getAccountRef()
// {
// return accountRef;
// }
//
// @XmlTransient
// public Set<CompetitorPO> getCompetitors()
// {
// return competitors;
// }
//
// @Override
// @XmlTransient
// public String getId()
// {
// return id;
// }
//
// @XmlTransient
// public String getName()
// {
// return name;
// }
//
// public void setAccountRef(String accountRef)
// {
// this.accountRef = accountRef;
// }
//
// public void setCompetitors(Set<CompetitorPO> competitors)
// {
// this.competitors = competitors;
// }
//
// @Override
// public void setId(String id)
// {
// this.id = id;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// @XmlTransient
// public String getExternalRef()
// {
// return externalRef;
// }
//
// public void setExternalRef(String externalRef)
// {
// this.externalRef = externalRef;
// }
//
// @XmlTransient
// public String getEMail()
// {
// return eMail;
// }
//
// public void setEMail(String eMail)
// {
// this.eMail = eMail;
// }
//
// }
// Path: de.hatoka.tournament/src/main/java/de/hatoka/tournament/internal/dao/PlayerDaoJpa.java
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import de.hatoka.common.capi.dao.GenericJPADao;
import de.hatoka.common.capi.dao.UUIDGenerator;
import de.hatoka.tournament.capi.dao.CompetitorDao;
import de.hatoka.tournament.capi.dao.PlayerDao;
import de.hatoka.tournament.capi.entities.PlayerPO;
package de.hatoka.tournament.internal.dao;
public class PlayerDaoJpa extends GenericJPADao<PlayerPO> implements PlayerDao
{
@Inject | private UUIDGenerator uuidGenerator; |
Thomas-Bergmann/Tournament | de.hatoka.user/src/main/java/de/hatoka/user/capi/entities/UserPO.java | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/IdentifiableEntity.java
// public interface IdentifiableEntity
// {
// String getId();
//
// void setId(String id);
// }
| import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.validation.constraints.NotNull;
import de.hatoka.common.capi.dao.IdentifiableEntity; | package de.hatoka.user.capi.entities;
@Entity
@NamedQuery(name = "UserPO.findByLogin", query = "select a from UserPO a where a.login = :login") | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/dao/IdentifiableEntity.java
// public interface IdentifiableEntity
// {
// String getId();
//
// void setId(String id);
// }
// Path: de.hatoka.user/src/main/java/de/hatoka/user/capi/entities/UserPO.java
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.validation.constraints.NotNull;
import de.hatoka.common.capi.dao.IdentifiableEntity;
package de.hatoka.user.capi.entities;
@Entity
@NamedQuery(name = "UserPO.findByLogin", query = "select a from UserPO a where a.login = :login") | public class UserPO implements Serializable, IdentifiableEntity |
Thomas-Bergmann/Tournament | de.hatoka.common/src/main/java/de/hatoka/common/capi/app/xslt/DateXmlAdapter.java | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/resource/LocalizationConstants.java
// public class LocalizationConstants
// {
// public static final String XML_DATEFORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
// public static final String XML_DATEFORMAT_SECONDS = "yyyy-MM-dd'T'HH:mm:ssXXX";
// public static final String XML_DATEFORMAT_MINUTES = "yyyy-MM-dd'T'HH:mm";
// }
| import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import de.hatoka.common.capi.business.CountryHelper;
import de.hatoka.common.capi.resource.LocalizationConstants; | package de.hatoka.common.capi.app.xslt;
public class DateXmlAdapter extends XmlAdapter<String, Date>
{
private final SimpleDateFormat dateFormat;
public DateXmlAdapter()
{ | // Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/resource/LocalizationConstants.java
// public class LocalizationConstants
// {
// public static final String XML_DATEFORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
// public static final String XML_DATEFORMAT_SECONDS = "yyyy-MM-dd'T'HH:mm:ssXXX";
// public static final String XML_DATEFORMAT_MINUTES = "yyyy-MM-dd'T'HH:mm";
// }
// Path: de.hatoka.common/src/main/java/de/hatoka/common/capi/app/xslt/DateXmlAdapter.java
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import de.hatoka.common.capi.business.CountryHelper;
import de.hatoka.common.capi.resource.LocalizationConstants;
package de.hatoka.common.capi.app.xslt;
public class DateXmlAdapter extends XmlAdapter<String, Date>
{
private final SimpleDateFormat dateFormat;
public DateXmlAdapter()
{ | dateFormat = new SimpleDateFormat(LocalizationConstants.XML_DATEFORMAT_SECONDS); |
Thomas-Bergmann/Tournament | de.hatoka.user/src/main/java/de/hatoka/user/internal/modules/UserDaoJpaModule.java | // Path: de.hatoka.user/src/main/java/de/hatoka/user/capi/dao/UserDao.java
// public interface UserDao extends Dao<UserPO>
// {
// /**
// *
// * @param login
// * @return
// */
// public UserPO createAndInsert(String login);
//
// /**
// *
// * @param login
// * @return user with the given login
// */
// public UserPO getByLogin(String login);
//
// }
| import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.user.capi.dao.UserDao;
import de.hatoka.user.internal.dao.UserDaoJpa; | package de.hatoka.user.internal.modules;
public class UserDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{ | // Path: de.hatoka.user/src/main/java/de/hatoka/user/capi/dao/UserDao.java
// public interface UserDao extends Dao<UserPO>
// {
// /**
// *
// * @param login
// * @return
// */
// public UserPO createAndInsert(String login);
//
// /**
// *
// * @param login
// * @return user with the given login
// */
// public UserPO getByLogin(String login);
//
// }
// Path: de.hatoka.user/src/main/java/de/hatoka/user/internal/modules/UserDaoJpaModule.java
import com.google.inject.Binder;
import com.google.inject.Module;
import de.hatoka.user.capi.dao.UserDao;
import de.hatoka.user.internal.dao.UserDaoJpa;
package de.hatoka.user.internal.modules;
public class UserDaoJpaModule implements Module
{
@Override
public void configure(Binder binder)
{ | binder.bind(UserDao.class).to(UserDaoJpa.class).asEagerSingleton(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.