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
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/bolt/AmConfigurationBolt.java
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // }
import java.util.Map; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.bolt; /** * BaseBolt, this class has the following values ​​in the field, <br> * and auto extract {@link acromusashi.stream.entity.StreamMessage} from {@link backtype.storm.tuple.Tuple}. * * <ol> * <li>Storm configuration</li> * <li>Topology context</li> * <li>SpoutOutputCollector</li> * </ol> */ public abstract class AmConfigurationBolt extends BaseRichBolt { /** serialVersionUID */ private static final long serialVersionUID = 103046340453102132L; /** StormConfig */ @SuppressWarnings("rawtypes") private Map stormConf; /** TopologyContext */ private TopologyContext context; /** OutputCollector */ private OutputCollector collector; /** Executing Tuple */ private Tuple executingTuple; /** * {@inheritDoc} */ @SuppressWarnings("rawtypes") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.stormConf = stormConf; this.context = context; this.collector = collector; } /** * {@inheritDoc} */ @Override public void execute(Tuple input) { // extract message from Tuple this.executingTuple = input;
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // Path: src/main/java/acromusashi/stream/bolt/AmConfigurationBolt.java import java.util.Map; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.bolt; /** * BaseBolt, this class has the following values ​​in the field, <br> * and auto extract {@link acromusashi.stream.entity.StreamMessage} from {@link backtype.storm.tuple.Tuple}. * * <ol> * <li>Storm configuration</li> * <li>Topology context</li> * <li>SpoutOutputCollector</li> * </ol> */ public abstract class AmConfigurationBolt extends BaseRichBolt { /** serialVersionUID */ private static final long serialVersionUID = 103046340453102132L; /** StormConfig */ @SuppressWarnings("rawtypes") private Map stormConf; /** TopologyContext */ private TopologyContext context; /** OutputCollector */ private OutputCollector collector; /** Executing Tuple */ private Tuple executingTuple; /** * {@inheritDoc} */ @SuppressWarnings("rawtypes") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.stormConf = stormConf; this.context = context; this.collector = collector; } /** * {@inheritDoc} */ @Override public void execute(Tuple input) { // extract message from Tuple this.executingTuple = input;
StreamMessage message = null;
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/bolt/AmConfigurationBolt.java
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // }
import java.util.Map; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.bolt; /** * BaseBolt, this class has the following values ​​in the field, <br> * and auto extract {@link acromusashi.stream.entity.StreamMessage} from {@link backtype.storm.tuple.Tuple}. * * <ol> * <li>Storm configuration</li> * <li>Topology context</li> * <li>SpoutOutputCollector</li> * </ol> */ public abstract class AmConfigurationBolt extends BaseRichBolt { /** serialVersionUID */ private static final long serialVersionUID = 103046340453102132L; /** StormConfig */ @SuppressWarnings("rawtypes") private Map stormConf; /** TopologyContext */ private TopologyContext context; /** OutputCollector */ private OutputCollector collector; /** Executing Tuple */ private Tuple executingTuple; /** * {@inheritDoc} */ @SuppressWarnings("rawtypes") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.stormConf = stormConf; this.context = context; this.collector = collector; } /** * {@inheritDoc} */ @Override public void execute(Tuple input) { // extract message from Tuple this.executingTuple = input; StreamMessage message = null; boolean messageGet = false;
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // Path: src/main/java/acromusashi/stream/bolt/AmConfigurationBolt.java import java.util.Map; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.tuple.Tuple; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.bolt; /** * BaseBolt, this class has the following values ​​in the field, <br> * and auto extract {@link acromusashi.stream.entity.StreamMessage} from {@link backtype.storm.tuple.Tuple}. * * <ol> * <li>Storm configuration</li> * <li>Topology context</li> * <li>SpoutOutputCollector</li> * </ol> */ public abstract class AmConfigurationBolt extends BaseRichBolt { /** serialVersionUID */ private static final long serialVersionUID = 103046340453102132L; /** StormConfig */ @SuppressWarnings("rawtypes") private Map stormConf; /** TopologyContext */ private TopologyContext context; /** OutputCollector */ private OutputCollector collector; /** Executing Tuple */ private Tuple executingTuple; /** * {@inheritDoc} */ @SuppressWarnings("rawtypes") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.stormConf = stormConf; this.context = context; this.collector = collector; } /** * {@inheritDoc} */ @Override public void execute(Tuple input) { // extract message from Tuple this.executingTuple = input; StreamMessage message = null; boolean messageGet = false;
if (input.contains(FieldName.MESSAGE_VALUE) == true)
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/infinispan/SimpleCacheMapper.java
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // }
import acromusashi.stream.exception.ConvertFailException; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Tuple中の指定したキーから値を取得してKey、Valueを生成するSimpleなMapper * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public class SimpleCacheMapper<K, V> implements TupleCacheMapper<K, V> { /** serialVersionUID */ private static final long serialVersionUID = 883625725130826587L; /** Key用フィールドID */
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // } // Path: src/main/java/acromusashi/stream/component/infinispan/SimpleCacheMapper.java import acromusashi.stream.exception.ConvertFailException; import acromusashi.stream.constants.FieldName; import acromusashi.stream.entity.StreamMessage; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Tuple中の指定したキーから値を取得してKey、Valueを生成するSimpleなMapper * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public class SimpleCacheMapper<K, V> implements TupleCacheMapper<K, V> { /** serialVersionUID */ private static final long serialVersionUID = 883625725130826587L; /** Key用フィールドID */
private String keyField = FieldName.MESSAGE_KEY;
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/infinispan/TupleCacheMapper.java
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // }
import acromusashi.stream.entity.StreamMessage; import acromusashi.stream.exception.ConvertFailException; import java.io.Serializable;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Cacheに保存するKey、ValueをTupleから生成する変換インタフェース * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public interface TupleCacheMapper<K, V> extends Serializable { /** * Cacheに保存するKeyを生成する。 * * @param input received message * @return Cacheに保存するKey * @throws ConvertFailException 変換失敗時 */
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // } // Path: src/main/java/acromusashi/stream/component/infinispan/TupleCacheMapper.java import acromusashi.stream.entity.StreamMessage; import acromusashi.stream.exception.ConvertFailException; import java.io.Serializable; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Cacheに保存するKey、ValueをTupleから生成する変換インタフェース * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public interface TupleCacheMapper<K, V> extends Serializable { /** * Cacheに保存するKeyを生成する。 * * @param input received message * @return Cacheに保存するKey * @throws ConvertFailException 変換失敗時 */
K convertToKey(StreamMessage input) throws ConvertFailException;
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/infinispan/TupleCacheMapper.java
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // }
import acromusashi.stream.entity.StreamMessage; import acromusashi.stream.exception.ConvertFailException; import java.io.Serializable;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Cacheに保存するKey、ValueをTupleから生成する変換インタフェース * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public interface TupleCacheMapper<K, V> extends Serializable { /** * Cacheに保存するKeyを生成する。 * * @param input received message * @return Cacheに保存するKey * @throws ConvertFailException 変換失敗時 */
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConvertFailException.java // public class ConvertFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConvertFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConvertFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConvertFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConvertFailException(Throwable cause) // { // super(cause); // } // } // Path: src/main/java/acromusashi/stream/component/infinispan/TupleCacheMapper.java import acromusashi.stream.entity.StreamMessage; import acromusashi.stream.exception.ConvertFailException; import java.io.Serializable; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.infinispan; /** * Cacheに保存するKey、ValueをTupleから生成する変換インタフェース * * @author kimura * * @param <K> InfinispanCacheKeyの型 * @param <V> InfinispanCacheValueの型 */ public interface TupleCacheMapper<K, V> extends Serializable { /** * Cacheに保存するKeyを生成する。 * * @param input received message * @return Cacheに保存するKey * @throws ConvertFailException 変換失敗時 */
K convertToKey(StreamMessage input) throws ConvertFailException;
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/elasticsearch/bolt/EsTupleConverter.java
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // }
import acromusashi.stream.entity.StreamMessage; import java.io.Serializable;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.elasticsearch.bolt; /** * Storm TupleをElastic Searchに投入するIndex Requestに変換するコンバータインタフェース * * @author kimura */ public interface EsTupleConverter extends Serializable { /** * Storm TupleからElastic SearchにIndex Requestを投入する際のIndex Nameを生成する * * @param message received message * @return Index Name */
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // Path: src/main/java/acromusashi/stream/component/elasticsearch/bolt/EsTupleConverter.java import acromusashi.stream.entity.StreamMessage; import java.io.Serializable; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.elasticsearch.bolt; /** * Storm TupleをElastic Searchに投入するIndex Requestに変換するコンバータインタフェース * * @author kimura */ public interface EsTupleConverter extends Serializable { /** * Storm TupleからElastic SearchにIndex Requestを投入する際のIndex Nameを生成する * * @param message received message * @return Index Name */
String convertToIndex(StreamMessage message);
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/entity/StreamMessageHeader.java
// Path: src/main/java/acromusashi/stream/trace/KeyHistory.java // public class KeyHistory implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7488577569585048930L; // // /** キー情報を出力する際のフォーマット */ // private static final String TOSTRING_FORMAT = "KeyHistory={0}"; // // /** 蓄積キー情報履歴。同様の値を重複して保持しないためにSetとして定義。*/ // protected Set<String> keyHistory = new LinkedHashSet<>(); // // /** // * パラメータを指定せずにインスタンスを作成する。 // */ // public KeyHistory() // { // // Do nothing. // } // // /** // * キー情報履歴に指定されたキーを追加する。<br> // * ただし、既に同様の値がキー情報履歴に保持されている場合は追加を行わない。 // * // * @param messageKey キー情報 // */ // public void addKey(String messageKey) // { // this.keyHistory.add(messageKey); // } // // /** // * 対象KeyHistoryInfoのディープコピーを生成し、返す。 // * // * @return 対象KeyHistoryInfoのディープコピー // */ // public KeyHistory createDeepCopy() // { // KeyHistory result = (KeyHistory) SerializationUtils.clone(this); // return result; // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String keyHistoryStr = this.keyHistory.toString(); // String result = MessageFormat.format(TOSTRING_FORMAT, keyHistoryStr); // return result; // } // }
import java.io.Serializable; import java.util.Map; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import acromusashi.stream.trace.KeyHistory; import com.google.common.collect.Maps;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.entity; /** * Common message header used in AcroMUSASHI Stream * * @author kimura */ public class StreamMessageHeader implements Serializable { /** serialVersionUID */ private static final long serialVersionUID = -3290857759292105445L; /** Default Version */ public static final String DEFAULT_VERSION = "1.0"; /** Message Key */ private String messageKey = ""; /** Message Identifier */ private String messageId = ""; /** Key History */
// Path: src/main/java/acromusashi/stream/trace/KeyHistory.java // public class KeyHistory implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7488577569585048930L; // // /** キー情報を出力する際のフォーマット */ // private static final String TOSTRING_FORMAT = "KeyHistory={0}"; // // /** 蓄積キー情報履歴。同様の値を重複して保持しないためにSetとして定義。*/ // protected Set<String> keyHistory = new LinkedHashSet<>(); // // /** // * パラメータを指定せずにインスタンスを作成する。 // */ // public KeyHistory() // { // // Do nothing. // } // // /** // * キー情報履歴に指定されたキーを追加する。<br> // * ただし、既に同様の値がキー情報履歴に保持されている場合は追加を行わない。 // * // * @param messageKey キー情報 // */ // public void addKey(String messageKey) // { // this.keyHistory.add(messageKey); // } // // /** // * 対象KeyHistoryInfoのディープコピーを生成し、返す。 // * // * @return 対象KeyHistoryInfoのディープコピー // */ // public KeyHistory createDeepCopy() // { // KeyHistory result = (KeyHistory) SerializationUtils.clone(this); // return result; // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String keyHistoryStr = this.keyHistory.toString(); // String result = MessageFormat.format(TOSTRING_FORMAT, keyHistoryStr); // return result; // } // } // Path: src/main/java/acromusashi/stream/entity/StreamMessageHeader.java import java.io.Serializable; import java.util.Map; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import acromusashi.stream.trace.KeyHistory; import com.google.common.collect.Maps; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.entity; /** * Common message header used in AcroMUSASHI Stream * * @author kimura */ public class StreamMessageHeader implements Serializable { /** serialVersionUID */ private static final long serialVersionUID = -3290857759292105445L; /** Default Version */ public static final String DEFAULT_VERSION = "1.0"; /** Message Key */ private String messageKey = ""; /** Message Identifier */ private String messageId = ""; /** Key History */
private KeyHistory history;
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/topology/state/TopologyExecutionGetter.java
// Path: src/main/java/acromusashi/stream/client/NimbusClientFactory.java // public class NimbusClientFactory // { // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public NimbusClientFactory() // {} // // /** // * Nimbusへの接続クライアントを生成する。 // * // * @param host Nimbusホスト // * @param port NimbusPort // * @return Nimbusへの接続クライアント // */ // public NimbusClient createClient(String host, int port) // { // Map<String, Object> nimbusConf = Maps.newHashMap(); // nimbusConf.put(Config.NIMBUS_HOST, host); // nimbusConf.put(Config.NIMBUS_THRIFT_PORT, port); // nimbusConf.put(Config.STORM_THRIFT_TRANSPORT_PLUGIN, // "backtype.storm.security.auth.SimpleTransportPlugin"); // NimbusClient nimbusClient = NimbusClient.getConfiguredClient(nimbusConf); // return nimbusClient; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConnectFailException.java // public class ConnectFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConnectFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConnectFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConnectFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConnectFailException(Throwable cause) // { // super(cause); // } // }
import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import acromusashi.stream.client.NimbusClientFactory; import acromusashi.stream.exception.ConnectFailException; import backtype.storm.generated.ClusterSummary; import backtype.storm.generated.Nimbus; import backtype.storm.generated.NotAliveException; import backtype.storm.generated.TopologyInfo; import backtype.storm.utils.NimbusClient;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.topology.state; /** * Nimbusに問合せ、該当Topologyの実行状態を取得するクライアントクラス<br> * 該当Topologyのメッセージ処理数を定期的に確認し、指定した判定実行回数分変化がなかった場合に該当Topologyを「停止中」として扱う。<br> * メッセージ処理数に変化があった場合はメッセージ処理中として扱い、「処理中」として扱う。 * * @author kimura */ public class TopologyExecutionGetter { /** * パラメータを指定せずにインスタンスを生成する。 */ public TopologyExecutionGetter() { // Do nothing. } /** * 該当Topologyの実行状態を取得する。 * * @param topologyName トポロジ名 * @param nimbusHost NimbusHost * @param nimbusPort NimbusPort * @param interval 処理中判定実行インターバル(ミリ秒単位) * @param number 処理中判定実行回数 * @throws ConnectFailException 接続失敗時 * @return Topology実行状態 */ public TopologyExecutionStatus getExecution(String topologyName, String nimbusHost,
// Path: src/main/java/acromusashi/stream/client/NimbusClientFactory.java // public class NimbusClientFactory // { // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public NimbusClientFactory() // {} // // /** // * Nimbusへの接続クライアントを生成する。 // * // * @param host Nimbusホスト // * @param port NimbusPort // * @return Nimbusへの接続クライアント // */ // public NimbusClient createClient(String host, int port) // { // Map<String, Object> nimbusConf = Maps.newHashMap(); // nimbusConf.put(Config.NIMBUS_HOST, host); // nimbusConf.put(Config.NIMBUS_THRIFT_PORT, port); // nimbusConf.put(Config.STORM_THRIFT_TRANSPORT_PLUGIN, // "backtype.storm.security.auth.SimpleTransportPlugin"); // NimbusClient nimbusClient = NimbusClient.getConfiguredClient(nimbusConf); // return nimbusClient; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConnectFailException.java // public class ConnectFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConnectFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConnectFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConnectFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConnectFailException(Throwable cause) // { // super(cause); // } // } // Path: src/main/java/acromusashi/stream/topology/state/TopologyExecutionGetter.java import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import acromusashi.stream.client.NimbusClientFactory; import acromusashi.stream.exception.ConnectFailException; import backtype.storm.generated.ClusterSummary; import backtype.storm.generated.Nimbus; import backtype.storm.generated.NotAliveException; import backtype.storm.generated.TopologyInfo; import backtype.storm.utils.NimbusClient; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.topology.state; /** * Nimbusに問合せ、該当Topologyの実行状態を取得するクライアントクラス<br> * 該当Topologyのメッセージ処理数を定期的に確認し、指定した判定実行回数分変化がなかった場合に該当Topologyを「停止中」として扱う。<br> * メッセージ処理数に変化があった場合はメッセージ処理中として扱い、「処理中」として扱う。 * * @author kimura */ public class TopologyExecutionGetter { /** * パラメータを指定せずにインスタンスを生成する。 */ public TopologyExecutionGetter() { // Do nothing. } /** * 該当Topologyの実行状態を取得する。 * * @param topologyName トポロジ名 * @param nimbusHost NimbusHost * @param nimbusPort NimbusPort * @param interval 処理中判定実行インターバル(ミリ秒単位) * @param number 処理中判定実行回数 * @throws ConnectFailException 接続失敗時 * @return Topology実行状態 */ public TopologyExecutionStatus getExecution(String topologyName, String nimbusHost,
int nimbusPort, int interval, int number) throws ConnectFailException
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/topology/state/TopologyExecutionGetter.java
// Path: src/main/java/acromusashi/stream/client/NimbusClientFactory.java // public class NimbusClientFactory // { // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public NimbusClientFactory() // {} // // /** // * Nimbusへの接続クライアントを生成する。 // * // * @param host Nimbusホスト // * @param port NimbusPort // * @return Nimbusへの接続クライアント // */ // public NimbusClient createClient(String host, int port) // { // Map<String, Object> nimbusConf = Maps.newHashMap(); // nimbusConf.put(Config.NIMBUS_HOST, host); // nimbusConf.put(Config.NIMBUS_THRIFT_PORT, port); // nimbusConf.put(Config.STORM_THRIFT_TRANSPORT_PLUGIN, // "backtype.storm.security.auth.SimpleTransportPlugin"); // NimbusClient nimbusClient = NimbusClient.getConfiguredClient(nimbusConf); // return nimbusClient; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConnectFailException.java // public class ConnectFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConnectFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConnectFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConnectFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConnectFailException(Throwable cause) // { // super(cause); // } // }
import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import acromusashi.stream.client.NimbusClientFactory; import acromusashi.stream.exception.ConnectFailException; import backtype.storm.generated.ClusterSummary; import backtype.storm.generated.Nimbus; import backtype.storm.generated.NotAliveException; import backtype.storm.generated.TopologyInfo; import backtype.storm.utils.NimbusClient;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.topology.state; /** * Nimbusに問合せ、該当Topologyの実行状態を取得するクライアントクラス<br> * 該当Topologyのメッセージ処理数を定期的に確認し、指定した判定実行回数分変化がなかった場合に該当Topologyを「停止中」として扱う。<br> * メッセージ処理数に変化があった場合はメッセージ処理中として扱い、「処理中」として扱う。 * * @author kimura */ public class TopologyExecutionGetter { /** * パラメータを指定せずにインスタンスを生成する。 */ public TopologyExecutionGetter() { // Do nothing. } /** * 該当Topologyの実行状態を取得する。 * * @param topologyName トポロジ名 * @param nimbusHost NimbusHost * @param nimbusPort NimbusPort * @param interval 処理中判定実行インターバル(ミリ秒単位) * @param number 処理中判定実行回数 * @throws ConnectFailException 接続失敗時 * @return Topology実行状態 */ public TopologyExecutionStatus getExecution(String topologyName, String nimbusHost, int nimbusPort, int interval, int number) throws ConnectFailException {
// Path: src/main/java/acromusashi/stream/client/NimbusClientFactory.java // public class NimbusClientFactory // { // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public NimbusClientFactory() // {} // // /** // * Nimbusへの接続クライアントを生成する。 // * // * @param host Nimbusホスト // * @param port NimbusPort // * @return Nimbusへの接続クライアント // */ // public NimbusClient createClient(String host, int port) // { // Map<String, Object> nimbusConf = Maps.newHashMap(); // nimbusConf.put(Config.NIMBUS_HOST, host); // nimbusConf.put(Config.NIMBUS_THRIFT_PORT, port); // nimbusConf.put(Config.STORM_THRIFT_TRANSPORT_PLUGIN, // "backtype.storm.security.auth.SimpleTransportPlugin"); // NimbusClient nimbusClient = NimbusClient.getConfiguredClient(nimbusConf); // return nimbusClient; // } // } // // Path: src/main/java/acromusashi/stream/exception/ConnectFailException.java // public class ConnectFailException extends Exception // { // /** serialVersionUID */ // private static final long serialVersionUID = -3457655487597730586L; // // /** // * パラメータを指定せずにインスタンスを生成する。 // */ // public ConnectFailException() // { // super(); // } // // /** // * コンストラクタ // * // * @param message メッセージ // */ // public ConnectFailException(String message) // { // super(message); // } // // /** // * コンストラクタ // * // * @param message メッセージ // * @param cause 発生原因例外 // */ // public ConnectFailException(String message, Throwable cause) // { // super(message, cause); // } // // /** // * コンストラクタ // * // * @param cause 発生原因例外 // */ // public ConnectFailException(Throwable cause) // { // super(cause); // } // } // Path: src/main/java/acromusashi/stream/topology/state/TopologyExecutionGetter.java import java.util.concurrent.TimeUnit; import org.apache.commons.lang.StringUtils; import acromusashi.stream.client.NimbusClientFactory; import acromusashi.stream.exception.ConnectFailException; import backtype.storm.generated.ClusterSummary; import backtype.storm.generated.Nimbus; import backtype.storm.generated.NotAliveException; import backtype.storm.generated.TopologyInfo; import backtype.storm.utils.NimbusClient; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.topology.state; /** * Nimbusに問合せ、該当Topologyの実行状態を取得するクライアントクラス<br> * 該当Topologyのメッセージ処理数を定期的に確認し、指定した判定実行回数分変化がなかった場合に該当Topologyを「停止中」として扱う。<br> * メッセージ処理数に変化があった場合はメッセージ処理中として扱い、「処理中」として扱う。 * * @author kimura */ public class TopologyExecutionGetter { /** * パラメータを指定せずにインスタンスを生成する。 */ public TopologyExecutionGetter() { // Do nothing. } /** * 該当Topologyの実行状態を取得する。 * * @param topologyName トポロジ名 * @param nimbusHost NimbusHost * @param nimbusPort NimbusPort * @param interval 処理中判定実行インターバル(ミリ秒単位) * @param number 処理中判定実行回数 * @throws ConnectFailException 接続失敗時 * @return Topology実行状態 */ public TopologyExecutionStatus getExecution(String topologyName, String nimbusHost, int nimbusPort, int interval, int number) throws ConnectFailException {
NimbusClientFactory factory = new NimbusClientFactory();
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/kestrel/spout/KestrelJsonSpout.java
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/util/JsonValueExtractor.java // public class JsonValueExtractor // { // /** // * インスタンス化を防止するためのコンストラクタ // */ // private JsonValueExtractor() // {} // // /** // * 指定したJSONオブジェクトから「parentKey」要素中の「key」の要素を抽出する。<br> // * 抽出に失敗した場合は例外が発生する。 // * // * @param target JSONオブジェクト // * @param parentKey JSONオブジェクト中の親キー // * @param childKey JSONオブジェクト中の子キー // * @return 取得結果 // */ // public static String extractValue(Object target, String parentKey, String childKey) // { // JSONObject jsonObj = JSONObject.fromObject(target); // JSONObject parentObj = jsonObj.getJSONObject(parentKey); // String value = parentObj.getString(childKey); // return value; // } // }
import backtype.storm.tuple.Fields; import java.text.MessageFormat; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import net.sf.json.JSONException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import acromusashi.stream.constants.FieldName; import acromusashi.stream.util.JsonValueExtractor; import backtype.storm.spout.Scheme; import backtype.storm.spout.SchemeAsMultiScheme; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.task.TopologyContext;
} } /** * {@inheritDoc} */ @SuppressWarnings({"rawtypes"}) @Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { super.open(conf, context, collector); Number timeout = (Number) conf.get(KESTREL_TIMEOUT); this.messageTimeoutMs = (int) TimeUnit.SECONDS.toMillis(timeout.intValue()); this.restrictWatcher = new RestrictWatcher(this.restrictFilePath); // Spoutの番号に併せて取得対象となるQueue番号をQueue名称に設定 int componentIndex = context.getThisTaskIndex(); String baseQueueName = getQueueName(); String queueName = baseQueueName + "_" + componentIndex; setQueueName(queueName); } /** * {@inheritDoc} */ @Override public Fields getOutputFields() {
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/util/JsonValueExtractor.java // public class JsonValueExtractor // { // /** // * インスタンス化を防止するためのコンストラクタ // */ // private JsonValueExtractor() // {} // // /** // * 指定したJSONオブジェクトから「parentKey」要素中の「key」の要素を抽出する。<br> // * 抽出に失敗した場合は例外が発生する。 // * // * @param target JSONオブジェクト // * @param parentKey JSONオブジェクト中の親キー // * @param childKey JSONオブジェクト中の子キー // * @return 取得結果 // */ // public static String extractValue(Object target, String parentKey, String childKey) // { // JSONObject jsonObj = JSONObject.fromObject(target); // JSONObject parentObj = jsonObj.getJSONObject(parentKey); // String value = parentObj.getString(childKey); // return value; // } // } // Path: src/main/java/acromusashi/stream/component/kestrel/spout/KestrelJsonSpout.java import backtype.storm.tuple.Fields; import java.text.MessageFormat; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import net.sf.json.JSONException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import acromusashi.stream.constants.FieldName; import acromusashi.stream.util.JsonValueExtractor; import backtype.storm.spout.Scheme; import backtype.storm.spout.SchemeAsMultiScheme; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.task.TopologyContext; } } /** * {@inheritDoc} */ @SuppressWarnings({"rawtypes"}) @Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { super.open(conf, context, collector); Number timeout = (Number) conf.get(KESTREL_TIMEOUT); this.messageTimeoutMs = (int) TimeUnit.SECONDS.toMillis(timeout.intValue()); this.restrictWatcher = new RestrictWatcher(this.restrictFilePath); // Spoutの番号に併せて取得対象となるQueue番号をQueue名称に設定 int componentIndex = context.getThisTaskIndex(); String baseQueueName = getQueueName(); String queueName = baseQueueName + "_" + componentIndex; setQueueName(queueName); } /** * {@inheritDoc} */ @Override public Fields getOutputFields() {
return new Fields(Arrays.asList(FieldName.MESSAGE_KEY, FieldName.MESSAGE_VALUE));
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/kestrel/spout/KestrelJsonSpout.java
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/util/JsonValueExtractor.java // public class JsonValueExtractor // { // /** // * インスタンス化を防止するためのコンストラクタ // */ // private JsonValueExtractor() // {} // // /** // * 指定したJSONオブジェクトから「parentKey」要素中の「key」の要素を抽出する。<br> // * 抽出に失敗した場合は例外が発生する。 // * // * @param target JSONオブジェクト // * @param parentKey JSONオブジェクト中の親キー // * @param childKey JSONオブジェクト中の子キー // * @return 取得結果 // */ // public static String extractValue(Object target, String parentKey, String childKey) // { // JSONObject jsonObj = JSONObject.fromObject(target); // JSONObject parentObj = jsonObj.getJSONObject(parentKey); // String value = parentObj.getString(childKey); // return value; // } // }
import backtype.storm.tuple.Fields; import java.text.MessageFormat; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import net.sf.json.JSONException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import acromusashi.stream.constants.FieldName; import acromusashi.stream.util.JsonValueExtractor; import backtype.storm.spout.Scheme; import backtype.storm.spout.SchemeAsMultiScheme; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.task.TopologyContext;
/** * {@inheritDoc} */ @Override public Fields getOutputFields() { return new Fields(Arrays.asList(FieldName.MESSAGE_KEY, FieldName.MESSAGE_VALUE)); } /** * {@inheritDoc} */ @Override protected boolean isRestricted() { return this.restrictWatcher.isRestrict(); } /** * {@inheritDoc} */ @Override protected EmitItem generateEmitItem(List<Object> retItems, KestrelSourceId sourceId) { String groupingInfo = null; String jsonMessage = (String) retItems.get(0); try { // グルーピング情報を取得する
// Path: src/main/java/acromusashi/stream/constants/FieldName.java // public interface FieldName // { // /** Message grouping key's field name. */ // String MESSAGE_KEY = "messageKey"; // // /** Message value's field name. */ // String MESSAGE_VALUE = "messageValue"; // } // // Path: src/main/java/acromusashi/stream/util/JsonValueExtractor.java // public class JsonValueExtractor // { // /** // * インスタンス化を防止するためのコンストラクタ // */ // private JsonValueExtractor() // {} // // /** // * 指定したJSONオブジェクトから「parentKey」要素中の「key」の要素を抽出する。<br> // * 抽出に失敗した場合は例外が発生する。 // * // * @param target JSONオブジェクト // * @param parentKey JSONオブジェクト中の親キー // * @param childKey JSONオブジェクト中の子キー // * @return 取得結果 // */ // public static String extractValue(Object target, String parentKey, String childKey) // { // JSONObject jsonObj = JSONObject.fromObject(target); // JSONObject parentObj = jsonObj.getJSONObject(parentKey); // String value = parentObj.getString(childKey); // return value; // } // } // Path: src/main/java/acromusashi/stream/component/kestrel/spout/KestrelJsonSpout.java import backtype.storm.tuple.Fields; import java.text.MessageFormat; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import net.sf.json.JSONException; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import acromusashi.stream.constants.FieldName; import acromusashi.stream.util.JsonValueExtractor; import backtype.storm.spout.Scheme; import backtype.storm.spout.SchemeAsMultiScheme; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.task.TopologyContext; /** * {@inheritDoc} */ @Override public Fields getOutputFields() { return new Fields(Arrays.asList(FieldName.MESSAGE_KEY, FieldName.MESSAGE_VALUE)); } /** * {@inheritDoc} */ @Override protected boolean isRestricted() { return this.restrictWatcher.isRestrict(); } /** * {@inheritDoc} */ @Override protected EmitItem generateEmitItem(List<Object> retItems, KestrelSourceId sourceId) { String groupingInfo = null; String jsonMessage = (String) retItems.get(0); try { // グルーピング情報を取得する
groupingInfo = JsonValueExtractor.extractValue(jsonMessage, HEADER_TAG, MESSAGEKEY_TAG);
acromusashi/acromusashi-stream
src/main/java/acromusashi/stream/component/elasticsearch/bolt/JsonConverter.java
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // }
import java.io.IOException; import java.util.HashMap; import java.util.Map; import acromusashi.stream.entity.StreamMessage; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper;
/** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.elasticsearch.bolt; /** * TupleにElasticSearchに投入するJSONが含まれるケースに使用するコンバータ * * @author kimura */ public class JsonConverter implements EsTupleConverter { /** serialVersionUID */ private static final long serialVersionUID = -6547492926366285428L; /** Index Name */ private String index; /** Type Name */ private String type; /** Documentが格納されているTupleField */ private String field; /** JSONマッピング用のマッパー */ private transient ObjectMapper mapper; /** * Index、Type、fieldを指定してインスタンスを生成する。 * * @param index Index Name * @param type Type Name * @param field TupleField */ public JsonConverter(String index, String type, String field) { this.index = index; this.type = type; this.field = field; } /** * {@inheritDoc} */ @Override
// Path: src/main/java/acromusashi/stream/entity/StreamMessage.java // public class StreamMessage implements Serializable // { // /** serialVersionUID */ // private static final long serialVersionUID = -7553630425199269093L; // // /** Message Header */ // private StreamMessageHeader header; // // /** Message Body */ // private Object body; // // /** // * Constructs instance. // */ // public StreamMessage() // { // this.header = new StreamMessageHeader(); // } // // /** // * Constructs instance with Header and body. // * // * @param header Message Header // * @param body Message Body // */ // public StreamMessage(StreamMessageHeader header, Object body) // { // this.header = header; // this.body = body; // } // // /** // * @return the header // */ // public StreamMessageHeader getHeader() // { // return this.header; // } // // /** // * @param header the header to set // */ // public void setHeader(StreamMessageHeader header) // { // this.header = header; // } // // /** // * @return the body // */ // public Object getBody() // { // return this.body; // } // // /** // * @param body the body to set // */ // public void setBody(Object body) // { // this.body = body; // } // // /** // * Add field to message body. // * // * @param key key // * @param value value // */ // @SuppressWarnings({"unchecked", "rawtypes"}) // public void addField(String key, Object value) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // this.body = Maps.newLinkedHashMap(); // } // // ((Map) this.body).put(key, value); // } // // /** // * Get field from message body. // * // * @param key key // * @return field mapped key // */ // @SuppressWarnings("rawtypes") // public Object getField(String key) // { // if (this.body == null || Map.class.isAssignableFrom(this.body.getClass()) == false) // { // return null; // } // // return ((Map) this.body).get(key); // } // // /** // * {@inheritDoc} // */ // @Override // public String toString() // { // String result = this.header.toString() + "," + this.body.toString(); // return result; // } // } // Path: src/main/java/acromusashi/stream/component/elasticsearch/bolt/JsonConverter.java import java.io.IOException; import java.util.HashMap; import java.util.Map; import acromusashi.stream.entity.StreamMessage; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; /** * Copyright (c) Acroquest Technology Co, Ltd. All Rights Reserved. * Please read the associated COPYRIGHTS file for more details. * * THE SOFTWARE IS PROVIDED BY Acroquest Technolog Co., Ltd., * WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDER BE LIABLE FOR ANY * CLAIM, DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ package acromusashi.stream.component.elasticsearch.bolt; /** * TupleにElasticSearchに投入するJSONが含まれるケースに使用するコンバータ * * @author kimura */ public class JsonConverter implements EsTupleConverter { /** serialVersionUID */ private static final long serialVersionUID = -6547492926366285428L; /** Index Name */ private String index; /** Type Name */ private String type; /** Documentが格納されているTupleField */ private String field; /** JSONマッピング用のマッパー */ private transient ObjectMapper mapper; /** * Index、Type、fieldを指定してインスタンスを生成する。 * * @param index Index Name * @param type Type Name * @param field TupleField */ public JsonConverter(String index, String type, String field) { this.index = index; this.type = type; this.field = field; } /** * {@inheritDoc} */ @Override
public String convertToIndex(StreamMessage message)
almeidaRodrigo/conciliacao
src/gui/ButtonGenerator.java
// Path: src/principal/InitializerGUI.java // public class InitializerGUI { // /** // * // */ // private InitializerGUI() { // // } // // private static WindowAdapter windowState = null; // // /** // * @return the windowState // */ // public static WindowAdapter getWindowState() { // return windowState; // } // // /** // * @param windowState the windowState to set // */ // public static void setWindowState(WindowAdapter wa) { // InitializerGUI.windowState = wa; // } // // public static void show(Image appIcon, IWindow window, Set<Button> lButtons) throws IOException{ // IScreen screen; // JMenuBar menu = new JMenuBar(); // IFrame frame = new Frame(); // JLabel subTitle = new JLabel("Conciliação - Banco do Brasil"); // // window.setIconImage(appIcon); // screen = new AppScreen(); // // for (Button button : lButtons) { // menu.add(button); // } // // screen.setTitle("Sistema de Conciliação Bancária - JUCEB"); // screen.setSubTitle(subTitle); // screen.setWindow(window); // screen.setMenu(menu); // screen.setFrame(frame); // // screen.show(); // } // // }
import java.awt.AWTException; import java.awt.Button; import java.awt.Image; import java.awt.SystemTray; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; import java.util.HashSet; import java.util.Set; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JOptionPane; import principal.InitializerGUI;
/** * */ package gui; /** * @author rodrigo * */ public class ButtonGenerator { /** * */ private ButtonGenerator() { } public static Set<Button> generate(IWindow window){ Set<Button> lButtons = new HashSet<>(); Button menuConfig, menuOcultar; menuConfig = new Button("Configurações"); menuConfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null, e.getActionCommand() , "CONCILIAÇÃO - "+e.getActionCommand(), JOptionPane.INFORMATION_MESSAGE); } }); menuOcultar = new Button("Ocultar"); menuOcultar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(JOptionPane.showConfirmDialog( null, "Você deseja "+ e.getActionCommand() +"?", "CONCILIAÇÃO - "+e.getActionCommand(), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){
// Path: src/principal/InitializerGUI.java // public class InitializerGUI { // /** // * // */ // private InitializerGUI() { // // } // // private static WindowAdapter windowState = null; // // /** // * @return the windowState // */ // public static WindowAdapter getWindowState() { // return windowState; // } // // /** // * @param windowState the windowState to set // */ // public static void setWindowState(WindowAdapter wa) { // InitializerGUI.windowState = wa; // } // // public static void show(Image appIcon, IWindow window, Set<Button> lButtons) throws IOException{ // IScreen screen; // JMenuBar menu = new JMenuBar(); // IFrame frame = new Frame(); // JLabel subTitle = new JLabel("Conciliação - Banco do Brasil"); // // window.setIconImage(appIcon); // screen = new AppScreen(); // // for (Button button : lButtons) { // menu.add(button); // } // // screen.setTitle("Sistema de Conciliação Bancária - JUCEB"); // screen.setSubTitle(subTitle); // screen.setWindow(window); // screen.setMenu(menu); // screen.setFrame(frame); // // screen.show(); // } // // } // Path: src/gui/ButtonGenerator.java import java.awt.AWTException; import java.awt.Button; import java.awt.Image; import java.awt.SystemTray; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; import java.util.HashSet; import java.util.Set; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JOptionPane; import principal.InitializerGUI; /** * */ package gui; /** * @author rodrigo * */ public class ButtonGenerator { /** * */ private ButtonGenerator() { } public static Set<Button> generate(IWindow window){ Set<Button> lButtons = new HashSet<>(); Button menuConfig, menuOcultar; menuConfig = new Button("Configurações"); menuConfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( null, e.getActionCommand() , "CONCILIAÇÃO - "+e.getActionCommand(), JOptionPane.INFORMATION_MESSAGE); } }); menuOcultar = new Button("Ocultar"); menuOcultar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(JOptionPane.showConfirmDialog( null, "Você deseja "+ e.getActionCommand() +"?", "CONCILIAÇÃO - "+e.getActionCommand(), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){
if(InitializerGUI.getWindowState() == null){
almeidaRodrigo/conciliacao
src/arquivo/ManipulateXml.java
// Path: src/xml/GeradorXml.java // public class GeradorXml { // Object obj; // // public GeradorXml(Object obj){ // this.obj = obj; // // } // // public String makeXml(){ // XStream xstream = new XStream(); // return xstream.toXML(this.obj); // } // // }
import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Path; import com.thoughtworks.xstream.XStream; import xml.GeradorXml;
package arquivo; /* * ReaderXml: Classe responsavel por manipulacao de leitura do arquivo fixo " */ public class ManipulateXml extends ConciliacaoFiles { /** * */ private static final long serialVersionUID = 1L; public ManipulateXml(Path path) { super(path); //Efetua a leitura do arquivo config.xml dentro da pasta do arquivo JAR (executavel deste projeto) //Path path = FileSystems.getDefault().getPath(System.getProperty("user.dir") , fileName); } public Object openXml() throws FileNotFoundException { return new XStream().fromXML(this.openFileStream()); } public void saveXml(Object o) throws IOException{
// Path: src/xml/GeradorXml.java // public class GeradorXml { // Object obj; // // public GeradorXml(Object obj){ // this.obj = obj; // // } // // public String makeXml(){ // XStream xstream = new XStream(); // return xstream.toXML(this.obj); // } // // } // Path: src/arquivo/ManipulateXml.java import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Path; import com.thoughtworks.xstream.XStream; import xml.GeradorXml; package arquivo; /* * ReaderXml: Classe responsavel por manipulacao de leitura do arquivo fixo " */ public class ManipulateXml extends ConciliacaoFiles { /** * */ private static final long serialVersionUID = 1L; public ManipulateXml(Path path) { super(path); //Efetua a leitura do arquivo config.xml dentro da pasta do arquivo JAR (executavel deste projeto) //Path path = FileSystems.getDefault().getPath(System.getProperty("user.dir") , fileName); } public Object openXml() throws FileNotFoundException { return new XStream().fromXML(this.openFileStream()); } public void saveXml(Object o) throws IOException{
this.saveFile(new GeradorXml(o).makeXml(), false);
almeidaRodrigo/conciliacao
src/vo/Dam.java
// Path: src/utilitario/DigitoVerificador.java // public final class DigitoVerificador { // // private DigitoVerificador(){ // //Evitar instancia de classe, pois, esta classe somente tem metodos static. // } // // public static String obterDigito(String value){ // int sum = 0; // int resto = 0; // // //String sValue = "3" + String.valueOf(value); //O DAM deve iniciar com '3' + 7 numeros e passar a ser incrementado a partir dai. // String digito = ""; // // for(int i = 0; i < value.length(); i++){ // digito = value.substring(i, i+1); // sum = sum + ( (i+1) * Integer.parseInt(digito)); // } // // resto = sum % 11; // // if(resto > 1){ // return ""+(11-resto); // }else{ // return "0"; // } // // } // }
import java.math.BigDecimal; import java.util.Calendar; import utilitario.DigitoVerificador;
*/ public void setSeqDuplicacao(int seqDuplicacao) { this.seqDuplicacao = seqDuplicacao; } /** * @return the codigoAgencia */ public String getCodigoAgencia() { return codigoAgencia; } /** * @param codigoAgencia the codigoAgencia to set */ public void setCodigoAgencia(String codigoAgencia) { this.codigoAgencia = codigoAgencia; } /** * @return the numDam */ public String getNumDam() { return numDam; } /** * @return the numDam + DV mod11 */ public String getDigitoVerificador() {
// Path: src/utilitario/DigitoVerificador.java // public final class DigitoVerificador { // // private DigitoVerificador(){ // //Evitar instancia de classe, pois, esta classe somente tem metodos static. // } // // public static String obterDigito(String value){ // int sum = 0; // int resto = 0; // // //String sValue = "3" + String.valueOf(value); //O DAM deve iniciar com '3' + 7 numeros e passar a ser incrementado a partir dai. // String digito = ""; // // for(int i = 0; i < value.length(); i++){ // digito = value.substring(i, i+1); // sum = sum + ( (i+1) * Integer.parseInt(digito)); // } // // resto = sum % 11; // // if(resto > 1){ // return ""+(11-resto); // }else{ // return "0"; // } // // } // } // Path: src/vo/Dam.java import java.math.BigDecimal; import java.util.Calendar; import utilitario.DigitoVerificador; */ public void setSeqDuplicacao(int seqDuplicacao) { this.seqDuplicacao = seqDuplicacao; } /** * @return the codigoAgencia */ public String getCodigoAgencia() { return codigoAgencia; } /** * @param codigoAgencia the codigoAgencia to set */ public void setCodigoAgencia(String codigoAgencia) { this.codigoAgencia = codigoAgencia; } /** * @return the numDam */ public String getNumDam() { return numDam; } /** * @return the numDam + DV mod11 */ public String getDigitoVerificador() {
return DigitoVerificador.obterDigito(numDam);
almeidaRodrigo/conciliacao
src/arquivo/Log.java
// Path: src/erro/ErrorLog.java // public class ErrorLog { // // private Calendar timeError; // private Exception error; // private String stringErro; // // public ErrorLog(Calendar timeError, Exception e) { // this.timeError = timeError; // this.error = e; // // StringBuilder message = new StringBuilder(); // message.append("\r\n-\r\n"); // message.append("|Data e hora do erro: " + this.timeError.getTime() + "\r\n"); // message.append("|Mensagem informada pelo erro:\r\n"); // message.append("|" + this.error.getMessage() + "\r\n"); // //message.append("|Pilha do erro:\r\n"); // //message.append("|" + this.error.toString() + "\r\n"); // message.append("-\r\n"); // // this.stringErro = message.toString(); // // } // // @Override // public String toString(){ // return this.stringErro; // // } // // }
import java.nio.file.Path; import java.util.Calendar; import erro.ErrorLog;
package arquivo; public class Log extends ConciliacaoFiles { /** * */ private static final long serialVersionUID = 1L; public Log(Path path) { super(path); } public void makeLog(Exception exception) throws Exception {
// Path: src/erro/ErrorLog.java // public class ErrorLog { // // private Calendar timeError; // private Exception error; // private String stringErro; // // public ErrorLog(Calendar timeError, Exception e) { // this.timeError = timeError; // this.error = e; // // StringBuilder message = new StringBuilder(); // message.append("\r\n-\r\n"); // message.append("|Data e hora do erro: " + this.timeError.getTime() + "\r\n"); // message.append("|Mensagem informada pelo erro:\r\n"); // message.append("|" + this.error.getMessage() + "\r\n"); // //message.append("|Pilha do erro:\r\n"); // //message.append("|" + this.error.toString() + "\r\n"); // message.append("-\r\n"); // // this.stringErro = message.toString(); // // } // // @Override // public String toString(){ // return this.stringErro; // // } // // } // Path: src/arquivo/Log.java import java.nio.file.Path; import java.util.Calendar; import erro.ErrorLog; package arquivo; public class Log extends ConciliacaoFiles { /** * */ private static final long serialVersionUID = 1L; public Log(Path path) { super(path); } public void makeLog(Exception exception) throws Exception {
ErrorLog erroLog = new ErrorLog(Calendar.getInstance(), exception);
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import java.util.Objects; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; import static com.google.common.truth.Truth.assertAbout; import javax.annotation.Nullable; import org.checkerframework.checker.nullness.compatqual.NullableDecl; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.api.Trouble;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.testhelper; public final class TestCaseSubject extends Subject {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java import java.util.Objects; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; import static com.google.common.truth.Truth.assertAbout; import javax.annotation.Nullable; import org.checkerframework.checker.nullness.compatqual.NullableDecl; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.api.Trouble; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.testhelper; public final class TestCaseSubject extends Subject {
private static final Subject.Factory<TestCaseSubject, CndTestCase> TESTCASES_SUBJECT_FACTORY = TestCaseSubject::new;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import java.util.Objects; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; import static com.google.common.truth.Truth.assertAbout; import javax.annotation.Nullable; import org.checkerframework.checker.nullness.compatqual.NullableDecl; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.api.Trouble;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.testhelper; public final class TestCaseSubject extends Subject { private static final Subject.Factory<TestCaseSubject, CndTestCase> TESTCASES_SUBJECT_FACTORY = TestCaseSubject::new; private final CndTestCase actual; private TestCaseSubject(FailureMetadata metadata, @NullableDecl CndTestCase actual) { super(metadata, actual); this.actual = Objects.requireNonNull(actual); } public void hasError() { final Trouble trouble = actual.getTrouble(); check("hasError()").that(trouble).isNotNull(); check("hasError()").that(trouble.isError()).isTrue(); } public void hasNoError() { check("hasNoError()").that(actual.getTrouble()).isNull(); } public void isTime(long timeMs) { check("timeIs").that(actual.getTimeMillis()).isEqualTo(timeMs); }
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java import java.util.Objects; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; import static com.google.common.truth.Truth.assertAbout; import javax.annotation.Nullable; import org.checkerframework.checker.nullness.compatqual.NullableDecl; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.api.Trouble; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.testhelper; public final class TestCaseSubject extends Subject { private static final Subject.Factory<TestCaseSubject, CndTestCase> TESTCASES_SUBJECT_FACTORY = TestCaseSubject::new; private final CndTestCase actual; private TestCaseSubject(FailureMetadata metadata, @NullableDecl CndTestCase actual) { super(metadata, actual); this.actual = Objects.requireNonNull(actual); } public void hasError() { final Trouble trouble = actual.getTrouble(); check("hasError()").that(trouble).isNotNull(); check("hasError()").that(trouble.isError()).isTrue(); } public void hasNoError() { check("hasNoError()").that(actual.getTrouble()).isNull(); } public void isTime(long timeMs) { check("timeIs").that(actual.getTimeMillis()).isEqualTo(timeMs); }
public void isFramework(TestFramework expected)
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerTestMethodNode.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // }
import org.openide.util.lookup.Lookups; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import java.util.ArrayList; import java.util.List; import javax.swing.Action; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.ui.api.DiffViewAction; import org.netbeans.modules.gsf.testrunner.ui.api.Locator; import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodNode; import org.openide.nodes.Node; import org.openide.util.NbBundle;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerTestMethodNode} implements a frame node for * a testmethod. * * @author offa */ public class TestRunnerTestMethodNode extends TestMethodNode { private final String actionName = NbBundle.getMessage(TestRunnerTestMethodNode.class, "LBL_Action_GoToSource");
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerTestMethodNode.java import org.openide.util.lookup.Lookups; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import java.util.ArrayList; import java.util.List; import javax.swing.Action; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.ui.api.DiffViewAction; import org.netbeans.modules.gsf.testrunner.ui.api.Locator; import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodNode; import org.openide.nodes.Node; import org.openide.util.NbBundle; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerTestMethodNode} implements a frame node for * a testmethod. * * @author offa */ public class TestRunnerTestMethodNode extends TestMethodNode { private final String actionName = NbBundle.getMessage(TestRunnerTestMethodNode.class, "LBL_Action_GoToSource");
public TestRunnerTestMethodNode(CndTestCase testcase, Project project)
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; /** * The class {@code CppUTestTestHandlerFactory} implements a factory for * <i>CppUTest</i> test handler. * * @author offa */ public class CppUTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; /** * The class {@code CppUTestTestHandlerFactory} implements a factory for * <i>CppUTest</i> test handler. * * @author offa */ public class CppUTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
Manager.getInstance().setNodeFactory(new TestRunnerUINodeFactory());
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; /** * The class {@code CppUTestTestHandlerFactory} implements a factory for * <i>CppUTest</i> test handler. * * @author offa */ public class CppUTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setNodeFactory(new TestRunnerUINodeFactory());
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; /** * The class {@code CppUTestTestHandlerFactory} implements a factory for * <i>CppUTest</i> test handler. * * @author offa */ public class CppUTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setNodeFactory(new TestRunnerUINodeFactory());
Manager.getInstance().setTestingFramework(TestFramework.CPPUTEST.getName());
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestSuiteFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // }
import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.*; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestSuiteFinishedHandlerTest { private static Project project; private static Report report; private TestSessionInformation info; private CppUTestSuiteFinishedHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestSuiteFinishedHandlerTest.java import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.*; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestSuiteFinishedHandlerTest { private static Project project; private static Report report; private TestSessionInformation info; private CppUTestSuiteFinishedHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // }
import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest {
private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // }
import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST; private GoogleTestTestStartedHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST; private GoogleTestTestStartedHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // }
import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST; private GoogleTestTestStartedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeEach public void setUp() { handler = new GoogleTestTestStartedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestCase() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestTestStartedHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST; private GoogleTestTestStartedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeEach public void setUp() { handler = new GoogleTestTestStartedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestCase() {
Matcher m = checkedMatch(handler, "[ RUN ] TestSuite.testCase");
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // }
import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock;
@BeforeEach public void setUp() { handler = new GoogleTestTestStartedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestCase() { Matcher m = checkedMatch(handler, "[ RUN ] TestSuite.testCase"); assertThat(m.group(1)).isEqualTo("TestSuite"); assertThat(m.group(2)).isEqualTo("testCase"); } @Test public void parseDataTestCaseParameterized() { Matcher m = checkedMatch(handler, "[ RUN ] withParameterImpl/TestSuite.testCase/0"); assertThat(m.group(1)).isEqualTo("withParameterImpl/TestSuite"); assertThat(m.group(2)).isEqualTo("testCase"); } @Test public void updateUIAddsTestCase() { checkedMatch(handler, "[ RUN ] TestSuite.testCase"); handler.updateUI(manager, session);
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<Testcase> isTestOfFramework(String suite, String test, TestFramework framework) // { // return new ArgumentMatcherImpl<Testcase>("isTestframework()", suite + "::" + test + " - " + framework) // { // @Override // public boolean matches(Testcase t) // { // return isTest(suite, test).matches(t) && isFramework(framework).matches(t); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestStartedHandlerTest.java import static org.mockito.Mockito.verify; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isTestOfFramework; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; @BeforeEach public void setUp() { handler = new GoogleTestTestStartedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestCase() { Matcher m = checkedMatch(handler, "[ RUN ] TestSuite.testCase"); assertThat(m.group(1)).isEqualTo("TestSuite"); assertThat(m.group(2)).isEqualTo("testCase"); } @Test public void parseDataTestCaseParameterized() { Matcher m = checkedMatch(handler, "[ RUN ] withParameterImpl/TestSuite.testCase/0"); assertThat(m.group(1)).isEqualTo("withParameterImpl/TestSuite"); assertThat(m.group(2)).isEqualTo("testCase"); } @Test public void updateUIAddsTestCase() { checkedMatch(handler, "[ RUN ] TestSuite.testCase"); handler.updateUI(manager, session);
verify(session).addTestCase(argThat(isTestOfFramework("TestSuite", "testCase", FRAMEWORK)));
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSessionFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSessionFinishedHandlerTest { private static Project project; private static Report report; private GoogleTestSessionFinishedHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSessionFinishedHandlerTest.java import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSessionFinishedHandlerTest { private static Project project; private static Report report; private GoogleTestSessionFinishedHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSessionFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSessionFinishedHandlerTest { private static Project project; private static Report report; private GoogleTestSessionFinishedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeAll public static void setUpClass() { project = mock(Project.class); when(project.getProjectDirectory()) .thenReturn(FileUtil.createMemoryFileSystem().getRoot()); when(project.getLookup()).thenReturn(Lookup.EMPTY); report = new Report("suite", project); } @BeforeEach public void setUp() { handler = new GoogleTestSessionFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestSession() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSessionFinishedHandlerTest.java import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSessionFinishedHandlerTest { private static Project project; private static Report report; private GoogleTestSessionFinishedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeAll public static void setUpClass() { project = mock(Project.class); when(project.getProjectDirectory()) .thenReturn(FileUtil.createMemoryFileSystem().getRoot()); when(project.getLookup()).thenReturn(Lookup.EMPTY); report = new Report("suite", project); } @BeforeEach public void setUp() { handler = new GoogleTestSessionFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataTestSession() {
Matcher m = checkedMatch(handler, "[==========] 1200 tests from 307 test cases ran. (1234 ms total)");
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; /** * The class {@code GoogleTestTestHandlerFactory} implements a factory for * <i>GoogleTest</i> test handler. * * @author offa */ public class GoogleTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; /** * The class {@code GoogleTestTestHandlerFactory} implements a factory for * <i>GoogleTest</i> test handler. * * @author offa */ public class GoogleTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
Manager.getInstance().setTestingFramework(TestFramework.GOOGLETEST.getName());
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; /** * The class {@code GoogleTestTestHandlerFactory} implements a factory for * <i>GoogleTest</i> test handler. * * @author offa */ public class GoogleTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setTestingFramework(TestFramework.GOOGLETEST.getName());
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; /** * The class {@code GoogleTestTestHandlerFactory} implements a factory for * <i>GoogleTest</i> test handler. * * @author offa */ public class GoogleTestTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setTestingFramework(TestFramework.GOOGLETEST.getName());
Manager.getInstance().setNodeFactory(new TestRunnerUINodeFactory());
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTimeHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java // public static TestCaseSubject assertThat(@Nullable CndTestCase actual) // { // return assertAbout(testcases()).that(actual); // }
import static org.mockito.Mockito.*; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import static bv.offa.netbeans.cnd.unittest.testhelper.TestCaseSubject.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestTimeHandlerTest {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java // public static TestCaseSubject assertThat(@Nullable CndTestCase actual) // { // return assertAbout(testcases()).that(actual); // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTimeHandlerTest.java import static org.mockito.Mockito.*; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import static bv.offa.netbeans.cnd.unittest.testhelper.TestCaseSubject.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestTimeHandlerTest {
private static final TestFramework FRAMEWORK = TestFramework.CPPUTEST;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTimeHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java // public static TestCaseSubject assertThat(@Nullable CndTestCase actual) // { // return assertAbout(testcases()).that(actual); // }
import static org.mockito.Mockito.*; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import static bv.offa.netbeans.cnd.unittest.testhelper.TestCaseSubject.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestTimeHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.CPPUTEST; private TestSessionInformation info; private CppUTestTimeHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/TestCaseSubject.java // public static TestCaseSubject assertThat(@Nullable CndTestCase actual) // { // return assertAbout(testcases()).that(actual); // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/cpputest/CppUTestTimeHandlerTest.java import static org.mockito.Mockito.*; import org.netbeans.modules.gsf.testrunner.api.TestSession; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import static bv.offa.netbeans.cnd.unittest.testhelper.TestCaseSubject.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.cpputest; @Tag("Test-Framework") @Tag("CppUTest") public class CppUTestTimeHandlerTest { private static final TestFramework FRAMEWORK = TestFramework.CPPUTEST; private TestSessionInformation info; private CppUTestTimeHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // }
import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.ui.api.TestRunnerNodeFactory; import org.netbeans.modules.gsf.testrunner.ui.api.TestsuiteNode; import org.openide.nodes.Node;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerUINodeFactory} implements a testrunner * node factory. * * @author offa */ public class TestRunnerUINodeFactory extends TestRunnerNodeFactory { /** * Creates a new testmethod node. * * @param testcase Testcase * @param project Project * @return Node */ @Override public Node createTestMethodNode(Testcase testcase, Project project) {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Testcase; import org.netbeans.modules.gsf.testrunner.ui.api.TestRunnerNodeFactory; import org.netbeans.modules.gsf.testrunner.ui.api.TestsuiteNode; import org.openide.nodes.Node; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerUINodeFactory} implements a testrunner * node factory. * * @author offa */ public class TestRunnerUINodeFactory extends TestRunnerNodeFactory { /** * Creates a new testmethod node. * * @param testcase Testcase * @param project Project * @return Node */ @Override public Node createTestMethodNode(Testcase testcase, Project project) {
return new TestRunnerTestMethodNode((CndTestCase) testcase, project);
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerTestSuiteNode.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // }
import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import java.util.ArrayList; import java.util.List; import javax.swing.Action; import org.netbeans.modules.gsf.testrunner.ui.api.Locator; import org.netbeans.modules.gsf.testrunner.ui.api.TestsuiteNode; import org.openide.nodes.Node; import org.openide.util.NbBundle; import org.openide.util.lookup.Lookups;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerTestSuiteNode} implements a frame node for * a testsuite. * * @author offa */ public class TestRunnerTestSuiteNode extends TestsuiteNode { private final String actionName = NbBundle.getMessage(TestRunnerTestSuiteNode.class, "LBL_Action_GoToSource"); public TestRunnerTestSuiteNode(String suiteName, boolean filtered) { super(null, suiteName, filtered, Lookups.singleton((Locator) (Node node) -> { Action jumpTo = node.getPreferredAction(); if( jumpTo != null ) { jumpTo.actionPerformed(null); } })); } /** * Returns the preferred action. * * @return Action */ @Override public Action getPreferredAction() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerTestSuiteNode.java import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import java.util.ArrayList; import java.util.List; import javax.swing.Action; import org.netbeans.modules.gsf.testrunner.ui.api.Locator; import org.netbeans.modules.gsf.testrunner.ui.api.TestsuiteNode; import org.openide.nodes.Node; import org.openide.util.NbBundle; import org.openide.util.lookup.Lookups; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.ui; /** * The class {@code TestRunnerTestSuiteNode} implements a frame node for * a testsuite. * * @author offa */ public class TestRunnerTestSuiteNode extends TestsuiteNode { private final String actionName = NbBundle.getMessage(TestRunnerTestSuiteNode.class, "LBL_Action_GoToSource"); public TestRunnerTestSuiteNode(String suiteName, boolean filtered) { super(null, suiteName, filtered, Lookups.singleton((Locator) (Node node) -> { Action jumpTo = node.getPreferredAction(); if( jumpTo != null ) { jumpTo.actionPerformed(null); } })); } /** * Returns the preferred action. * * @return Action */ @Override public Action getPreferredAction() {
return new GoToSourceSuiteTestNodeAction(actionName, (CndTestSuite) suite, report.getProject());
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestSessionFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; @Tag("Test-Framework") @Tag("LibUnittestCpp") public class LibunittestCppTestSessionFinishedHandlerTest { private static Project project; private static Report report; private LibunittestCppTestSessionFinishedHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestSessionFinishedHandlerTest.java import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; @Tag("Test-Framework") @Tag("LibUnittestCpp") public class LibunittestCppTestSessionFinishedHandlerTest { private static Project project; private static Report report; private LibunittestCppTestSessionFinishedHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestSessionFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when;
private ManagerAdapter manager; @BeforeAll public static void setUpClass() { project = mock(Project.class); when(project.getProjectDirectory()) .thenReturn(FileUtil.createMemoryFileSystem().getRoot()); when(project.getLookup()).thenReturn(Lookup.EMPTY); report = new Report("suite", project); } @BeforeEach public void setUp() { handler = new LibunittestCppTestSessionFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void matchesSuccessfulTest() { assertThat(handler.matches("Ran 60 tests in 0.100471s")).isTrue(); assertThat(handler.matches("Ran 5 tests in 127.000288703s")).isTrue(); } @Test public void parseDataSuccessfulTest() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestSessionFinishedHandlerTest.java import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; private ManagerAdapter manager; @BeforeAll public static void setUpClass() { project = mock(Project.class); when(project.getProjectDirectory()) .thenReturn(FileUtil.createMemoryFileSystem().getRoot()); when(project.getLookup()).thenReturn(Lookup.EMPTY); report = new Report("suite", project); } @BeforeEach public void setUp() { handler = new LibunittestCppTestSessionFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void matchesSuccessfulTest() { assertThat(handler.matches("Ran 60 tests in 0.100471s")).isTrue(); assertThat(handler.matches("Ran 5 tests in 127.000288703s")).isTrue(); } @Test public void parseDataSuccessfulTest() {
Matcher m = checkedMatch(handler, "Ran 5 tests in 127.000288703s");
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; /** * The class {@code LibunittestCppTestHandlerFactory} implements a factory for * <i>libunittestc++</i> test handler. * * @author offa */ public class LibunittestCppTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; /** * The class {@code LibunittestCppTestHandlerFactory} implements a factory for * <i>libunittestc++</i> test handler. * * @author offa */ public class LibunittestCppTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() {
Manager.getInstance().setTestingFramework(TestFramework.LIBUNITTESTCPP.getName());
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestHandlerFactory.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // }
import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; /** * The class {@code LibunittestCppTestHandlerFactory} implements a factory for * <i>libunittestc++</i> test handler. * * @author offa */ public class LibunittestCppTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setTestingFramework(TestFramework.LIBUNITTESTCPP.getName());
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/ui/TestRunnerUINodeFactory.java // public class TestRunnerUINodeFactory extends TestRunnerNodeFactory // { // /** // * Creates a new testmethod node. // * // * @param testcase Testcase // * @param project Project // * @return Node // */ // @Override // public Node createTestMethodNode(Testcase testcase, Project project) // { // return new TestRunnerTestMethodNode((CndTestCase) testcase, project); // } // // // /** // * Creates a new callstack node. // * // * @param frameInfo Callstack frameinfo // * @param displayName Display name // * @return Node // */ // @Override // public Node createCallstackFrameNode(String frameInfo, String displayName) // { // return new TestRunnerCallstackFrameNode(frameInfo, displayName); // } // // // /** // * Creates a new testsuite node. // * // * @param suiteName Testsuite name // * @param filtered Filtered // * @return Node // */ // @Override // public TestsuiteNode createTestSuiteNode(String suiteName, boolean filtered) // { // return new TestRunnerTestSuiteNode(suiteName, filtered); // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/libunittestcpp/LibunittestCppTestHandlerFactory.java import bv.offa.netbeans.cnd.unittest.api.TestFramework; import bv.offa.netbeans.cnd.unittest.ui.TestRunnerUINodeFactory; import java.util.ArrayList; import java.util.List; import org.netbeans.modules.cnd.testrunner.spi.TestHandlerFactory; import org.netbeans.modules.cnd.testrunner.spi.TestRecognizerHandler; import org.netbeans.modules.gsf.testrunner.ui.api.Manager; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.libunittestcpp; /** * The class {@code LibunittestCppTestHandlerFactory} implements a factory for * <i>libunittestc++</i> test handler. * * @author offa */ public class LibunittestCppTestHandlerFactory implements TestHandlerFactory { /** * Creates handlers for the unit test output. * * @return Test output handler */ @Override public List<TestRecognizerHandler> createHandlers() { Manager.getInstance().setTestingFramework(TestFramework.LIBUNITTESTCPP.getName());
Manager.getInstance().setNodeFactory(new TestRunnerUINodeFactory());
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project;
assertThat(parseMs("3")).isEqualTo(3000L); assertThat(parseMs("0.100471")).isEqualTo(100L); assertThat(parseMs("477.100486")).isEqualTo(477100L); assertThat(parseMs("0.1005")).isEqualTo(101L); assertThat(parseMs("12.00")).isEqualTo(12000L); assertThat(parseMs("0.01")).isEqualTo(10L); assertThat(parseMs("0.0")).isEqualTo(0L); assertThat(parseMs("2.646e-05")).isEqualTo(0L); assertThat(parseMs("427.4272e-05")).isEqualTo(4L); assertThat(parseMs("7.4272e-02")).isEqualTo(74L); assertThat(parseMs("3.2e02")).isEqualTo(320000L); assertThat(parseMs("0.000144571")).isEqualTo(0L); assertThat(parseMs("0.00144571")).isEqualTo(1L); assertThat(parseMs("0.234108")).isEqualTo(234L); } @Test public void parseTimeToMillisWithInvalidInput() { assertThat(parseMs("-7.4272e-02")).isEqualTo(0L); assertThat(parseMs("-0.100471")).isEqualTo(0L); assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; assertThat(parseMs("3")).isEqualTo(3000L); assertThat(parseMs("0.100471")).isEqualTo(100L); assertThat(parseMs("477.100486")).isEqualTo(477100L); assertThat(parseMs("0.1005")).isEqualTo(101L); assertThat(parseMs("12.00")).isEqualTo(12000L); assertThat(parseMs("0.01")).isEqualTo(10L); assertThat(parseMs("0.0")).isEqualTo(0L); assertThat(parseMs("2.646e-05")).isEqualTo(0L); assertThat(parseMs("427.4272e-05")).isEqualTo(4L); assertThat(parseMs("7.4272e-02")).isEqualTo(74L); assertThat(parseMs("3.2e02")).isEqualTo(320000L); assertThat(parseMs("0.000144571")).isEqualTo(0L); assertThat(parseMs("0.00144571")).isEqualTo(1L); assertThat(parseMs("0.234108")).isEqualTo(234L); } @Test public void parseTimeToMillisWithInvalidInput() { assertThat(parseMs("-7.4272e-02")).isEqualTo(0L); assertThat(parseMs("-0.100471")).isEqualTo(0L); assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() {
CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock);
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project;
assertThat(parseMs("3")).isEqualTo(3000L); assertThat(parseMs("0.100471")).isEqualTo(100L); assertThat(parseMs("477.100486")).isEqualTo(477100L); assertThat(parseMs("0.1005")).isEqualTo(101L); assertThat(parseMs("12.00")).isEqualTo(12000L); assertThat(parseMs("0.01")).isEqualTo(10L); assertThat(parseMs("0.0")).isEqualTo(0L); assertThat(parseMs("2.646e-05")).isEqualTo(0L); assertThat(parseMs("427.4272e-05")).isEqualTo(4L); assertThat(parseMs("7.4272e-02")).isEqualTo(74L); assertThat(parseMs("3.2e02")).isEqualTo(320000L); assertThat(parseMs("0.000144571")).isEqualTo(0L); assertThat(parseMs("0.00144571")).isEqualTo(1L); assertThat(parseMs("0.234108")).isEqualTo(234L); } @Test public void parseTimeToMillisWithInvalidInput() { assertThat(parseMs("-7.4272e-02")).isEqualTo(0L); assertThat(parseMs("-0.100471")).isEqualTo(0L); assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; assertThat(parseMs("3")).isEqualTo(3000L); assertThat(parseMs("0.100471")).isEqualTo(100L); assertThat(parseMs("477.100486")).isEqualTo(477100L); assertThat(parseMs("0.1005")).isEqualTo(101L); assertThat(parseMs("12.00")).isEqualTo(12000L); assertThat(parseMs("0.01")).isEqualTo(10L); assertThat(parseMs("0.0")).isEqualTo(0L); assertThat(parseMs("2.646e-05")).isEqualTo(0L); assertThat(parseMs("427.4272e-05")).isEqualTo(4L); assertThat(parseMs("7.4272e-02")).isEqualTo(74L); assertThat(parseMs("3.2e02")).isEqualTo(320000L); assertThat(parseMs("0.000144571")).isEqualTo(0L); assertThat(parseMs("0.00144571")).isEqualTo(1L); assertThat(parseMs("0.234108")).isEqualTo(234L); } @Test public void parseTimeToMillisWithInvalidInput() { assertThat(parseMs("-7.4272e-02")).isEqualTo(0L); assertThat(parseMs("-0.100471")).isEqualTo(0L); assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() {
CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock);
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project;
assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() { CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock); testCase.setClassName(SUITE_NAME); final String expected = "C:TEST_" + SUITE_NAME + "_" + CASE_NAME + "_Test"; assertThat(TestSupportUtils.getUniqueDeclarationName(testCase)).isEqualTo(expected); } @Test public void getUniqueDeclarationNameTestCaseCppUTestIgnored() { CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock); testCase.setClassName(SUITE_NAME); testCase.setStatus(Status.SKIPPED); final String expected = "C:IGNORE" + SUITE_NAME + "_" + CASE_NAME + "_Test"; assertThat(TestSupportUtils.getUniqueDeclarationName(testCase)).isEqualTo(expected); } @Test public void getUniqueDeclarationNameTestSuiteCppUTest() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/TestSupportUtilsTest.java import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import java.util.logging.Level; import java.util.logging.Logger; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static com.google.common.truth.Truth.assertThat; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; assertThat(parseMs("-477.100486")).isEqualTo(0L); assertThat(parseMs("7.4272b-02")).isEqualTo(0L); assertThat(parseMs("7.4272e")).isEqualTo(0L); assertThat(parseMs("")).isEqualTo(0L); } @Test public void getUniqueDeclarationNameTestCaseCppUTest() { CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock); testCase.setClassName(SUITE_NAME); final String expected = "C:TEST_" + SUITE_NAME + "_" + CASE_NAME + "_Test"; assertThat(TestSupportUtils.getUniqueDeclarationName(testCase)).isEqualTo(expected); } @Test public void getUniqueDeclarationNameTestCaseCppUTestIgnored() { CndTestCase testCase = new CndTestCase(CASE_NAME, TestFramework.CPPUTEST, testSessionMock); testCase.setClassName(SUITE_NAME); testCase.setStatus(Status.SKIPPED); final String expected = "C:IGNORE" + SUITE_NAME + "_" + CASE_NAME + "_Test"; assertThat(TestSupportUtils.getUniqueDeclarationName(testCase)).isEqualTo(expected); } @Test public void getUniqueDeclarationNameTestSuiteCppUTest() {
CndTestSuite testSuite = new CndTestSuite(SUITE_NAME, TestFramework.CPPUTEST);
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase;
{ return new ArgumentMatcherImpl<Testcase>("hasError()") { @Override public boolean matches(Testcase t) { return Objects.requireNonNull(t.getTrouble()).isError(); } }; } public static ArgumentMatcher<Testcase> hasNoError() { return new ArgumentMatcherImpl<Testcase>("hasNoError()") { @Override public boolean matches(Testcase t) { return t.getTrouble() == null; } }; } public static ArgumentMatcher<Testcase> isTest(String suite, String name) { return new ArgumentMatcherImpl<Testcase>("isTest()", suite + "::" + name) { @Override public boolean matches(Testcase t) {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase; { return new ArgumentMatcherImpl<Testcase>("hasError()") { @Override public boolean matches(Testcase t) { return Objects.requireNonNull(t.getTrouble()).isError(); } }; } public static ArgumentMatcher<Testcase> hasNoError() { return new ArgumentMatcherImpl<Testcase>("hasNoError()") { @Override public boolean matches(Testcase t) { return t.getTrouble() == null; } }; } public static ArgumentMatcher<Testcase> isTest(String suite, String name) { return new ArgumentMatcherImpl<Testcase>("isTest()", suite + "::" + name) { @Override public boolean matches(Testcase t) {
final CndTestCase testCase = (CndTestCase) t;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase;
} }; } public static ArgumentMatcher<Testcase> hasNoError() { return new ArgumentMatcherImpl<Testcase>("hasNoError()") { @Override public boolean matches(Testcase t) { return t.getTrouble() == null; } }; } public static ArgumentMatcher<Testcase> isTest(String suite, String name) { return new ArgumentMatcherImpl<Testcase>("isTest()", suite + "::" + name) { @Override public boolean matches(Testcase t) { final CndTestCase testCase = (CndTestCase) t; return (testCase.getName().equals(name) == true) && (testCase.getClassName().equals(suite) == true); } }; }
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase; } }; } public static ArgumentMatcher<Testcase> hasNoError() { return new ArgumentMatcherImpl<Testcase>("hasNoError()") { @Override public boolean matches(Testcase t) { return t.getTrouble() == null; } }; } public static ArgumentMatcher<Testcase> isTest(String suite, String name) { return new ArgumentMatcherImpl<Testcase>("isTest()", suite + "::" + name) { @Override public boolean matches(Testcase t) { final CndTestCase testCase = (CndTestCase) t; return (testCase.getName().equals(name) == true) && (testCase.getClassName().equals(suite) == true); } }; }
public static ArgumentMatcher<Testcase> isFramework(TestFramework framework)
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // }
import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase;
{ @Override public boolean matches(Testcase t) { final CndTestCase testCase = (CndTestCase) t; return (testCase.getName().equals(name) == true) && (testCase.getClassName().equals(suite) == true); } }; } public static ArgumentMatcher<Testcase> isFramework(TestFramework framework) { return new ArgumentMatcherImpl<Testcase>("isFramework()", framework) { @Override public boolean matches(Testcase t) { return ((CndTestCase) t).getFramework() == framework; } }; } public static ArgumentMatcher<TestSuite> isSuiteFramework(TestFramework framework) { return new ArgumentMatcherImpl<TestSuite>("isSuiteFramework()", framework) { @Override public boolean matches(TestSuite t) {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import java.util.Objects; import org.mockito.ArgumentMatcher; import org.netbeans.modules.gsf.testrunner.api.Status; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.netbeans.modules.gsf.testrunner.api.Testcase; { @Override public boolean matches(Testcase t) { final CndTestCase testCase = (CndTestCase) t; return (testCase.getName().equals(name) == true) && (testCase.getClassName().equals(suite) == true); } }; } public static ArgumentMatcher<Testcase> isFramework(TestFramework framework) { return new ArgumentMatcherImpl<Testcase>("isFramework()", framework) { @Override public boolean matches(Testcase t) { return ((CndTestCase) t).getFramework() == framework; } }; } public static ArgumentMatcher<TestSuite> isSuiteFramework(TestFramework framework) { return new ArgumentMatcherImpl<TestSuite>("isSuiteFramework()", framework) { @Override public boolean matches(TestSuite t) {
return ((CndTestSuite) t).getFramework() == framework;
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // }
import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject;
/** * Parses a string to int, returns {@code 0} if an error occours. * * @param str Input string to parse * @return Int value */ public static int parseInt(String str) { try { return Integer.parseInt(str); } catch( NumberFormatException ex) { LOGGER.log(Level.WARNING, "Parsing value failed", ex); } return 0; } /** * Executes a Go-To-Source to the given TestSuite. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testSuite TestSuite */
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject; /** * Parses a string to int, returns {@code 0} if an error occours. * * @param str Input string to parse * @return Int value */ public static int parseInt(String str) { try { return Integer.parseInt(str); } catch( NumberFormatException ex) { LOGGER.log(Level.WARNING, "Parsing value failed", ex); } return 0; } /** * Executes a Go-To-Source to the given TestSuite. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testSuite TestSuite */
public static void goToSourceOfTestSuite(Project project, CndTestSuite testSuite)
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // }
import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject;
} return 0; } /** * Executes a Go-To-Source to the given TestSuite. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testSuite TestSuite */ public static void goToSourceOfTestSuite(Project project, CndTestSuite testSuite) { final String uniqueDecl = TestSupportUtils.getUniqueDeclarationName(testSuite); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given TestCase. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testCase TestCase */
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject; } return 0; } /** * Executes a Go-To-Source to the given TestSuite. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testSuite TestSuite */ public static void goToSourceOfTestSuite(Project project, CndTestSuite testSuite) { final String uniqueDecl = TestSupportUtils.getUniqueDeclarationName(testSuite); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given TestCase. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testCase TestCase */
public static void goToSourceOfTestCase(Project project, CndTestCase testCase)
offa/NBCndUnit
src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // }
import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject;
final String uniqueDecl = TestSupportUtils.getUniqueDeclarationName(testSuite); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given TestCase. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testCase TestCase */ public static void goToSourceOfTestCase(Project project, CndTestCase testCase) { final String uniqueDecl = getUniqueDeclarationName(testCase); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given failure. If the jump * target isn't available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param failure Failure */
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestCase.java // public class CndTestCase extends Testcase // { // private final TestFramework framework; // private FailureInfo failureInfo; // // // public CndTestCase(String name, TestFramework framework, TestSession session) // { // super(name, framework.getName(), session); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // // /** // * Sets the Test as failed. // */ // public void setError() // { // Trouble trouble = getTrouble(); // // if( trouble == null ) // { // trouble = new Trouble(true); // } // // trouble.setError(true); // setTrouble(trouble); // } // // // /** // * Sets the test as {@link #setError() failed}. The source of failure is // * described by the parameters. // * // * @param file File of failure // * @param line Line of failure // */ // public void setError(String file, int line) // { // Trouble trouble = new Trouble(true); // trouble.setStackTrace(new String[] { file + ":" + line }); // setTrouble(trouble); // this.failureInfo = new FailureInfo(file, line); // } // // // /** // * Sets the Test as skipped (ignored by the test runner). // */ // public void setSkipped() // { // setStatus(Status.SKIPPED); // } // // // /** // * Returns the failure info if the test has failed or {@code null} otherwise. // * // * @return Failure or {@code null} if not failed // */ // public FailureInfo getFailureInfo() // { // return failureInfo; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/FailureInfo.java // public class FailureInfo // { // private final String file; // private final int line; // // public FailureInfo(String file, int line) // { // this.file = file; // this.line = line; // } // // // /** // * Returns the file of failure. // * // * @return File // */ // public String getFile() // { // return file; // } // // // /** // * Returns the line of failure. // * // * @return Line // */ // public int getLine() // { // return line; // } // // } // Path: src/main/java/bv/offa/netbeans/cnd/unittest/TestSupportUtils.java import org.netbeans.modules.cnd.modelutil.CsmUtilities; import org.netbeans.modules.gsf.testrunner.api.Status; import org.openide.util.RequestProcessor; import bv.offa.netbeans.cnd.unittest.api.CndTestCase; import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.FailureInfo; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; import org.netbeans.modules.cnd.api.model.CsmDeclaration; import org.netbeans.modules.cnd.api.model.CsmFile; import org.netbeans.modules.cnd.api.model.CsmModelAccessor; import org.netbeans.modules.cnd.api.model.CsmProject; final String uniqueDecl = TestSupportUtils.getUniqueDeclarationName(testSuite); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given TestCase. If the jump target isn't * available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param testCase TestCase */ public static void goToSourceOfTestCase(Project project, CndTestCase testCase) { final String uniqueDecl = getUniqueDeclarationName(testCase); goToDeclaration(project, uniqueDecl); } /** * Executes a Go-To-Source to the given failure. If the jump * target isn't available, this method does nothing. * * <p>The execution is done in a task; the method doesn't block.</p> * * @param project Project * @param failure Failure */
public static void goToSourceOfFailure(final Project project, final FailureInfo failure)
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // }
import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteStartedHandlerTest {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteStartedHandlerTest {
private static final TestFramework FRAMEWORK = TestFramework.GOOGLETEST;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // }
import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup;
@Test public void parseDataTestSuiteParameterized() { Matcher m = checkedMatch(handler, "[----------] 5 tests from withParameterImpl/TestSuite"); assertThat(m.group(1)).isEqualTo("withParameterImpl/TestSuite"); } @Test public void parseDataSingleTestSuite() { Matcher m = checkedMatch(handler, "[----------] 1 test from TestSuite"); assertThat(m.group(1)).isEqualTo("TestSuite"); } @Test public void updateUIStartsTestIfFirstTest() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); verify(manager).testStarted(session); } @Test public void updateUIStartsTestBeforeSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); InOrder inOrder = inOrder(manager); inOrder.verify(manager).testStarted(any(TestSession.class));
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; @Test public void parseDataTestSuiteParameterized() { Matcher m = checkedMatch(handler, "[----------] 5 tests from withParameterImpl/TestSuite"); assertThat(m.group(1)).isEqualTo("withParameterImpl/TestSuite"); } @Test public void parseDataSingleTestSuite() { Matcher m = checkedMatch(handler, "[----------] 1 test from TestSuite"); assertThat(m.group(1)).isEqualTo("TestSuite"); } @Test public void updateUIStartsTestIfFirstTest() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); verify(manager).testStarted(session); } @Test public void updateUIStartsTestBeforeSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); InOrder inOrder = inOrder(manager); inOrder.verify(manager).testStarted(any(TestSession.class));
inOrder.verify(manager).displaySuiteRunning(any(TestSession.class), any(CndTestSuite.class));
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // }
import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup;
checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); verify(manager).testStarted(session); } @Test public void updateUIStartsTestBeforeSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); InOrder inOrder = inOrder(manager); inOrder.verify(manager).testStarted(any(TestSession.class)); inOrder.verify(manager).displaySuiteRunning(any(TestSession.class), any(CndTestSuite.class)); } @Test public void updateUIDisplaysReportIfNotFirstTest() { checkedMatch(handler, "[----------] 1 test from TestSuite"); when(session.getReport(anyLong())).thenReturn(report); handler.updateUI(manager, session); handler.updateUI(manager, session); verify(manager).displayReport(session, report); } @Test public void updateUIStartsNewSuiteIfFirstSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session);
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/CndTestSuite.java // public class CndTestSuite extends TestSuite // { // private final TestFramework framework; // // public CndTestSuite(String name, TestFramework framework) // { // super(name); // this.framework = framework; // } // // // /** // * Returns the framework. // * // * @return Framework // */ // public TestFramework getFramework() // { // return framework; // } // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/TestFramework.java // public enum TestFramework // { // /** CppUTest. */ // CPPUTEST("CppUTest"), // /** GoogleTest / GoogleMock. */ // GOOGLETEST("GoogleTest"), // /** LibunittestC++. */ // LIBUNITTESTCPP("LibunittestCpp"); // // // private final String name; // // // TestFramework(String name) // { // this.name = name; // } // // // /** // * Returns the name of the framework. // * // * @return Name // */ // public String getName() // { // return name; // } // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static CndTestSuite createCurrentTestSuite(String suiteName, TestFramework framework, // TestSession session) // { // final CndTestSuite testSuite = new CndTestSuite(suiteName, framework); // when(session.getCurrentSuite()).thenReturn(testSuite); // // return testSuite; // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/MockArgumentMatcher.java // public static ArgumentMatcher<TestSuite> isSuite(String suite) // { // return new ArgumentMatcherImpl<TestSuite>("isSuite()", suite) // { // @Override // public boolean matches(TestSuite t) // { // return t.getName().equals(suite); // } // }; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteStartedHandlerTest.java import bv.offa.netbeans.cnd.unittest.api.CndTestSuite; import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import bv.offa.netbeans.cnd.unittest.api.TestFramework; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.createCurrentTestSuite; import static bv.offa.netbeans.cnd.unittest.testhelper.MockArgumentMatcher.isSuite; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import org.mockito.InOrder; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.netbeans.api.project.Project; import org.netbeans.modules.gsf.testrunner.api.Report; import org.netbeans.modules.gsf.testrunner.api.TestSession; import org.netbeans.modules.gsf.testrunner.api.TestSuite; import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); verify(manager).testStarted(session); } @Test public void updateUIStartsTestBeforeSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session); InOrder inOrder = inOrder(manager); inOrder.verify(manager).testStarted(any(TestSession.class)); inOrder.verify(manager).displaySuiteRunning(any(TestSession.class), any(CndTestSuite.class)); } @Test public void updateUIDisplaysReportIfNotFirstTest() { checkedMatch(handler, "[----------] 1 test from TestSuite"); when(session.getReport(anyLong())).thenReturn(report); handler.updateUI(manager, session); handler.updateUI(manager, session); verify(manager).displayReport(session, report); } @Test public void updateUIStartsNewSuiteIfFirstSuite() { checkedMatch(handler, "[----------] 1 test from TestSuite"); handler.updateUI(manager, session);
verify(session).addSuite(argThat(isSuite("TestSuite")));
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import org.netbeans.modules.gsf.testrunner.api.TestSession;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteFinishedHandlerTest { private GoogleTestSuiteFinishedHandler handler; private TestSession session;
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteFinishedHandlerTest.java import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import org.netbeans.modules.gsf.testrunner.api.TestSession; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteFinishedHandlerTest { private GoogleTestSuiteFinishedHandler handler; private TestSession session;
private ManagerAdapter manager;
offa/NBCndUnit
src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteFinishedHandlerTest.java
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // }
import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import org.netbeans.modules.gsf.testrunner.api.TestSession;
/* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteFinishedHandlerTest { private GoogleTestSuiteFinishedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeEach public void setUp() { handler = new GoogleTestSuiteFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataSuccessfulTestSuite() {
// Path: src/main/java/bv/offa/netbeans/cnd/unittest/api/ManagerAdapter.java // public interface ManagerAdapter // { // // /** // * Displays the result report for the test session. // * // * @param session Test session // * @param report Report // */ // public void displayReport(TestSession session, Report report); // // // /** // * Finishes the test session. // * // * @param session Test session // */ // public void sessionFinished(TestSession session); // // // /** // * Starts the test session. // * // * @param session Test session // */ // public void testStarted(TestSession session); // // // /** // * Displays the test suite as running within the session. // * // * @param session Test session // * @param suite Test suite // */ // public void displaySuiteRunning(TestSession session, TestSuite suite); // // } // // Path: src/test/java/bv/offa/netbeans/cnd/unittest/testhelper/Helper.java // public static Matcher checkedMatch(CndTestHandler handler, String input) // { // final Matcher m = handler.match(input); // assertThat(m.find()).isTrue(); // return m; // } // Path: src/test/java/bv/offa/netbeans/cnd/unittest/googletest/GoogleTestSuiteFinishedHandlerTest.java import bv.offa.netbeans.cnd.unittest.api.ManagerAdapter; import static bv.offa.netbeans.cnd.unittest.testhelper.Helper.checkedMatch; import static com.google.common.truth.Truth.assertThat; import java.util.regex.Matcher; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import org.netbeans.modules.gsf.testrunner.api.TestSession; /* * NBCndUnit - C/C++ unit tests for NetBeans. * Copyright (C) 2015-2021 offa * * This file is part of NBCndUnit. * * NBCndUnit 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 3 of the License, or * (at your option) any later version. * * NBCndUnit 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 NBCndUnit. If not, see <http://www.gnu.org/licenses/>. */ package bv.offa.netbeans.cnd.unittest.googletest; @Tag("Test-Framework") @Tag("GoogleTest") public class GoogleTestSuiteFinishedHandlerTest { private GoogleTestSuiteFinishedHandler handler; private TestSession session; private ManagerAdapter manager; @BeforeEach public void setUp() { handler = new GoogleTestSuiteFinishedHandler(); session = mock(TestSession.class); manager = mock(ManagerAdapter.class); } @Test public void parseDataSuccessfulTestSuite() {
Matcher m = checkedMatch(handler, "[----------] 3 tests from TestSuite (259 ms total)");
mess110/detection
clients/java/detect_wrapper/src/detect/api/util/DOMParser.java
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // }
import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region;
package detect.api.util; public class DOMParser { private Document doc; public DOMParser(String xml) throws Exception { this.doc = getNormalizedDocument(xml); } public boolean hasNodeNamed(String name) { boolean result = false; try { result = doc.getElementsByTagName(name).getLength() != 0; } catch (Exception e) { System.out.println("Could not parse xml!"); //e.printStackTrace(); } return result; }
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // } // Path: clients/java/detect_wrapper/src/detect/api/util/DOMParser.java import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region; package detect.api.util; public class DOMParser { private Document doc; public DOMParser(String xml) throws Exception { this.doc = getNormalizedDocument(xml); } public boolean hasNodeNamed(String name) { boolean result = false; try { result = doc.getElementsByTagName(name).getLength() != 0; } catch (Exception e) { System.out.println("Could not parse xml!"); //e.printStackTrace(); } return result; }
public ApiError getApiError() {
mess110/detection
clients/java/detect_wrapper/src/detect/api/util/DOMParser.java
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // }
import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region;
package detect.api.util; public class DOMParser { private Document doc; public DOMParser(String xml) throws Exception { this.doc = getNormalizedDocument(xml); } public boolean hasNodeNamed(String name) { boolean result = false; try { result = doc.getElementsByTagName(name).getLength() != 0; } catch (Exception e) { System.out.println("Could not parse xml!"); //e.printStackTrace(); } return result; } public ApiError getApiError() { ApiError ae = new ApiError(); String[] tagList = {"code", "description"}; ArrayList<String> error = getValues("error", tagList); ae.setErrorCode(error.get(0)); ae.setErrorDescription(error.get(1)); return ae; }
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // } // Path: clients/java/detect_wrapper/src/detect/api/util/DOMParser.java import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region; package detect.api.util; public class DOMParser { private Document doc; public DOMParser(String xml) throws Exception { this.doc = getNormalizedDocument(xml); } public boolean hasNodeNamed(String name) { boolean result = false; try { result = doc.getElementsByTagName(name).getLength() != 0; } catch (Exception e) { System.out.println("Could not parse xml!"); //e.printStackTrace(); } return result; } public ApiError getApiError() { ApiError ae = new ApiError(); String[] tagList = {"code", "description"}; ArrayList<String> error = getValues("error", tagList); ae.setErrorCode(error.get(0)); ae.setErrorDescription(error.get(1)); return ae; }
public Image getImage() {
mess110/detection
clients/java/detect_wrapper/src/detect/api/util/DOMParser.java
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // }
import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region;
ae.setErrorCode(error.get(0)); ae.setErrorDescription(error.get(1)); return ae; } public Image getImage() { Image img = new Image(); String[] tagList = {"id", "status", "url"}; ArrayList<String> values = getValues("image", tagList); img.setId(Integer.parseInt(values.get(0))); img.setStatus(values.get(1)); img.setUrl(values.get(2)); NodeList nList = doc.getElementsByTagName("regions"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; NodeList nlList= eElement.getElementsByTagName("region"); for (int i = 0; i < nlList.getLength(); i++) { Node oneRegion = nlList.item(i); NamedNodeMap attr = oneRegion.getAttributes(); img.addRegion(parseRegion(attr)); } } } return img; }
// Path: clients/java/detect_wrapper/src/detect/api/models/ApiError.java // public class ApiError { // // private String errorCode; // private String errorDescription; // // public ApiError() { // // } // // public String getErrorCode() { // return errorCode; // } // // public void setErrorCode(String errorCode) { // this.errorCode = errorCode; // } // // public String getErrorDescription() { // return errorDescription; // } // // public void setErrorDescription(String errorDescription) { // this.errorDescription = errorDescription; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Image.java // public class Image { // // private int id; // private String status; // private String url; // private int estimatedTimeOfArrival; // private ArrayList<Region> regions; // // public static final String STATUS_COMPLETED = "completed"; // public static final String STATUS_FAILED = "failed"; // public static final String STATUS_PROCESSING = "processing"; // // public Image() { // regions = new ArrayList<Region>(); // } // // public void addRegion(Region r) { // regions.add(r); // } // // public boolean isCompleted() { // return getStatus().equals(STATUS_COMPLETED); // } // // public ArrayList<Region> getRegions() { // return regions; // } // public void setRegions(ArrayList<Region> regions) { // this.regions = regions; // } // public int getId() { // return id; // } // public void setId(int id) { // this.id = id; // } // public String getStatus() { // return status; // } // public void setStatus(String status) { // this.status = status; // } // public String getUrl() { // return url; // } // public void setUrl(String url) { // this.url = url; // } // public int getEstimatedTimeOfArrival() { // return estimatedTimeOfArrival; // } // public void setEstimatedTimeOfArrival(int estimatedTimeOfArrival) { // this.estimatedTimeOfArrival = estimatedTimeOfArrival; // } // } // // Path: clients/java/detect_wrapper/src/detect/api/models/Region.java // public class Region { // // private int tlx, tly, brx, bry; // // public Region() { // // } // // public int getTlx() { // return tlx; // } // // public void setTlx(int tlx) { // this.tlx = tlx; // } // // public int getTly() { // return tly; // } // // public void setTly(int tly) { // this.tly = tly; // } // // public int getBrx() { // return brx; // } // // public void setBrx(int brx) { // this.brx = brx; // } // // public int getBry() { // return bry; // } // // public void setBry(int bry) { // this.bry = bry; // } // } // Path: clients/java/detect_wrapper/src/detect/api/util/DOMParser.java import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import detect.api.models.ApiError; import detect.api.models.Image; import detect.api.models.Region; ae.setErrorCode(error.get(0)); ae.setErrorDescription(error.get(1)); return ae; } public Image getImage() { Image img = new Image(); String[] tagList = {"id", "status", "url"}; ArrayList<String> values = getValues("image", tagList); img.setId(Integer.parseInt(values.get(0))); img.setStatus(values.get(1)); img.setUrl(values.get(2)); NodeList nList = doc.getElementsByTagName("regions"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; NodeList nlList= eElement.getElementsByTagName("region"); for (int i = 0; i < nlList.getLength(); i++) { Node oneRegion = nlList.item(i); NamedNodeMap attr = oneRegion.getAttributes(); img.addRegion(parseRegion(attr)); } } } return img; }
private Region parseRegion(NamedNodeMap attr) {
yjfnypeu/Router-RePlugin
RePluginDemo/remote/src/main/java/com/lzh/remote/RemoteApplication.java
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // }
import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration;
package com.lzh.remote; @RouteConfig(baseUrl = "remote://") public class RemoteApplication extends Application { @Override public void onCreate() { super.onCreate();
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // } // Path: RePluginDemo/remote/src/main/java/com/lzh/remote/RemoteApplication.java import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration; package com.lzh.remote; @RouteConfig(baseUrl = "remote://") public class RemoteApplication extends Application { @Override public void onCreate() { super.onCreate();
PluginRouterConfiguration.init("com.lzh.replugindemo", "remote", this);
yjfnypeu/Router-RePlugin
plugin/src/main/java/com/lzh/router/replugin/plugin/PluginActionLauncher.java
// Path: core/src/main/java/com/lzh/router/replugin/core/RouterResumeReceiver.java // public class RouterResumeReceiver extends BroadcastReceiver { // // @Override // public void onReceive(Context context, Intent intent) { // Uri uri; // RouteBundleExtras extras; // Context resume; // if (intent.hasExtra(Keys.KEY_URI_INDEX)) { // resume = CacheStore.get().get(intent.getIntExtra(Keys.KEY_RESUME_CONTEXT_INDEX, -1)); // extras = CacheStore.get().get(intent.getIntExtra(Keys.KEY_EXTRAS_INDEX, -1)); // uri = CacheStore.get().get(intent.getIntExtra(Keys.KEY_URI_INDEX, -1)); // } else { // resume = context; // extras = intent.getParcelableExtra(Keys.KEY_EXTRAS); // uri = intent.getParcelableExtra(Keys.KEY_URI); // } // // IPluginCallback callback = RePluginRouteCallback.get().getCallback(); // if (resume != null && uri != null) { // Router.resume(uri, extras).open(resume); // if (callback != null) { // callback.onResume(uri); // } // } // } // // public static void registerSelf(Context context, String alias, boolean isHost) { // String action = obtainAction(alias, isHost); // // IntentFilter filter = new IntentFilter(action); // context.registerReceiver(new RouterResumeReceiver(), filter); // } // // public static void start(Context context, String alias, boolean isHost, Uri uri, RouteBundleExtras extras) { // String action = obtainAction(alias, isHost); // // Intent intent = new Intent(action); // intent.putExtra(Keys.KEY_URI, uri); // intent.putExtra(Keys.KEY_EXTRAS, copy(extras)); // context.sendBroadcast(intent); // } // // public static String obtainAction(String alias, boolean isHost) { // String action; // if (isHost) { // action = "com.RePlugin.Router.Host"; // } else { // action = "com.RePlugin.Router.Plugin." + alias; // } // return action; // } // // public static RouteBundleExtras copy(RouteBundleExtras extras) { // // 新版本的Router跨组件传输时,采用了临时缓存策略(使用CacheStore将一些不可序列化的数据进行临时存储) // // 所以这里为了防止跨插件传递数据时导致内存泄漏。将这部分的数据移除 // // 简而言之,就是为此次路由配置的拦截器、回调等数据,将会失效 // RouteBundleExtras copy = new RouteBundleExtras(); // copy.addExtras(extras.getExtras()); // copy.addFlags(extras.getFlags()); // copy.setRequestCode(extras.getRequestCode()); // copy.setOutAnimation(extras.getOutAnimation()); // copy.setInAnimation(extras.getInAnimation()); // return copy; // } // }
import android.content.Context; import android.text.TextUtils; import com.lzh.nonview.router.launcher.DefaultActionLauncher; import com.lzh.router.replugin.core.RouterResumeReceiver;
package com.lzh.router.replugin.plugin; /** * 针对RePlugin框架定制的动作路由启动器。 */ public class PluginActionLauncher extends DefaultActionLauncher { @Override public void open(Context context) { String alias = alias(); boolean isHost = isHost(); if (isHost || !TextUtils.isEmpty(alias)) {
// Path: core/src/main/java/com/lzh/router/replugin/core/RouterResumeReceiver.java // public class RouterResumeReceiver extends BroadcastReceiver { // // @Override // public void onReceive(Context context, Intent intent) { // Uri uri; // RouteBundleExtras extras; // Context resume; // if (intent.hasExtra(Keys.KEY_URI_INDEX)) { // resume = CacheStore.get().get(intent.getIntExtra(Keys.KEY_RESUME_CONTEXT_INDEX, -1)); // extras = CacheStore.get().get(intent.getIntExtra(Keys.KEY_EXTRAS_INDEX, -1)); // uri = CacheStore.get().get(intent.getIntExtra(Keys.KEY_URI_INDEX, -1)); // } else { // resume = context; // extras = intent.getParcelableExtra(Keys.KEY_EXTRAS); // uri = intent.getParcelableExtra(Keys.KEY_URI); // } // // IPluginCallback callback = RePluginRouteCallback.get().getCallback(); // if (resume != null && uri != null) { // Router.resume(uri, extras).open(resume); // if (callback != null) { // callback.onResume(uri); // } // } // } // // public static void registerSelf(Context context, String alias, boolean isHost) { // String action = obtainAction(alias, isHost); // // IntentFilter filter = new IntentFilter(action); // context.registerReceiver(new RouterResumeReceiver(), filter); // } // // public static void start(Context context, String alias, boolean isHost, Uri uri, RouteBundleExtras extras) { // String action = obtainAction(alias, isHost); // // Intent intent = new Intent(action); // intent.putExtra(Keys.KEY_URI, uri); // intent.putExtra(Keys.KEY_EXTRAS, copy(extras)); // context.sendBroadcast(intent); // } // // public static String obtainAction(String alias, boolean isHost) { // String action; // if (isHost) { // action = "com.RePlugin.Router.Host"; // } else { // action = "com.RePlugin.Router.Plugin." + alias; // } // return action; // } // // public static RouteBundleExtras copy(RouteBundleExtras extras) { // // 新版本的Router跨组件传输时,采用了临时缓存策略(使用CacheStore将一些不可序列化的数据进行临时存储) // // 所以这里为了防止跨插件传递数据时导致内存泄漏。将这部分的数据移除 // // 简而言之,就是为此次路由配置的拦截器、回调等数据,将会失效 // RouteBundleExtras copy = new RouteBundleExtras(); // copy.addExtras(extras.getExtras()); // copy.addFlags(extras.getFlags()); // copy.setRequestCode(extras.getRequestCode()); // copy.setOutAnimation(extras.getOutAnimation()); // copy.setInAnimation(extras.getInAnimation()); // return copy; // } // } // Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginActionLauncher.java import android.content.Context; import android.text.TextUtils; import com.lzh.nonview.router.launcher.DefaultActionLauncher; import com.lzh.router.replugin.core.RouterResumeReceiver; package com.lzh.router.replugin.plugin; /** * 针对RePlugin框架定制的动作路由启动器。 */ public class PluginActionLauncher extends DefaultActionLauncher { @Override public void open(Context context) { String alias = alias(); boolean isHost = isHost(); if (isHost || !TextUtils.isEmpty(alias)) {
RouterResumeReceiver.start(context, alias, isHost, uri, extras);
yjfnypeu/Router-RePlugin
RePluginDemo/usercenter/src/main/java/com/lzh/usercenetr/UCApplication.java
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // }
import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration;
package com.lzh.usercenetr; @RouteConfig(baseUrl = "usercenter://") public class UCApplication extends Application { @Override public void onCreate() { super.onCreate(); RouterConfiguration.get().addRouteCreator(new RouterRuleCreator());
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // } // Path: RePluginDemo/usercenter/src/main/java/com/lzh/usercenetr/UCApplication.java import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration; package com.lzh.usercenetr; @RouteConfig(baseUrl = "usercenter://") public class UCApplication extends Application { @Override public void onCreate() { super.onCreate(); RouterConfiguration.get().addRouteCreator(new RouterRuleCreator());
PluginRouterConfiguration.init("com.lzh.replugindemo", "usercenter", this);
yjfnypeu/Router-RePlugin
RePluginDemo/plugina/src/main/java/com/lzh/plugina/PluginApplication.java
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // }
import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration;
package com.lzh.plugina; @RouteConfig(baseUrl = "plugina://") public class PluginApplication extends Application{ private static final String TAG = "ROUTER"; @Override public void onCreate() { super.onCreate();
// Path: plugin/src/main/java/com/lzh/router/replugin/plugin/PluginRouterConfiguration.java // @SuppressWarnings("unused") // public final class PluginRouterConfiguration { // // /** // * 初始化加载。此方法每个插件只需要被加载一次。请尽早进行初始化。 // * @param hostPackage 宿主包名:用于指定启动、连接远程路由服务。为各插件提供路由索引功能 // * @param alias 插件别名:路由启动器将会使用此别名作为唯一标识。 // * @param context 用于启动远程任务的。 // */ // public static void init(String hostPackage, String alias, Context context) { // // 启动并连接远程路由服务。 // RouterConfiguration.get().startHostService(hostPackage, context, alias); // // 提供远程数据创建工厂 // RouterConfiguration.get().setRemoteFactory(new PluginRemoteFactory(alias)); // // 初始化callback. // RouterConfiguration.get().setCallback(RePluginRouteCallback.get()); // // 设置路由启动器 // RouterConfiguration.get().setActionLauncher(PluginActionLauncher.class); // RouterConfiguration.get().setActivityLauncher(PluginActivityLauncher.class); // // 设置自身的插件别名 // RePluginRouteCallback.get().setAlias(alias); // // RouterResumeReceiver.registerSelf(context, alias, false); // } // // public PluginRouterConfiguration setCallback(IPluginCallback callback) { // RePluginRouteCallback.get().setCallback(callback); // return this; // } // // public PluginRouterConfiguration setRouteCallback(RouteCallback callback) { // RePluginRouteCallback.get().setRouteCallback(callback); // return this; // } // // /** // * 设置路由uri转换器。 // * // * @see IUriConverter // * @param converter non-null. // * @return configuration // */ // public PluginRouterConfiguration setConverter(IUriConverter converter) { // if (converter != null) { // RePluginRouteCallback.get().setConverter(converter); // } // return this; // } // // private static PluginRouterConfiguration configuration = new PluginRouterConfiguration(); // private PluginRouterConfiguration() {} // public static PluginRouterConfiguration get() { // return configuration; // } // } // Path: RePluginDemo/plugina/src/main/java/com/lzh/plugina/PluginApplication.java import android.app.Application; import com.lzh.nonview.router.RouterConfiguration; import com.lzh.nonview.router.anno.RouteConfig; import com.lzh.router.RouterRuleCreator; import com.lzh.router.replugin.plugin.PluginRouterConfiguration; package com.lzh.plugina; @RouteConfig(baseUrl = "plugina://") public class PluginApplication extends Application{ private static final String TAG = "ROUTER"; @Override public void onCreate() { super.onCreate();
PluginRouterConfiguration.init("com.lzh.replugindemo", "plugina", this);
yjfnypeu/Router-RePlugin
host/src/main/java/com/lzh/router/replugin/host/HostActionLauncher.java
// Path: core/src/main/java/com/lzh/router/replugin/core/RouterResumeReceiver.java // public class RouterResumeReceiver extends BroadcastReceiver { // // @Override // public void onReceive(Context context, Intent intent) { // Uri uri; // RouteBundleExtras extras; // Context resume; // if (intent.hasExtra(Keys.KEY_URI_INDEX)) { // resume = CacheStore.get().get(intent.getIntExtra(Keys.KEY_RESUME_CONTEXT_INDEX, -1)); // extras = CacheStore.get().get(intent.getIntExtra(Keys.KEY_EXTRAS_INDEX, -1)); // uri = CacheStore.get().get(intent.getIntExtra(Keys.KEY_URI_INDEX, -1)); // } else { // resume = context; // extras = intent.getParcelableExtra(Keys.KEY_EXTRAS); // uri = intent.getParcelableExtra(Keys.KEY_URI); // } // // IPluginCallback callback = RePluginRouteCallback.get().getCallback(); // if (resume != null && uri != null) { // Router.resume(uri, extras).open(resume); // if (callback != null) { // callback.onResume(uri); // } // } // } // // public static void registerSelf(Context context, String alias, boolean isHost) { // String action = obtainAction(alias, isHost); // // IntentFilter filter = new IntentFilter(action); // context.registerReceiver(new RouterResumeReceiver(), filter); // } // // public static void start(Context context, String alias, boolean isHost, Uri uri, RouteBundleExtras extras) { // String action = obtainAction(alias, isHost); // // Intent intent = new Intent(action); // intent.putExtra(Keys.KEY_URI, uri); // intent.putExtra(Keys.KEY_EXTRAS, copy(extras)); // context.sendBroadcast(intent); // } // // public static String obtainAction(String alias, boolean isHost) { // String action; // if (isHost) { // action = "com.RePlugin.Router.Host"; // } else { // action = "com.RePlugin.Router.Plugin." + alias; // } // return action; // } // // public static RouteBundleExtras copy(RouteBundleExtras extras) { // // 新版本的Router跨组件传输时,采用了临时缓存策略(使用CacheStore将一些不可序列化的数据进行临时存储) // // 所以这里为了防止跨插件传递数据时导致内存泄漏。将这部分的数据移除 // // 简而言之,就是为此次路由配置的拦截器、回调等数据,将会失效 // RouteBundleExtras copy = new RouteBundleExtras(); // copy.addExtras(extras.getExtras()); // copy.addFlags(extras.getFlags()); // copy.setRequestCode(extras.getRequestCode()); // copy.setOutAnimation(extras.getOutAnimation()); // copy.setInAnimation(extras.getInAnimation()); // return copy; // } // }
import android.content.Context; import android.text.TextUtils; import com.lzh.nonview.router.launcher.DefaultActionLauncher; import com.lzh.router.replugin.core.RouterResumeReceiver;
package com.lzh.router.replugin.host; /** * 针对RePlugin框架定制的宿主使用的动作路由启动器。 */ public class HostActionLauncher extends DefaultActionLauncher { @Override public void open(Context context) { String alias = remote.getString("alias"); if (TextUtils.isEmpty(alias)) { // 代表在宿主中 super.open(context); } else { // 桥接到指定插件并进行处理
// Path: core/src/main/java/com/lzh/router/replugin/core/RouterResumeReceiver.java // public class RouterResumeReceiver extends BroadcastReceiver { // // @Override // public void onReceive(Context context, Intent intent) { // Uri uri; // RouteBundleExtras extras; // Context resume; // if (intent.hasExtra(Keys.KEY_URI_INDEX)) { // resume = CacheStore.get().get(intent.getIntExtra(Keys.KEY_RESUME_CONTEXT_INDEX, -1)); // extras = CacheStore.get().get(intent.getIntExtra(Keys.KEY_EXTRAS_INDEX, -1)); // uri = CacheStore.get().get(intent.getIntExtra(Keys.KEY_URI_INDEX, -1)); // } else { // resume = context; // extras = intent.getParcelableExtra(Keys.KEY_EXTRAS); // uri = intent.getParcelableExtra(Keys.KEY_URI); // } // // IPluginCallback callback = RePluginRouteCallback.get().getCallback(); // if (resume != null && uri != null) { // Router.resume(uri, extras).open(resume); // if (callback != null) { // callback.onResume(uri); // } // } // } // // public static void registerSelf(Context context, String alias, boolean isHost) { // String action = obtainAction(alias, isHost); // // IntentFilter filter = new IntentFilter(action); // context.registerReceiver(new RouterResumeReceiver(), filter); // } // // public static void start(Context context, String alias, boolean isHost, Uri uri, RouteBundleExtras extras) { // String action = obtainAction(alias, isHost); // // Intent intent = new Intent(action); // intent.putExtra(Keys.KEY_URI, uri); // intent.putExtra(Keys.KEY_EXTRAS, copy(extras)); // context.sendBroadcast(intent); // } // // public static String obtainAction(String alias, boolean isHost) { // String action; // if (isHost) { // action = "com.RePlugin.Router.Host"; // } else { // action = "com.RePlugin.Router.Plugin." + alias; // } // return action; // } // // public static RouteBundleExtras copy(RouteBundleExtras extras) { // // 新版本的Router跨组件传输时,采用了临时缓存策略(使用CacheStore将一些不可序列化的数据进行临时存储) // // 所以这里为了防止跨插件传递数据时导致内存泄漏。将这部分的数据移除 // // 简而言之,就是为此次路由配置的拦截器、回调等数据,将会失效 // RouteBundleExtras copy = new RouteBundleExtras(); // copy.addExtras(extras.getExtras()); // copy.addFlags(extras.getFlags()); // copy.setRequestCode(extras.getRequestCode()); // copy.setOutAnimation(extras.getOutAnimation()); // copy.setInAnimation(extras.getInAnimation()); // return copy; // } // } // Path: host/src/main/java/com/lzh/router/replugin/host/HostActionLauncher.java import android.content.Context; import android.text.TextUtils; import com.lzh.nonview.router.launcher.DefaultActionLauncher; import com.lzh.router.replugin.core.RouterResumeReceiver; package com.lzh.router.replugin.host; /** * 针对RePlugin框架定制的宿主使用的动作路由启动器。 */ public class HostActionLauncher extends DefaultActionLauncher { @Override public void open(Context context) { String alias = remote.getString("alias"); if (TextUtils.isEmpty(alias)) { // 代表在宿主中 super.open(context); } else { // 桥接到指定插件并进行处理
RouterResumeReceiver.start(context, alias, false, uri, extras);
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/TransactedConnection.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/CannotForkTransactedConnection.java // public final class CannotForkTransactedConnection extends SQLRuntimeException { // // private static final long serialVersionUID = -5632849589133364479L; // // public CannotForkTransactedConnection(String message) { // super(message); // } // // }
import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.NClob; import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; import java.util.Map; import java.util.Properties; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; import org.davidmoten.rx.jdbc.exceptions.CannotForkTransactedConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package org.davidmoten.rx.jdbc; final class TransactedConnection implements Connection { private static final Logger log = LoggerFactory.getLogger(TransactedConnection.class); private final Connection con; private final AtomicInteger counter; TransactedConnection(Connection con, AtomicInteger counter) { log.debug("constructing TransactedConnection from {}, {}", con, counter); this.con = con; this.counter = counter; } public TransactedConnection(Connection con) { this(con, new AtomicInteger(1)); } public int counter() { return counter.get(); } @Override public void abort(Executor executor) throws SQLException { con.abort(executor); } @Override public void clearWarnings() throws SQLException { con.clearWarnings(); } public TransactedConnection fork() { log.debug("forking connection"); if (counter.getAndIncrement() > 0) { return new TransactedConnection(con, counter); } else {
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/CannotForkTransactedConnection.java // public final class CannotForkTransactedConnection extends SQLRuntimeException { // // private static final long serialVersionUID = -5632849589133364479L; // // public CannotForkTransactedConnection(String message) { // super(message); // } // // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/TransactedConnection.java import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.NClob; import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; import java.util.Map; import java.util.Properties; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicInteger; import org.davidmoten.rx.jdbc.exceptions.CannotForkTransactedConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; package org.davidmoten.rx.jdbc; final class TransactedConnection implements Connection { private static final Logger log = LoggerFactory.getLogger(TransactedConnection.class); private final Connection con; private final AtomicInteger counter; TransactedConnection(Connection con, AtomicInteger counter) { log.debug("constructing TransactedConnection from {}, {}", con, counter); this.con = con; this.counter = counter; } public TransactedConnection(Connection con) { this(con, new AtomicInteger(1)); } public int counter() { return counter.get(); } @Override public void abort(Executor executor) throws SQLException { con.abort(executor); } @Override public void clearWarnings() throws SQLException { con.clearWarnings(); } public TransactedConnection fork() { log.debug("forking connection"); if (counter.getAndIncrement() > 0) { return new TransactedConnection(con, counter); } else {
throw new CannotForkTransactedConnection(
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/internal/SingletonConnectionProvider.java // public final class SingletonConnectionProvider implements ConnectionProvider { // // private final Connection connection; // // public SingletonConnectionProvider(Connection connection) { // this.connection = connection; // } // // @Override // public Connection get() { // return connection; // } // // @Override // public void close() { // // do nothing as con was not created by this provider // } // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.davidmoten.rx.jdbc.internal.SingletonConnectionProvider; import com.github.davidmoten.guavamini.Preconditions;
package org.davidmoten.rx.jdbc; /** * Provides JDBC Connections as required. It is advisable generally to use a * Connection pool. * **/ public interface ConnectionProvider { /** * Returns a new {@link Connection} (perhaps from a Connection pool). * * @return a new Connection to a database */ @Nonnull Connection get(); /** * Closes the connection provider and releases its resources. For example, a * connection pool may need formal closure to release its connections because * connection.close() is actually just releasing a connection back to the pool * for reuse. This method should be idempotent. */ void close(); /** * Warning: Don't pass one of these as a ConnectionProvider to a pool because * once the pool closes the connection the pool cannot create a new one (the * same closed connection is returned). Instead use a different ConnectionProvider * factory method. * * @param connection connection for singleton provider * @return singleton connection provider (don't use with connection pools!) */ static ConnectionProvider from(@Nonnull Connection connection) { Preconditions.checkNotNull(connection, "connection cannot be null");
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/internal/SingletonConnectionProvider.java // public final class SingletonConnectionProvider implements ConnectionProvider { // // private final Connection connection; // // public SingletonConnectionProvider(Connection connection) { // this.connection = connection; // } // // @Override // public Connection get() { // return connection; // } // // @Override // public void close() { // // do nothing as con was not created by this provider // } // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.davidmoten.rx.jdbc.internal.SingletonConnectionProvider; import com.github.davidmoten.guavamini.Preconditions; package org.davidmoten.rx.jdbc; /** * Provides JDBC Connections as required. It is advisable generally to use a * Connection pool. * **/ public interface ConnectionProvider { /** * Returns a new {@link Connection} (perhaps from a Connection pool). * * @return a new Connection to a database */ @Nonnull Connection get(); /** * Closes the connection provider and releases its resources. For example, a * connection pool may need formal closure to release its connections because * connection.close() is actually just releasing a connection back to the pool * for reuse. This method should be idempotent. */ void close(); /** * Warning: Don't pass one of these as a ConnectionProvider to a pool because * once the pool closes the connection the pool cannot create a new one (the * same closed connection is returned). Instead use a different ConnectionProvider * factory method. * * @param connection connection for singleton provider * @return singleton connection provider (don't use with connection pools!) */ static ConnectionProvider from(@Nonnull Connection connection) { Preconditions.checkNotNull(connection, "connection cannot be null");
return new SingletonConnectionProvider(connection);
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/internal/SingletonConnectionProvider.java // public final class SingletonConnectionProvider implements ConnectionProvider { // // private final Connection connection; // // public SingletonConnectionProvider(Connection connection) { // this.connection = connection; // } // // @Override // public Connection get() { // return connection; // } // // @Override // public void close() { // // do nothing as con was not created by this provider // } // }
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.davidmoten.rx.jdbc.internal.SingletonConnectionProvider; import com.github.davidmoten.guavamini.Preconditions;
package org.davidmoten.rx.jdbc; /** * Provides JDBC Connections as required. It is advisable generally to use a * Connection pool. * **/ public interface ConnectionProvider { /** * Returns a new {@link Connection} (perhaps from a Connection pool). * * @return a new Connection to a database */ @Nonnull Connection get(); /** * Closes the connection provider and releases its resources. For example, a * connection pool may need formal closure to release its connections because * connection.close() is actually just releasing a connection back to the pool * for reuse. This method should be idempotent. */ void close(); /** * Warning: Don't pass one of these as a ConnectionProvider to a pool because * once the pool closes the connection the pool cannot create a new one (the * same closed connection is returned). Instead use a different ConnectionProvider * factory method. * * @param connection connection for singleton provider * @return singleton connection provider (don't use with connection pools!) */ static ConnectionProvider from(@Nonnull Connection connection) { Preconditions.checkNotNull(connection, "connection cannot be null"); return new SingletonConnectionProvider(connection); } static ConnectionProvider from(@Nonnull String url) { Preconditions.checkNotNull(url, "url cannot be null"); return new ConnectionProvider() { @Override public Connection get() { try { return DriverManager.getConnection(url); } catch (SQLException e) {
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/internal/SingletonConnectionProvider.java // public final class SingletonConnectionProvider implements ConnectionProvider { // // private final Connection connection; // // public SingletonConnectionProvider(Connection connection) { // this.connection = connection; // } // // @Override // public Connection get() { // return connection; // } // // @Override // public void close() { // // do nothing as con was not created by this provider // } // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.davidmoten.rx.jdbc.internal.SingletonConnectionProvider; import com.github.davidmoten.guavamini.Preconditions; package org.davidmoten.rx.jdbc; /** * Provides JDBC Connections as required. It is advisable generally to use a * Connection pool. * **/ public interface ConnectionProvider { /** * Returns a new {@link Connection} (perhaps from a Connection pool). * * @return a new Connection to a database */ @Nonnull Connection get(); /** * Closes the connection provider and releases its resources. For example, a * connection pool may need formal closure to release its connections because * connection.close() is actually just releasing a connection back to the pool * for reuse. This method should be idempotent. */ void close(); /** * Warning: Don't pass one of these as a ConnectionProvider to a pool because * once the pool closes the connection the pool cannot create a new one (the * same closed connection is returned). Instead use a different ConnectionProvider * factory method. * * @param connection connection for singleton provider * @return singleton connection provider (don't use with connection pools!) */ static ConnectionProvider from(@Nonnull Connection connection) { Preconditions.checkNotNull(connection, "connection cannot be null"); return new SingletonConnectionProvider(connection); } static ConnectionProvider from(@Nonnull String url) { Preconditions.checkNotNull(url, "url cannot be null"); return new ConnectionProvider() { @Override public Connection get() { try { return DriverManager.getConnection(url); } catch (SQLException e) {
throw new SQLRuntimeException(e);
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuples.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ResultSetMapper.java // public interface ResultSetMapper<T> extends Function<ResultSet, T>{ // // @Override // T apply(@Nonnull ResultSet rs) throws SQLException; // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // }
import static org.davidmoten.rx.jdbc.Util.mapObject; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.davidmoten.rx.jdbc.ResultSetMapper; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import com.github.davidmoten.guavamini.Preconditions;
package org.davidmoten.rx.jdbc.tuple; /** * Utility methods for tuples. */ public final class Tuples { /** * Private constructor to prevent instantiation. */ private Tuples() { // prevent instantiation. }
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ResultSetMapper.java // public interface ResultSetMapper<T> extends Function<ResultSet, T>{ // // @Override // T apply(@Nonnull ResultSet rs) throws SQLException; // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuples.java import static org.davidmoten.rx.jdbc.Util.mapObject; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.davidmoten.rx.jdbc.ResultSetMapper; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import com.github.davidmoten.guavamini.Preconditions; package org.davidmoten.rx.jdbc.tuple; /** * Utility methods for tuples. */ public final class Tuples { /** * Private constructor to prevent instantiation. */ private Tuples() { // prevent instantiation. }
public static <T> ResultSetMapper<T> single(final Class<T> cls) {
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuples.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ResultSetMapper.java // public interface ResultSetMapper<T> extends Function<ResultSet, T>{ // // @Override // T apply(@Nonnull ResultSet rs) throws SQLException; // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // }
import static org.davidmoten.rx.jdbc.Util.mapObject; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.davidmoten.rx.jdbc.ResultSetMapper; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import com.github.davidmoten.guavamini.Preconditions;
return new ResultSetMapper<Tuple7<T1, T2, T3, T4, T5, T6, T7>>() { @Override public Tuple7<T1, T2, T3, T4, T5, T6, T7> apply(ResultSet rs) { return new Tuple7<T1, T2, T3, T4, T5, T6, T7>(mapObject(rs, cls1, 1), mapObject(rs, cls2, 2), mapObject(rs, cls3, 3), mapObject(rs, cls4, 4), mapObject(rs, cls5, 5), mapObject(rs, cls6, 6), mapObject(rs, cls7, 7)); } }; } public static <T> ResultSetMapper<TupleN<T>> tupleN(final Class<T> cls) { Preconditions.checkNotNull(cls, "cls cannot be null"); return new ResultSetMapper<TupleN<T>>() { @Override public TupleN<T> apply(ResultSet rs) { return toTupleN(cls, rs); } }; } private static <T> TupleN<T> toTupleN(final Class<T> cls, ResultSet rs) { try { int n = rs.getMetaData().getColumnCount(); List<T> list = new ArrayList<T>(); for (int i = 1; i <= n; i++) { list.add(mapObject(rs, cls, i)); } return new TupleN<T>(list); } catch (SQLException e) {
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ResultSetMapper.java // public interface ResultSetMapper<T> extends Function<ResultSet, T>{ // // @Override // T apply(@Nonnull ResultSet rs) throws SQLException; // } // // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/tuple/Tuples.java import static org.davidmoten.rx.jdbc.Util.mapObject; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.davidmoten.rx.jdbc.ResultSetMapper; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import com.github.davidmoten.guavamini.Preconditions; return new ResultSetMapper<Tuple7<T1, T2, T3, T4, T5, T6, T7>>() { @Override public Tuple7<T1, T2, T3, T4, T5, T6, T7> apply(ResultSet rs) { return new Tuple7<T1, T2, T3, T4, T5, T6, T7>(mapObject(rs, cls1, 1), mapObject(rs, cls2, 2), mapObject(rs, cls3, 3), mapObject(rs, cls4, 4), mapObject(rs, cls5, 5), mapObject(rs, cls6, 6), mapObject(rs, cls7, 7)); } }; } public static <T> ResultSetMapper<TupleN<T>> tupleN(final Class<T> cls) { Preconditions.checkNotNull(cls, "cls cannot be null"); return new ResultSetMapper<TupleN<T>>() { @Override public TupleN<T> apply(ResultSet rs) { return toTupleN(cls, rs); } }; } private static <T> TupleN<T> toTupleN(final Class<T> cls, ResultSet rs) { try { int n = rs.getMetaData().getColumnCount(); List<T> list = new ArrayList<T>(); for (int i = 1; i <= n; i++) { list.add(mapObject(rs, cls, i)); } return new TupleN<T>(list); } catch (SQLException e) {
throw new SQLRuntimeException(e);
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/pool/DatabaseType.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/pool/internal/HealthCheckPredicate.java // public final class HealthCheckPredicate implements Predicate<Connection> { // // private final String sql; // // public HealthCheckPredicate(String sql) { // this.sql = sql; // } // // @Override // public boolean test(Connection c) throws Exception { // try (Statement s = c.createStatement()) { // s.executeQuery(sql).close(); // return true; // } catch (Throwable t) { // return false; // } // } // }
import java.sql.Connection; import org.davidmoten.rx.jdbc.pool.internal.HealthCheckPredicate; import io.reactivex.functions.Predicate;
package org.davidmoten.rx.jdbc.pool; public enum DatabaseType { ORACLE("select 1 from dual"), // HSQLDB("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"), // H2("select 1"), // SQL_SERVER("select 1"), // MYSQL("select 1"), // POSTGRES("select 1"), // SQLITE("select 1"), // DB2("select 1 from sysibm.sysdummy1"), // DERBY("SELECT 1 FROM SYSIBM.SYSDUMMY1"), // INFORMIX("select count(*) from systables"), // OTHER("select 1"); private final String healthCheckSql; private DatabaseType(String healthCheckSql) { this.healthCheckSql = healthCheckSql; } public Predicate<Connection >healthCheck() {
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/pool/internal/HealthCheckPredicate.java // public final class HealthCheckPredicate implements Predicate<Connection> { // // private final String sql; // // public HealthCheckPredicate(String sql) { // this.sql = sql; // } // // @Override // public boolean test(Connection c) throws Exception { // try (Statement s = c.createStatement()) { // s.executeQuery(sql).close(); // return true; // } catch (Throwable t) { // return false; // } // } // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/pool/DatabaseType.java import java.sql.Connection; import org.davidmoten.rx.jdbc.pool.internal.HealthCheckPredicate; import io.reactivex.functions.Predicate; package org.davidmoten.rx.jdbc.pool; public enum DatabaseType { ORACLE("select 1 from dual"), // HSQLDB("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"), // H2("select 1"), // SQL_SERVER("select 1"), // MYSQL("select 1"), // POSTGRES("select 1"), // SQLITE("select 1"), // DB2("select 1 from sysibm.sysdummy1"), // DERBY("SELECT 1 FROM SYSIBM.SYSDUMMY1"), // INFORMIX("select count(*) from systables"), // OTHER("select 1"); private final String healthCheckSql; private DatabaseType(String healthCheckSql) { this.healthCheckSql = healthCheckSql; } public Predicate<Connection >healthCheck() {
return new HealthCheckPredicate(healthCheckSql);
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/test/java/org/davidmoten/rx/jdbc/pool/NonBlockingConnectionPoolTest.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java // public interface ConnectionProvider { // // /** // * Returns a new {@link Connection} (perhaps from a Connection pool). // * // * @return a new Connection to a database // */ // @Nonnull // Connection get(); // // /** // * Closes the connection provider and releases its resources. For example, a // * connection pool may need formal closure to release its connections because // * connection.close() is actually just releasing a connection back to the pool // * for reuse. This method should be idempotent. // */ // void close(); // // /** // * Warning: Don't pass one of these as a ConnectionProvider to a pool because // * once the pool closes the connection the pool cannot create a new one (the // * same closed connection is returned). Instead use a different ConnectionProvider // * factory method. // * // * @param connection connection for singleton provider // * @return singleton connection provider (don't use with connection pools!) // */ // static ConnectionProvider from(@Nonnull Connection connection) { // Preconditions.checkNotNull(connection, "connection cannot be null"); // return new SingletonConnectionProvider(connection); // } // // static ConnectionProvider from(@Nonnull String url) { // Preconditions.checkNotNull(url, "url cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // static ConnectionProvider from(@Nonnull String url, String username, String password) { // Preconditions.checkNotNull(url, "url cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url, username, password); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // static ConnectionProvider from(@Nonnull String url, Properties properties) { // Preconditions.checkNotNull(url, "url cannot be null"); // Preconditions.checkNotNull(properties, "properties cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url, properties); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // }
import java.sql.Connection; import org.davidmoten.rx.jdbc.ConnectionProvider; import org.junit.Test; import org.mockito.Mockito;
package org.davidmoten.rx.jdbc.pool; public class NonBlockingConnectionPoolTest { @Test(expected = IllegalArgumentException.class) public void testRejectSingletonConnectionProvider() { Connection con = Mockito.mock(Connection.class);
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/ConnectionProvider.java // public interface ConnectionProvider { // // /** // * Returns a new {@link Connection} (perhaps from a Connection pool). // * // * @return a new Connection to a database // */ // @Nonnull // Connection get(); // // /** // * Closes the connection provider and releases its resources. For example, a // * connection pool may need formal closure to release its connections because // * connection.close() is actually just releasing a connection back to the pool // * for reuse. This method should be idempotent. // */ // void close(); // // /** // * Warning: Don't pass one of these as a ConnectionProvider to a pool because // * once the pool closes the connection the pool cannot create a new one (the // * same closed connection is returned). Instead use a different ConnectionProvider // * factory method. // * // * @param connection connection for singleton provider // * @return singleton connection provider (don't use with connection pools!) // */ // static ConnectionProvider from(@Nonnull Connection connection) { // Preconditions.checkNotNull(connection, "connection cannot be null"); // return new SingletonConnectionProvider(connection); // } // // static ConnectionProvider from(@Nonnull String url) { // Preconditions.checkNotNull(url, "url cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // static ConnectionProvider from(@Nonnull String url, String username, String password) { // Preconditions.checkNotNull(url, "url cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url, username, password); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // static ConnectionProvider from(@Nonnull String url, Properties properties) { // Preconditions.checkNotNull(url, "url cannot be null"); // Preconditions.checkNotNull(properties, "properties cannot be null"); // return new ConnectionProvider() { // // @Override // public Connection get() { // try { // return DriverManager.getConnection(url, properties); // } catch (SQLException e) { // throw new SQLRuntimeException(e); // } // } // // @Override // public void close() { // // do nothing as closure will be handle by pool // } // }; // } // // } // Path: rxjava2-jdbc/src/test/java/org/davidmoten/rx/jdbc/pool/NonBlockingConnectionPoolTest.java import java.sql.Connection; import org.davidmoten.rx.jdbc.ConnectionProvider; import org.junit.Test; import org.mockito.Mockito; package org.davidmoten.rx.jdbc.pool; public class NonBlockingConnectionPoolTest { @Test(expected = IllegalArgumentException.class) public void testRejectSingletonConnectionProvider() { Connection con = Mockito.mock(Connection.class);
NonBlockingConnectionPool.builder().connectionProvider(ConnectionProvider.from(con));
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/test/java/org/davidmoten/rx/jdbc/UtilTest.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.lang.reflect.Method; import java.math.BigInteger; import java.sql.Blob; import java.sql.Clob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.time.Instant; import java.util.List; import javax.sql.DataSource; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; import org.mockito.Mockito; import com.github.davidmoten.guavamini.Lists;
@Test public void testAutomapDateToLong() { assertEquals(100L, (long) Util.autoMap(new java.sql.Date(100), Long.class)); } @Test public void testAutomapDateToBigInteger() { assertEquals(100L, ((BigInteger) Util.autoMap(new java.sql.Date(100), BigInteger.class)).longValue()); } @Test public void testAutomapDateToInstant() { assertEquals(100L, ((Instant) Util.autoMap(new java.sql.Date(100), Instant.class)).toEpochMilli()); } @Test public void testAutomapDateToString() { assertEquals(100L, ((java.sql.Date) Util.autoMap(new java.sql.Date(100), String.class)).getTime()); } @Test public void testConnectionProviderFromDataSource() throws SQLException { DataSource d = mock(DataSource.class); Connection c = mock(Connection.class); ConnectionProvider cp = Util.connectionProvider(d); when(d.getConnection()).thenReturn(c); assertTrue(c == cp.get()); cp.close(); }
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/SQLRuntimeException.java // public class SQLRuntimeException extends RuntimeException { // // private static final long serialVersionUID = -3879393806890615797L; // // public SQLRuntimeException(Throwable e) { // super(e); // } // // public SQLRuntimeException(String message) { // super(message); // } // // } // Path: rxjava2-jdbc/src/test/java/org/davidmoten/rx/jdbc/UtilTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.lang.reflect.Method; import java.math.BigInteger; import java.sql.Blob; import java.sql.Clob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.time.Instant; import java.util.List; import javax.sql.DataSource; import org.davidmoten.rx.jdbc.exceptions.SQLRuntimeException; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; import org.mockito.Mockito; import com.github.davidmoten.guavamini.Lists; @Test public void testAutomapDateToLong() { assertEquals(100L, (long) Util.autoMap(new java.sql.Date(100), Long.class)); } @Test public void testAutomapDateToBigInteger() { assertEquals(100L, ((BigInteger) Util.autoMap(new java.sql.Date(100), BigInteger.class)).longValue()); } @Test public void testAutomapDateToInstant() { assertEquals(100L, ((Instant) Util.autoMap(new java.sql.Date(100), Instant.class)).toEpochMilli()); } @Test public void testAutomapDateToString() { assertEquals(100L, ((java.sql.Date) Util.autoMap(new java.sql.Date(100), String.class)).getTime()); } @Test public void testConnectionProviderFromDataSource() throws SQLException { DataSource d = mock(DataSource.class); Connection c = mock(Connection.class); ConnectionProvider cp = Util.connectionProvider(d); when(d.getConnection()).thenReturn(c); assertTrue(c == cp.get()); cp.close(); }
@Test(expected = SQLRuntimeException.class)
davidmoten/rxjava2-jdbc
rxjava2-pool/src/test/java/org/davidmoten/rx/pool/NonBlockingPoolTest.java
// Path: rxjava2-pool/src/main/java/org/davidmoten/rx/internal/FlowableSingleDeferUntilRequest.java // public final class FlowableSingleDeferUntilRequest<T> extends Flowable<T> { // // private final Single<T> single; // // public FlowableSingleDeferUntilRequest(Single<T> single) { // this.single = single; // } // // @Override // protected void subscribeActual(Subscriber<? super T> s) { // SingleSubscription<T> sub = new SingleSubscription<T>(single, s); // s.onSubscribe(sub); // } // // private static final class SingleSubscription<T> extends AtomicBoolean implements Subscription, SingleObserver<T> { // // private static final long serialVersionUID = -4290226935675014466L; // // private final Subscriber<? super T> s; // private final Single<T> single; // private final AtomicReference<Disposable> disposable = new AtomicReference<Disposable>(); // // SingleSubscription(Single<T> single, Subscriber<? super T> s) { // super(); // this.single = single; // this.s = s; // } // // @Override // public void request(long n) { // if (n > 0 && this.compareAndSet(false, true)) { // Disposable d = disposable.get(); // if (d == null) { // single.subscribe(this); // } // } // } // // @Override // public void cancel() { // if (disposable.compareAndSet(null, Disposables.disposed())) { // return; // } else { // disposable.get().dispose(); // // clear for GC // disposable.set(Disposables.disposed()); // } // } // // @Override // public void onSubscribe(Disposable d) { // if (!disposable.compareAndSet(null, d)) { // // already cancelled // d.dispose(); // disposable.set(Disposables.disposed()); // } // } // // @Override // public void onSuccess(T t) { // s.onNext(t); // s.onComplete(); // } // // @Override // public void onError(Throwable e) { // s.onError(e); // } // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.davidmoten.rx.internal.FlowableSingleDeferUntilRequest; import org.junit.Test; import io.reactivex.Flowable; import io.reactivex.Scheduler; import io.reactivex.Single; import io.reactivex.SingleObserver; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.UndeliverableException; import io.reactivex.functions.Consumer; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.TestScheduler; import io.reactivex.subscribers.TestSubscriber;
package org.davidmoten.rx.pool; public class NonBlockingPoolTest { @Test public void testMaxIdleTime() throws InterruptedException { TestScheduler s = new TestScheduler(); AtomicInteger count = new AtomicInteger(); AtomicInteger disposed = new AtomicInteger(); Pool<Integer> pool = NonBlockingPool // .factory(() -> count.incrementAndGet()) // .healthCheck(n -> true) // .maxSize(3) // .maxIdleTime(1, TimeUnit.MINUTES) // .disposer(n -> disposed.incrementAndGet()) // .scheduler(s) // .build();
// Path: rxjava2-pool/src/main/java/org/davidmoten/rx/internal/FlowableSingleDeferUntilRequest.java // public final class FlowableSingleDeferUntilRequest<T> extends Flowable<T> { // // private final Single<T> single; // // public FlowableSingleDeferUntilRequest(Single<T> single) { // this.single = single; // } // // @Override // protected void subscribeActual(Subscriber<? super T> s) { // SingleSubscription<T> sub = new SingleSubscription<T>(single, s); // s.onSubscribe(sub); // } // // private static final class SingleSubscription<T> extends AtomicBoolean implements Subscription, SingleObserver<T> { // // private static final long serialVersionUID = -4290226935675014466L; // // private final Subscriber<? super T> s; // private final Single<T> single; // private final AtomicReference<Disposable> disposable = new AtomicReference<Disposable>(); // // SingleSubscription(Single<T> single, Subscriber<? super T> s) { // super(); // this.single = single; // this.s = s; // } // // @Override // public void request(long n) { // if (n > 0 && this.compareAndSet(false, true)) { // Disposable d = disposable.get(); // if (d == null) { // single.subscribe(this); // } // } // } // // @Override // public void cancel() { // if (disposable.compareAndSet(null, Disposables.disposed())) { // return; // } else { // disposable.get().dispose(); // // clear for GC // disposable.set(Disposables.disposed()); // } // } // // @Override // public void onSubscribe(Disposable d) { // if (!disposable.compareAndSet(null, d)) { // // already cancelled // d.dispose(); // disposable.set(Disposables.disposed()); // } // } // // @Override // public void onSuccess(T t) { // s.onNext(t); // s.onComplete(); // } // // @Override // public void onError(Throwable e) { // s.onError(e); // } // } // // } // Path: rxjava2-pool/src/test/java/org/davidmoten/rx/pool/NonBlockingPoolTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.davidmoten.rx.internal.FlowableSingleDeferUntilRequest; import org.junit.Test; import io.reactivex.Flowable; import io.reactivex.Scheduler; import io.reactivex.Single; import io.reactivex.SingleObserver; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.UndeliverableException; import io.reactivex.functions.Consumer; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.TestScheduler; import io.reactivex.subscribers.TestSubscriber; package org.davidmoten.rx.pool; public class NonBlockingPoolTest { @Test public void testMaxIdleTime() throws InterruptedException { TestScheduler s = new TestScheduler(); AtomicInteger count = new AtomicInteger(); AtomicInteger disposed = new AtomicInteger(); Pool<Integer> pool = NonBlockingPool // .factory(() -> count.incrementAndGet()) // .healthCheck(n -> true) // .maxSize(3) // .maxIdleTime(1, TimeUnit.MINUTES) // .disposer(n -> disposed.incrementAndGet()) // .scheduler(s) // .build();
TestSubscriber<Member<Integer>> ts = new FlowableSingleDeferUntilRequest<>( //
davidmoten/rxjava2-jdbc
rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/SelectAutomappedBuilder.java
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/QueryAnnotationMissingException.java // public final class QueryAnnotationMissingException extends SQLRuntimeException { // // private static final long serialVersionUID = 6725264065633977594L; // // public QueryAnnotationMissingException(String message) { // super(message); // } // }
import java.sql.Connection; import java.util.List; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.annotations.Query; import org.davidmoten.rx.jdbc.exceptions.QueryAnnotationMissingException; import io.reactivex.Flowable; import io.reactivex.Single; import io.reactivex.functions.Function;
package org.davidmoten.rx.jdbc; public final class SelectAutomappedBuilder<T> { final SelectBuilder selectBuilder; final Class<T> cls; private final Database db; SelectAutomappedBuilder(Class<T> cls, Single<Connection> connections, Database db) { this.selectBuilder = new SelectBuilder(getSql(cls), connections, db); this.cls = cls; this.db = db; } private static String getSql(Class<?> cls) { Query q = cls.getDeclaredAnnotation(Query.class); if (q == null) {
// Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/exceptions/QueryAnnotationMissingException.java // public final class QueryAnnotationMissingException extends SQLRuntimeException { // // private static final long serialVersionUID = 6725264065633977594L; // // public QueryAnnotationMissingException(String message) { // super(message); // } // } // Path: rxjava2-jdbc/src/main/java/org/davidmoten/rx/jdbc/SelectAutomappedBuilder.java import java.sql.Connection; import java.util.List; import javax.annotation.Nonnull; import org.davidmoten.rx.jdbc.annotations.Query; import org.davidmoten.rx.jdbc.exceptions.QueryAnnotationMissingException; import io.reactivex.Flowable; import io.reactivex.Single; import io.reactivex.functions.Function; package org.davidmoten.rx.jdbc; public final class SelectAutomappedBuilder<T> { final SelectBuilder selectBuilder; final Class<T> cls; private final Database db; SelectAutomappedBuilder(Class<T> cls, Single<Connection> connections, Database db) { this.selectBuilder = new SelectBuilder(getSql(cls), connections, db); this.cls = cls; this.db = db; } private static String getSql(Class<?> cls) { Query q = cls.getDeclaredAnnotation(Query.class); if (q == null) {
throw new QueryAnnotationMissingException(
tomasbjerre/git-changelog-lib
src/test/java/se/bjurr/gitchangelog/internal/git/GitRepoDataTest.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java // public class GitTag implements IGitCommitReferer { // // private final String annotation; // private final List<GitCommit> gitCommits; // private final String name; // private final Date tagTime; // // public GitTag( // final String name, // final String annotation, // final List<GitCommit> gitCommits, // final Date tagTime) { // checkArgument(!gitCommits.isEmpty(), "No commits in " + name); // this.name = checkNotNull(name, "name"); // this.annotation = annotation; // this.gitCommits = gitCommits; // this.tagTime = tagTime; // } // // public Optional<String> findAnnotation() { // return Optional.ofNullable(this.annotation); // } // // @Override // public GitCommit getGitCommit() { // return checkNotNull(this.gitCommits.get(0), this.name); // } // // public List<GitCommit> getGitCommits() { // return this.gitCommits; // } // // @Override // public String getName() { // return this.name; // } // // public Date getTagTime() { // return this.tagTime; // } // // @Override // public String toString() { // return "Tag: " + this.name + " Annotation: " + this.annotation + ", " + this.getGitCommit(); // } // }
import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; import org.junit.Test; import se.bjurr.gitchangelog.internal.git.model.GitTag;
package se.bjurr.gitchangelog.internal.git; public class GitRepoDataTest { public GitRepoData newGitRepoData(final String originUrl) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java // public class GitTag implements IGitCommitReferer { // // private final String annotation; // private final List<GitCommit> gitCommits; // private final String name; // private final Date tagTime; // // public GitTag( // final String name, // final String annotation, // final List<GitCommit> gitCommits, // final Date tagTime) { // checkArgument(!gitCommits.isEmpty(), "No commits in " + name); // this.name = checkNotNull(name, "name"); // this.annotation = annotation; // this.gitCommits = gitCommits; // this.tagTime = tagTime; // } // // public Optional<String> findAnnotation() { // return Optional.ofNullable(this.annotation); // } // // @Override // public GitCommit getGitCommit() { // return checkNotNull(this.gitCommits.get(0), this.name); // } // // public List<GitCommit> getGitCommits() { // return this.gitCommits; // } // // @Override // public String getName() { // return this.name; // } // // public Date getTagTime() { // return this.tagTime; // } // // @Override // public String toString() { // return "Tag: " + this.name + " Annotation: " + this.annotation + ", " + this.getGitCommit(); // } // } // Path: src/test/java/se/bjurr/gitchangelog/internal/git/GitRepoDataTest.java import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; import org.junit.Test; import se.bjurr.gitchangelog.internal.git.model.GitTag; package se.bjurr.gitchangelog.internal.git; public class GitRepoDataTest { public GitRepoData newGitRepoData(final String originUrl) {
final List<GitTag> gitTags = new ArrayList<>();
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/github/GitHubHelper.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static java.util.Optional.of; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import retrofit2.Call; import retrofit2.Response; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.github; public class GitHubHelper { private static Pattern PAGE_PATTERN = Pattern.compile("page=([0-9]+)>"); private final GitHubService service; public GitHubHelper(final GitHubService service) { this.service = service; } public Optional<GitHubIssue> getIssueFromAll(String issue)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/github/GitHubHelper.java import static java.util.Optional.of; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import retrofit2.Call; import retrofit2.Response; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; package se.bjurr.gitchangelog.internal.integrations.github; public class GitHubHelper { private static Pattern PAGE_PATTERN = Pattern.compile("page=([0-9]+)>"); private final GitHubService service; public GitHubHelper(final GitHubService service) { this.service = service; } public Optional<GitHubIssue> getIssueFromAll(String issue)
throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Changelog.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IIssues.java // public interface IIssues { // List<Issue> getIssues(); // }
import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.api.model.interfaces.IIssues;
package se.bjurr.gitchangelog.api.model; public class Changelog implements ICommits, IAuthors, IIssues, Serializable { private static final long serialVersionUID = 2193789018496738737L; private final List<Commit> commits; private final List<Tag> tags; private final List<Author> authors; private final List<Issue> issues; private final List<IssueType> issueTypes; private final String ownerName; private final String repoName; public Changelog( final List<Commit> commits, final List<Tag> tags, final List<Author> authors, final List<Issue> issues, final List<IssueType> issueTypes, final String ownerName, final String repoName) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IIssues.java // public interface IIssues { // List<Issue> getIssues(); // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Changelog.java import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.api.model.interfaces.IIssues; package se.bjurr.gitchangelog.api.model; public class Changelog implements ICommits, IAuthors, IIssues, Serializable { private static final long serialVersionUID = 2193789018496738737L; private final List<Commit> commits; private final List<Tag> tags; private final List<Author> authors; private final List<Issue> issues; private final List<IssueType> issueTypes; private final String ownerName; private final String repoName; public Changelog( final List<Commit> commits, final List<Tag> tags, final List<Author> authors, final List<Issue> issues, final List<IssueType> issueTypes, final String ownerName, final String repoName) {
this.commits = checkNotNull(commits, "commits");
tomasbjerre/git-changelog-lib
src/test/java/se/bjurr/gitchangelog/internal/integrations/redmine/RedmineClientTest.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; import java.util.Optional; import org.junit.Test; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.redmine; public class RedmineClientTest { @Test public void testThatTrailingSlashIsRemoved() { final RedmineClient client = this.createClient("https://server.com/redmine/"); assertThat(client.getApi()) // .isEqualTo("https://server.com/redmine"); } @Test public void testThatNoTrailingSlashUrlIsUntouched() { final RedmineClient client = this.createClient("https://server.com/redmine"); assertThat(client.getApi()) // .isEqualTo("https://server.com/redmine"); } private RedmineClient createClient(final String api) { return new RedmineClient(api) { @Override public RedmineClient withBasicCredentials(final String username, final String password) { return null; } @Override public RedmineClient withTokenCredentials(final String token) { return null; } @Override public RedmineClient withHeaders(final Map<String, String> headers) { return null; } @Override public Optional<RedmineIssue> getIssue(final String matched)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/test/java/se/bjurr/gitchangelog/internal/integrations/redmine/RedmineClientTest.java import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; import java.util.Optional; import org.junit.Test; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; package se.bjurr.gitchangelog.internal.integrations.redmine; public class RedmineClientTest { @Test public void testThatTrailingSlashIsRemoved() { final RedmineClient client = this.createClient("https://server.com/redmine/"); assertThat(client.getApi()) // .isEqualTo("https://server.com/redmine"); } @Test public void testThatNoTrailingSlashUrlIsUntouched() { final RedmineClient client = this.createClient("https://server.com/redmine"); assertThat(client.getApi()) // .isEqualTo("https://server.com/redmine"); } private RedmineClient createClient(final String api) { return new RedmineClient(api) { @Override public RedmineClient withBasicCredentials(final String username, final String password) { return null; } @Override public RedmineClient withTokenCredentials(final String token) { return null; } @Override public RedmineClient withHeaders(final Map<String, String> headers) { return null; } @Override public Optional<RedmineIssue> getIssue(final String matched)
throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues;
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Issue.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues;
private final SettingsIssueType issueType;
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Issue.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) {
checkState(!commits.isEmpty(), "commits");
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits;
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Issue.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits;
this.authors = checkNotNull(authors, "authors");
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits; this.authors = checkNotNull(authors, "authors"); this.name = checkNotNull(name, "name");
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Issue.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits; this.authors = checkNotNull(authors, "authors"); this.name = checkNotNull(name, "name");
this.title = nullToEmpty(title);
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits; this.authors = checkNotNull(authors, "authors"); this.name = checkNotNull(name, "name"); this.title = nullToEmpty(title);
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static String nullToEmpty(final String it) { // if (it == null) { // return ""; // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Issue.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import static se.bjurr.gitchangelog.internal.util.Preconditions.nullToEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class Issue implements ICommits, IAuthors, Serializable { private static final long serialVersionUID = -7571341639024417199L; private final List<Commit> commits; private final List<Author> authors; /** Like JIRA, or GitHub. */ private final String name; /** Like the title of a Jira. */ private final String title; private final boolean hasTitle; /** Like the actual Jira, JIR-ABC. */ private final String issue; private final boolean hasIssue; /** A link to the issue, http://..... */ private final String link; private final boolean hasLink; /** Type of issue, perhaps Story, Bug and etc */ private final String type; private final boolean hasType; private final boolean hasDescription; private final String description; /** Labels on the issue, for GitHub it may be bug, enhancement, ... */ private final List<String> labels; private final boolean hasLabels; private final boolean hasLinkedIssues; private final SettingsIssueType issueType; private final List<String> linkedIssues; public Issue( final List<Commit> commits, final List<Author> authors, final String name, final String title, final String issue, final SettingsIssueType issueType, final String description, final String link, final String type, final List<String> linkedIssues, final List<String> labels) { checkState(!commits.isEmpty(), "commits"); this.commits = commits; this.authors = checkNotNull(authors, "authors"); this.name = checkNotNull(name, "name"); this.title = nullToEmpty(title);
this.hasTitle = !isNullOrEmpty(title);
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/semantic/SemanticVersion.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/semantic/SemanticVersioning.java // public enum VERSION_STEP { // MAJOR, // MINOR, // PATCH, // /** Was not stepped. Given patch pattern did not match. */ // NONE // }
import java.io.Serializable; import java.util.Optional; import se.bjurr.gitchangelog.internal.semantic.SemanticVersioning.VERSION_STEP;
package se.bjurr.gitchangelog.internal.semantic; public class SemanticVersion implements Serializable { private static final long serialVersionUID = -7875655375353325189L; private final int patch; private final int minor; private final int major; private String tag;
// Path: src/main/java/se/bjurr/gitchangelog/internal/semantic/SemanticVersioning.java // public enum VERSION_STEP { // MAJOR, // MINOR, // PATCH, // /** Was not stepped. Given patch pattern did not match. */ // NONE // } // Path: src/main/java/se/bjurr/gitchangelog/internal/semantic/SemanticVersion.java import java.io.Serializable; import java.util.Optional; import se.bjurr.gitchangelog.internal.semantic.SemanticVersioning.VERSION_STEP; package se.bjurr.gitchangelog.internal.semantic; public class SemanticVersion implements Serializable { private static final long serialVersionUID = -7875655375353325189L; private final int patch; private final int minor; private final int major; private String tag;
private VERSION_STEP versionStep;
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Commit.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // }
import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors;
} } return toReturn; } static String toMessageTitle(final String message) { final List<String> stringList = toNoEmptyStringsList(message); if (stringList.size() > 0) { return stringList.get(0).trim(); } return ""; } private final String authorEmailAddress; private final String authorName; private final String commitTime; private final Long commitTimeLong; private final String hash; private final String hashFull; private final Boolean merge; private final String message; public Commit( final String authorName, final String authorEmailAddress, final String commitTime, final Long commitTimeLong, final String message, final String hash, final Boolean merge) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Commit.java import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; } } return toReturn; } static String toMessageTitle(final String message) { final List<String> stringList = toNoEmptyStringsList(message); if (stringList.size() > 0) { return stringList.get(0).trim(); } return ""; } private final String authorEmailAddress; private final String authorName; private final String commitTime; private final Long commitTimeLong; private final String hash; private final String hashFull; private final Boolean merge; private final String message; public Commit( final String authorName, final String authorEmailAddress, final String commitTime, final Long commitTimeLong, final String message, final String hash, final Boolean merge) {
this.authorName = checkNotNull(authorName, "authorName");
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/settings/IssuesUtil.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import java.util.ArrayList; import java.util.List;
package se.bjurr.gitchangelog.internal.settings; public class IssuesUtil { private final Settings settings; public IssuesUtil(final Settings settings) { this.settings = settings; } public List<SettingsIssue> getIssues() { final List<SettingsIssue> issues = new ArrayList<>(this.settings.getCustomIssues()); if (this.settings.isJiraEnabled()) { this.addJira(issues); } if (this.settings.isGitHubEnabled()) { this.addGitHub(issues); } if (this.settings.isGitLabEnabled()) { this.addGitLab(issues); } if (this.settings.isRedmineEnabled()) { this.addRedmine(issues); } return issues; } private void addGitHub(final List<SettingsIssue> issues) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/IssuesUtil.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import java.util.ArrayList; import java.util.List; package se.bjurr.gitchangelog.internal.settings; public class IssuesUtil { private final Settings settings; public IssuesUtil(final Settings settings) { this.settings = settings; } public List<SettingsIssue> getIssues() { final List<SettingsIssue> issues = new ArrayList<>(this.settings.getCustomIssues()); if (this.settings.isJiraEnabled()) { this.addJira(issues); } if (this.settings.isGitHubEnabled()) { this.addGitHub(issues); } if (this.settings.isGitLabEnabled()) { this.addGitLab(issues); } if (this.settings.isRedmineEnabled()) { this.addRedmine(issues); } return issues; } private void addGitHub(final List<SettingsIssue> issues) {
if (!isNullOrEmpty(this.settings.getGitHubIssuePattern())) {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/jira/JiraClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static com.jayway.jsonpath.JsonPath.read; import com.jayway.jsonpath.JsonPath; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
+ "?fields=parent,summary,issuetype,labels,description,issuelinks"; return endpoint; } protected JiraIssue toJiraIssue(final String issue, final String json) { final String title = read(json, "$.fields.summary"); final String description = read(json, "$.fields.description"); final String type = read(json, "$.fields.issuetype.name"); final String link = this.api + "/browse/" + issue; final List<String> labels = JsonPath.read(json, "$.fields.labels"); final List<String> linkedIssues = new ArrayList<>(); final List<String> inwardKey = JsonPath.read(json, "$.fields.issuelinks[*].inwardIssue.key"); final List<String> outwardKey = JsonPath.read(json, "$.fields.issuelinks[*].outwardIssue.key"); linkedIssues.addAll(inwardKey); linkedIssues.addAll(outwardKey); final JiraIssue jiraIssue = new JiraIssue(title, description, link, issue, type, linkedIssues, labels); return jiraIssue; } public abstract JiraClient withBasicCredentials(String username, String password); public abstract JiraClient withBearer(String bearerToken); public abstract JiraClient withTokenCredentials(String token); public abstract JiraClient withHeaders(Map<String, String> headers); public abstract Optional<JiraIssue> getIssue(String matched)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/jira/JiraClient.java import static com.jayway.jsonpath.JsonPath.read; import com.jayway.jsonpath.JsonPath; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; + "?fields=parent,summary,issuetype,labels,description,issuelinks"; return endpoint; } protected JiraIssue toJiraIssue(final String issue, final String json) { final String title = read(json, "$.fields.summary"); final String description = read(json, "$.fields.description"); final String type = read(json, "$.fields.issuetype.name"); final String link = this.api + "/browse/" + issue; final List<String> labels = JsonPath.read(json, "$.fields.labels"); final List<String> linkedIssues = new ArrayList<>(); final List<String> inwardKey = JsonPath.read(json, "$.fields.issuelinks[*].inwardIssue.key"); final List<String> outwardKey = JsonPath.read(json, "$.fields.issuelinks[*].outwardIssue.key"); linkedIssues.addAll(inwardKey); linkedIssues.addAll(outwardKey); final JiraIssue jiraIssue = new JiraIssue(title, description, link, issue, type, linkedIssues, labels); return jiraIssue; } public abstract JiraClient withBasicCredentials(String username, String password); public abstract JiraClient withBearer(String bearerToken); public abstract JiraClient withTokenCredentials(String token); public abstract JiraClient withHeaders(Map<String, String> headers); public abstract Optional<JiraIssue> getIssue(String matched)
throws GitChangelogIntegrationException;
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/gitlab/GitLabClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.gitlab.api.GitlabAPI; import org.gitlab.api.models.GitlabIssue; import org.gitlab.api.models.GitlabProject; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.gitlab; public class GitLabClient { private final String hostUrl; private final String apiToken; private List<GitlabIssue> issues; public GitLabClient(final String hostUrl, final String apiToken) { this.hostUrl = hostUrl; this.apiToken = apiToken; } public Optional<GitLabIssue> getIssue(final String projectName, final Integer matchedIssue)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/gitlab/GitLabClient.java import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.gitlab.api.GitlabAPI; import org.gitlab.api.models.GitlabIssue; import org.gitlab.api.models.GitlabProject; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; package se.bjurr.gitchangelog.internal.integrations.gitlab; public class GitLabClient { private final String hostUrl; private final String apiToken; private List<GitlabIssue> issues; public GitLabClient(final String hostUrl, final String apiToken) { this.hostUrl = hostUrl; this.apiToken = apiToken; } public Optional<GitLabIssue> getIssue(final String projectName, final Integer matchedIssue)
throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues;
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues;
private final SettingsIssueType type;
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues; private final SettingsIssueType type; public IssueType(final List<Issue> issues, final String name) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues; private final SettingsIssueType type; public IssueType(final List<Issue> issues, final String name) {
this.name = checkNotNull(name, "name");
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // }
import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType;
package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues; private final SettingsIssueType type; public IssueType(final List<Issue> issues, final String name) { this.name = checkNotNull(name, "name"); this.issues = checkNotNull(issues, "issues");
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkState(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/settings/SettingsIssueType.java // public enum SettingsIssueType { // NOISSUE, // CUSTOM, // JIRA, // GITHUB, // GITLAB, // REDMINE // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/IssueType.java import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.CUSTOM; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITHUB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.GITLAB; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.JIRA; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.NOISSUE; import static se.bjurr.gitchangelog.internal.settings.SettingsIssueType.REDMINE; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkState; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.internal.settings.SettingsIssueType; package se.bjurr.gitchangelog.api.model; public class IssueType implements Serializable { private static final long serialVersionUID = 8850522973130773606L; private final String name; private final List<Issue> issues; private final SettingsIssueType type; public IssueType(final List<Issue> issues, final String name) { this.name = checkNotNull(name, "name"); this.issues = checkNotNull(issues, "issues");
checkState(!issues.isEmpty(), "Issues empty!");
tomasbjerre/git-changelog-lib
src/test/java/se/bjurr/gitchangelog/internal/integrations/jira/JiraClientTest.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; import java.util.Optional; import org.junit.Test; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
final JiraClient client = this.createClient("https://server.com/jira"); assertThat(client.getApi()) // .isEqualTo("https://server.com/jira"); } private JiraClient createClient(final String api) { return new JiraClient(api) { @Override public JiraClient withBasicCredentials(final String username, final String password) { return null; } @Override public JiraClient withBearer(final String bearer) { return null; } @Override public JiraClient withTokenCredentials(final String token) { return null; } @Override public JiraClient withHeaders(final Map<String, String> headers) { return null; } @Override public Optional<JiraIssue> getIssue(final String matched)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/test/java/se/bjurr/gitchangelog/internal/integrations/jira/JiraClientTest.java import static org.assertj.core.api.Assertions.assertThat; import java.util.Map; import java.util.Optional; import org.junit.Test; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; final JiraClient client = this.createClient("https://server.com/jira"); assertThat(client.getApi()) // .isEqualTo("https://server.com/jira"); } private JiraClient createClient(final String api) { return new JiraClient(api) { @Override public JiraClient withBasicCredentials(final String username, final String password) { return null; } @Override public JiraClient withBearer(final String bearer) { return null; } @Override public JiraClient withTokenCredentials(final String token) { return null; } @Override public JiraClient withHeaders(final Map<String, String> headers) { return null; } @Override public Optional<JiraIssue> getIssue(final String matched)
throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static org.slf4j.LoggerFactory.getLogger; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.rest; public class RestClient { private static Logger logger = getLogger(RestClient.class); private static RestClient mockedRestClient; private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); private String basicAuthString; private String bearer; private Map<String, String> headers; public RestClient() {} public RestClient withBasicAuthCredentials(final String username, final String password) { try { this.basicAuthString = Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } return this; } public RestClient withTokenAuthCredentials(final String token) { this.basicAuthString = token; return this; } public RestClient withBearer(final String bearer) { this.bearer = bearer; return this; } public RestClient withHeaders(final Map<String, String> headers) { this.headers = headers; return this; }
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java import static org.slf4j.LoggerFactory.getLogger; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; package se.bjurr.gitchangelog.internal.integrations.rest; public class RestClient { private static Logger logger = getLogger(RestClient.class); private static RestClient mockedRestClient; private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); private String basicAuthString; private String bearer; private Map<String, String> headers; public RestClient() {} public RestClient withBasicAuthCredentials(final String username, final String password) { try { this.basicAuthString = Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } return this; } public RestClient withTokenAuthCredentials(final String token) { this.basicAuthString = token; return this; } public RestClient withBearer(final String bearer) { this.bearer = bearer; return this; } public RestClient withHeaders(final Map<String, String> headers) { this.headers = headers; return this; }
public Optional<String> get(final String url) throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/redmine/DefaultRedmineClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java // public class RestClient { // private static Logger logger = getLogger(RestClient.class); // private static RestClient mockedRestClient; // private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); // private String basicAuthString; // private String bearer; // private Map<String, String> headers; // // public RestClient() {} // // public RestClient withBasicAuthCredentials(final String username, final String password) { // try { // this.basicAuthString = // Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); // } catch (final UnsupportedEncodingException e) { // throw new RuntimeException(e); // } // return this; // } // // public RestClient withTokenAuthCredentials(final String token) { // this.basicAuthString = token; // return this; // } // // public RestClient withBearer(final String bearer) { // this.bearer = bearer; // return this; // } // // public RestClient withHeaders(final Map<String, String> headers) { // this.headers = headers; // return this; // } // // public Optional<String> get(final String url) throws GitChangelogIntegrationException { // try { // if (!this.urlCache.containsKey(url)) { // final Optional<String> content = RestClient.this.doGet(url); // this.urlCache.put(url, content); // } // return this.urlCache.get(url); // } catch (final Exception e) { // throw new GitChangelogIntegrationException("Problems invoking " + url, e); // } // } // // private Optional<String> doGet(final String urlParam) { // final String response = null; // HttpURLConnection conn = null; // try { // logger.info("GET:\n" + urlParam); // final URL url = new URL(urlParam); // conn = this.openConnection(url); // conn.setRequestProperty("Content-Type", "application/json"); // conn.setRequestProperty("Accept", "application/json"); // if (this.headers != null) { // for (final Entry<String, String> entry : this.headers.entrySet()) { // conn.setRequestProperty(entry.getKey(), entry.getValue()); // } // } // if (this.bearer != null) { // conn.setRequestProperty("Authorization", "Bearer " + this.bearer); // } else if (this.basicAuthString != null) { // conn.setRequestProperty("Authorization", "Basic " + this.basicAuthString); // } // return Optional.of(this.getResponse(conn)); // } catch (final Exception e) { // logger.error("Got:\n" + response, e); // return Optional.empty(); // } finally { // if (conn != null) { // conn.disconnect(); // } // } // } // // protected HttpURLConnection openConnection(final URL url) throws Exception { // if (mockedRestClient == null) { // return (HttpURLConnection) url.openConnection(); // } // return mockedRestClient.openConnection(url); // } // // protected String getResponse(final HttpURLConnection conn) throws Exception { // if (mockedRestClient == null) { // final InputStream inputStream = conn.getInputStream(); // InputStreamReader inputStreamReader = // new InputStreamReader(inputStream, StandardCharsets.UTF_8); // BufferedReader bufferedReader = new BufferedReader(inputStreamReader); // return bufferedReader.readLine(); // } // return mockedRestClient.getResponse(conn); // } // // public static void mock(final RestClient mock) { // mockedRestClient = mock; // } // }
import java.io.UnsupportedEncodingException; import java.util.Base64; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; import se.bjurr.gitchangelog.internal.integrations.rest.RestClient;
package se.bjurr.gitchangelog.internal.integrations.redmine; public class DefaultRedmineClient extends RedmineClient { private RestClient client; public DefaultRedmineClient(final String api) { super(api); this.client = new RestClient(); } @Override public RedmineClient withBasicCredentials(final String username, final String password) { this.client = this.client.withBasicAuthCredentials(username, password); return this; } @Override public RedmineClient withTokenCredentials(final String token) { String authToken; try { authToken = Base64.getEncoder().encodeToString((token + ":changelog").getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } this.client = this.client.withTokenAuthCredentials(authToken); return this; } @Override public RedmineClient withHeaders(final Map<String, String> headers) { this.client = this.client.withHeaders(headers); return this; } @Override public Optional<RedmineIssue> getIssue(final String issue)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java // public class RestClient { // private static Logger logger = getLogger(RestClient.class); // private static RestClient mockedRestClient; // private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); // private String basicAuthString; // private String bearer; // private Map<String, String> headers; // // public RestClient() {} // // public RestClient withBasicAuthCredentials(final String username, final String password) { // try { // this.basicAuthString = // Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); // } catch (final UnsupportedEncodingException e) { // throw new RuntimeException(e); // } // return this; // } // // public RestClient withTokenAuthCredentials(final String token) { // this.basicAuthString = token; // return this; // } // // public RestClient withBearer(final String bearer) { // this.bearer = bearer; // return this; // } // // public RestClient withHeaders(final Map<String, String> headers) { // this.headers = headers; // return this; // } // // public Optional<String> get(final String url) throws GitChangelogIntegrationException { // try { // if (!this.urlCache.containsKey(url)) { // final Optional<String> content = RestClient.this.doGet(url); // this.urlCache.put(url, content); // } // return this.urlCache.get(url); // } catch (final Exception e) { // throw new GitChangelogIntegrationException("Problems invoking " + url, e); // } // } // // private Optional<String> doGet(final String urlParam) { // final String response = null; // HttpURLConnection conn = null; // try { // logger.info("GET:\n" + urlParam); // final URL url = new URL(urlParam); // conn = this.openConnection(url); // conn.setRequestProperty("Content-Type", "application/json"); // conn.setRequestProperty("Accept", "application/json"); // if (this.headers != null) { // for (final Entry<String, String> entry : this.headers.entrySet()) { // conn.setRequestProperty(entry.getKey(), entry.getValue()); // } // } // if (this.bearer != null) { // conn.setRequestProperty("Authorization", "Bearer " + this.bearer); // } else if (this.basicAuthString != null) { // conn.setRequestProperty("Authorization", "Basic " + this.basicAuthString); // } // return Optional.of(this.getResponse(conn)); // } catch (final Exception e) { // logger.error("Got:\n" + response, e); // return Optional.empty(); // } finally { // if (conn != null) { // conn.disconnect(); // } // } // } // // protected HttpURLConnection openConnection(final URL url) throws Exception { // if (mockedRestClient == null) { // return (HttpURLConnection) url.openConnection(); // } // return mockedRestClient.openConnection(url); // } // // protected String getResponse(final HttpURLConnection conn) throws Exception { // if (mockedRestClient == null) { // final InputStream inputStream = conn.getInputStream(); // InputStreamReader inputStreamReader = // new InputStreamReader(inputStream, StandardCharsets.UTF_8); // BufferedReader bufferedReader = new BufferedReader(inputStreamReader); // return bufferedReader.readLine(); // } // return mockedRestClient.getResponse(conn); // } // // public static void mock(final RestClient mock) { // mockedRestClient = mock; // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/redmine/DefaultRedmineClient.java import java.io.UnsupportedEncodingException; import java.util.Base64; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; import se.bjurr.gitchangelog.internal.integrations.rest.RestClient; package se.bjurr.gitchangelog.internal.integrations.redmine; public class DefaultRedmineClient extends RedmineClient { private RestClient client; public DefaultRedmineClient(final String api) { super(api); this.client = new RestClient(); } @Override public RedmineClient withBasicCredentials(final String username, final String password) { this.client = this.client.withBasicAuthCredentials(username, password); return this; } @Override public RedmineClient withTokenCredentials(final String token) { String authToken; try { authToken = Base64.getEncoder().encodeToString((token + ":changelog").getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } this.client = this.client.withTokenAuthCredentials(authToken); return this; } @Override public RedmineClient withHeaders(final Map<String, String> headers) { this.client = this.client.withHeaders(headers); return this; } @Override public Optional<RedmineIssue> getIssue(final String issue)
throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkArgument(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/model/interfaces/IGitCommitReferer.java // public interface IGitCommitReferer { // GitCommit getGitCommit(); // // String getName(); // }
import static se.bjurr.gitchangelog.internal.util.Preconditions.checkArgument; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.util.Date; import java.util.List; import java.util.Optional; import se.bjurr.gitchangelog.internal.model.interfaces.IGitCommitReferer;
package se.bjurr.gitchangelog.internal.git.model; public class GitTag implements IGitCommitReferer { private final String annotation; private final List<GitCommit> gitCommits; private final String name; private final Date tagTime; public GitTag( final String name, final String annotation, final List<GitCommit> gitCommits, final Date tagTime) {
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkArgument(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/model/interfaces/IGitCommitReferer.java // public interface IGitCommitReferer { // GitCommit getGitCommit(); // // String getName(); // } // Path: src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java import static se.bjurr.gitchangelog.internal.util.Preconditions.checkArgument; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.util.Date; import java.util.List; import java.util.Optional; import se.bjurr.gitchangelog.internal.model.interfaces.IGitCommitReferer; package se.bjurr.gitchangelog.internal.git.model; public class GitTag implements IGitCommitReferer { private final String annotation; private final List<GitCommit> gitCommits; private final String name; private final Date tagTime; public GitTag( final String name, final String annotation, final List<GitCommit> gitCommits, final Date tagTime) {
checkArgument(!gitCommits.isEmpty(), "No commits in " + name);
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkArgument(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/model/interfaces/IGitCommitReferer.java // public interface IGitCommitReferer { // GitCommit getGitCommit(); // // String getName(); // }
import static se.bjurr.gitchangelog.internal.util.Preconditions.checkArgument; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.util.Date; import java.util.List; import java.util.Optional; import se.bjurr.gitchangelog.internal.model.interfaces.IGitCommitReferer;
package se.bjurr.gitchangelog.internal.git.model; public class GitTag implements IGitCommitReferer { private final String annotation; private final List<GitCommit> gitCommits; private final String name; private final Date tagTime; public GitTag( final String name, final String annotation, final List<GitCommit> gitCommits, final Date tagTime) { checkArgument(!gitCommits.isEmpty(), "No commits in " + name);
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static void checkArgument(final boolean b, final String string) { // if (!b) { // throw new IllegalStateException(string); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static <T> T checkNotNull(final T it, final String string) { // if (it == null) { // throw new IllegalStateException(string); // } // return it; // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/model/interfaces/IGitCommitReferer.java // public interface IGitCommitReferer { // GitCommit getGitCommit(); // // String getName(); // } // Path: src/main/java/se/bjurr/gitchangelog/internal/git/model/GitTag.java import static se.bjurr.gitchangelog.internal.util.Preconditions.checkArgument; import static se.bjurr.gitchangelog.internal.util.Preconditions.checkNotNull; import java.util.Date; import java.util.List; import java.util.Optional; import se.bjurr.gitchangelog.internal.model.interfaces.IGitCommitReferer; package se.bjurr.gitchangelog.internal.git.model; public class GitTag implements IGitCommitReferer { private final String annotation; private final List<GitCommit> gitCommits; private final String name; private final Date tagTime; public GitTag( final String name, final String annotation, final List<GitCommit> gitCommits, final Date tagTime) { checkArgument(!gitCommits.isEmpty(), "No commits in " + name);
this.name = checkNotNull(name, "name");
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/redmine/RedmineClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static com.jayway.jsonpath.JsonPath.read; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
} protected String getEndpoint(final String issue) { final String issueNo = getIssueNumber(issue); final String endpoint = this.api + "/issues/" + issueNo + ".json"; return endpoint; } protected RedmineIssue toRedmineIssue(final String issue, final String json) { final String issueNo = getIssueNumber(issue); final String title = read(json, "$.issue.subject"); final String description = read(json, "$.issue.description"); final String type = read(json, "$.issue.tracker.name"); final String link = this.api + "/issues/" + issueNo; final RedmineIssue redmineIssue = new RedmineIssue(title, description, link, issue, type); return redmineIssue; } protected String getIssueNumber(String issue) { return issue.startsWith("#") ? issue.substring(1) : issue; } public abstract RedmineClient withBasicCredentials(String username, String password); public abstract RedmineClient withTokenCredentials(String token); public abstract RedmineClient withHeaders(Map<String, String> headers); public abstract Optional<RedmineIssue> getIssue(String matched)
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/redmine/RedmineClient.java import static com.jayway.jsonpath.JsonPath.read; import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; } protected String getEndpoint(final String issue) { final String issueNo = getIssueNumber(issue); final String endpoint = this.api + "/issues/" + issueNo + ".json"; return endpoint; } protected RedmineIssue toRedmineIssue(final String issue, final String json) { final String issueNo = getIssueNumber(issue); final String title = read(json, "$.issue.subject"); final String description = read(json, "$.issue.description"); final String type = read(json, "$.issue.tracker.name"); final String link = this.api + "/issues/" + issueNo; final RedmineIssue redmineIssue = new RedmineIssue(title, description, link, issue, type); return redmineIssue; } protected String getIssueNumber(String issue) { return issue.startsWith("#") ? issue.substring(1) : issue; } public abstract RedmineClient withBasicCredentials(String username, String password); public abstract RedmineClient withTokenCredentials(String token); public abstract RedmineClient withHeaders(Map<String, String> headers); public abstract Optional<RedmineIssue> getIssue(String matched)
throws GitChangelogIntegrationException;
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/internal/integrations/jira/DefaultJiraClient.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java // public class RestClient { // private static Logger logger = getLogger(RestClient.class); // private static RestClient mockedRestClient; // private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); // private String basicAuthString; // private String bearer; // private Map<String, String> headers; // // public RestClient() {} // // public RestClient withBasicAuthCredentials(final String username, final String password) { // try { // this.basicAuthString = // Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); // } catch (final UnsupportedEncodingException e) { // throw new RuntimeException(e); // } // return this; // } // // public RestClient withTokenAuthCredentials(final String token) { // this.basicAuthString = token; // return this; // } // // public RestClient withBearer(final String bearer) { // this.bearer = bearer; // return this; // } // // public RestClient withHeaders(final Map<String, String> headers) { // this.headers = headers; // return this; // } // // public Optional<String> get(final String url) throws GitChangelogIntegrationException { // try { // if (!this.urlCache.containsKey(url)) { // final Optional<String> content = RestClient.this.doGet(url); // this.urlCache.put(url, content); // } // return this.urlCache.get(url); // } catch (final Exception e) { // throw new GitChangelogIntegrationException("Problems invoking " + url, e); // } // } // // private Optional<String> doGet(final String urlParam) { // final String response = null; // HttpURLConnection conn = null; // try { // logger.info("GET:\n" + urlParam); // final URL url = new URL(urlParam); // conn = this.openConnection(url); // conn.setRequestProperty("Content-Type", "application/json"); // conn.setRequestProperty("Accept", "application/json"); // if (this.headers != null) { // for (final Entry<String, String> entry : this.headers.entrySet()) { // conn.setRequestProperty(entry.getKey(), entry.getValue()); // } // } // if (this.bearer != null) { // conn.setRequestProperty("Authorization", "Bearer " + this.bearer); // } else if (this.basicAuthString != null) { // conn.setRequestProperty("Authorization", "Basic " + this.basicAuthString); // } // return Optional.of(this.getResponse(conn)); // } catch (final Exception e) { // logger.error("Got:\n" + response, e); // return Optional.empty(); // } finally { // if (conn != null) { // conn.disconnect(); // } // } // } // // protected HttpURLConnection openConnection(final URL url) throws Exception { // if (mockedRestClient == null) { // return (HttpURLConnection) url.openConnection(); // } // return mockedRestClient.openConnection(url); // } // // protected String getResponse(final HttpURLConnection conn) throws Exception { // if (mockedRestClient == null) { // final InputStream inputStream = conn.getInputStream(); // InputStreamReader inputStreamReader = // new InputStreamReader(inputStream, StandardCharsets.UTF_8); // BufferedReader bufferedReader = new BufferedReader(inputStreamReader); // return bufferedReader.readLine(); // } // return mockedRestClient.getResponse(conn); // } // // public static void mock(final RestClient mock) { // mockedRestClient = mock; // } // }
import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; import se.bjurr.gitchangelog.internal.integrations.rest.RestClient;
package se.bjurr.gitchangelog.internal.integrations.jira; public class DefaultJiraClient extends JiraClient { private RestClient client; public DefaultJiraClient(final String api) { super(api); this.client = new RestClient(); } @Override public JiraClient withBasicCredentials(final String username, final String password) { this.client = this.client.withBasicAuthCredentials(username, password); return this; } @Override public JiraClient withBearer(final String bearerToken) { this.client = this.client.withBearer(bearerToken); return this; } @Override public JiraClient withTokenCredentials(final String token) { this.client = this.client.withTokenAuthCredentials(token); return this; } @Override public JiraClient withHeaders(final Map<String, String> headers) { this.client = this.client.withHeaders(headers); return this; } @Override
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/rest/RestClient.java // public class RestClient { // private static Logger logger = getLogger(RestClient.class); // private static RestClient mockedRestClient; // private final Map<String, Optional<String>> urlCache = new ConcurrentHashMap<>(); // private String basicAuthString; // private String bearer; // private Map<String, String> headers; // // public RestClient() {} // // public RestClient withBasicAuthCredentials(final String username, final String password) { // try { // this.basicAuthString = // Base64.getEncoder().encodeToString((username + ":" + password).getBytes("UTF-8")); // } catch (final UnsupportedEncodingException e) { // throw new RuntimeException(e); // } // return this; // } // // public RestClient withTokenAuthCredentials(final String token) { // this.basicAuthString = token; // return this; // } // // public RestClient withBearer(final String bearer) { // this.bearer = bearer; // return this; // } // // public RestClient withHeaders(final Map<String, String> headers) { // this.headers = headers; // return this; // } // // public Optional<String> get(final String url) throws GitChangelogIntegrationException { // try { // if (!this.urlCache.containsKey(url)) { // final Optional<String> content = RestClient.this.doGet(url); // this.urlCache.put(url, content); // } // return this.urlCache.get(url); // } catch (final Exception e) { // throw new GitChangelogIntegrationException("Problems invoking " + url, e); // } // } // // private Optional<String> doGet(final String urlParam) { // final String response = null; // HttpURLConnection conn = null; // try { // logger.info("GET:\n" + urlParam); // final URL url = new URL(urlParam); // conn = this.openConnection(url); // conn.setRequestProperty("Content-Type", "application/json"); // conn.setRequestProperty("Accept", "application/json"); // if (this.headers != null) { // for (final Entry<String, String> entry : this.headers.entrySet()) { // conn.setRequestProperty(entry.getKey(), entry.getValue()); // } // } // if (this.bearer != null) { // conn.setRequestProperty("Authorization", "Bearer " + this.bearer); // } else if (this.basicAuthString != null) { // conn.setRequestProperty("Authorization", "Basic " + this.basicAuthString); // } // return Optional.of(this.getResponse(conn)); // } catch (final Exception e) { // logger.error("Got:\n" + response, e); // return Optional.empty(); // } finally { // if (conn != null) { // conn.disconnect(); // } // } // } // // protected HttpURLConnection openConnection(final URL url) throws Exception { // if (mockedRestClient == null) { // return (HttpURLConnection) url.openConnection(); // } // return mockedRestClient.openConnection(url); // } // // protected String getResponse(final HttpURLConnection conn) throws Exception { // if (mockedRestClient == null) { // final InputStream inputStream = conn.getInputStream(); // InputStreamReader inputStreamReader = // new InputStreamReader(inputStream, StandardCharsets.UTF_8); // BufferedReader bufferedReader = new BufferedReader(inputStreamReader); // return bufferedReader.readLine(); // } // return mockedRestClient.getResponse(conn); // } // // public static void mock(final RestClient mock) { // mockedRestClient = mock; // } // } // Path: src/main/java/se/bjurr/gitchangelog/internal/integrations/jira/DefaultJiraClient.java import java.util.Map; import java.util.Optional; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; import se.bjurr.gitchangelog.internal.integrations.rest.RestClient; package se.bjurr.gitchangelog.internal.integrations.jira; public class DefaultJiraClient extends JiraClient { private RestClient client; public DefaultJiraClient(final String api) { super(api); this.client = new RestClient(); } @Override public JiraClient withBasicCredentials(final String username, final String password) { this.client = this.client.withBasicAuthCredentials(username, password); return this; } @Override public JiraClient withBearer(final String bearerToken) { this.client = this.client.withBearer(bearerToken); return this; } @Override public JiraClient withTokenCredentials(final String token) { this.client = this.client.withTokenAuthCredentials(token); return this; } @Override public JiraClient withHeaders(final Map<String, String> headers) { this.client = this.client.withHeaders(headers); return this; } @Override
public Optional<JiraIssue> getIssue(final String issue) throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/test/java/se/bjurr/gitchangelog/internal/integrations/gitlab/GitLabClientTest.java
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // }
import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException;
package se.bjurr.gitchangelog.internal.integrations.gitlab; public class GitLabClientTest { private static Logger LOG = LoggerFactory.getLogger(GitLabClientTest.class); private GitLabClient sut; private boolean disabled; @Before public void before() throws IOException { final String hostUrl = "https://gitlab.com/"; String apiToken = null; try { apiToken = new String( Files.readAllBytes(new File("/home/bjerre/gitlabapitoken.txt").toPath()), StandardCharsets.UTF_8) .trim(); } catch (final Exception e) { this.disabled = true; return; } this.sut = new GitLabClient(hostUrl, apiToken); } @Test
// Path: src/main/java/se/bjurr/gitchangelog/api/exceptions/GitChangelogIntegrationException.java // public class GitChangelogIntegrationException extends Exception { // // private static final long serialVersionUID = 4249741847365803709L; // // public GitChangelogIntegrationException(String message, Throwable throwable) { // super(message, throwable); // } // // public GitChangelogIntegrationException(String message) { // super(message); // } // } // Path: src/test/java/se/bjurr/gitchangelog/internal/integrations/gitlab/GitLabClientTest.java import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import se.bjurr.gitchangelog.api.exceptions.GitChangelogIntegrationException; package se.bjurr.gitchangelog.internal.integrations.gitlab; public class GitLabClientTest { private static Logger LOG = LoggerFactory.getLogger(GitLabClientTest.class); private GitLabClient sut; private boolean disabled; @Before public void before() throws IOException { final String hostUrl = "https://gitlab.com/"; String apiToken = null; try { apiToken = new String( Files.readAllBytes(new File("/home/bjerre/gitlabapitoken.txt").toPath()), StandardCharsets.UTF_8) .trim(); } catch (final Exception e) { this.disabled = true; return; } this.sut = new GitLabClient(hostUrl, apiToken); } @Test
public void testGetIssue() throws GitChangelogIntegrationException {
tomasbjerre/git-changelog-lib
src/main/java/se/bjurr/gitchangelog/api/model/Tag.java
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IIssues.java // public interface IIssues { // List<Issue> getIssues(); // }
import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.api.model.interfaces.IIssues;
package se.bjurr.gitchangelog.api.model; public class Tag implements ICommits, IAuthors, IIssues, Serializable { private static final long serialVersionUID = 2140208294219785889L; private final String annotation; private final List<Author> authors; private final List<Commit> commits; private final List<Issue> issues; private final List<IssueType> issueTypes; private final String name; private final String tagTime; private final Long tagTimeLong; private final boolean hasTagTime; public Tag( final String name, final String annotation, final List<Commit> commits, final List<Author> authors, final List<Issue> issues, final List<IssueType> issueTypes, final String tagTime, final Long tagTimeLong) { this.commits = commits; this.authors = authors; this.issues = issues; this.name = name; this.annotation = annotation; this.issueTypes = issueTypes; this.tagTime = tagTime; this.tagTimeLong = tagTimeLong;
// Path: src/main/java/se/bjurr/gitchangelog/internal/util/Preconditions.java // public static boolean isNullOrEmpty(final String it) { // return it == null || it.isEmpty(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IAuthors.java // public interface IAuthors { // List<Author> getAuthors(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/ICommits.java // public interface ICommits { // List<Commit> getCommits(); // } // // Path: src/main/java/se/bjurr/gitchangelog/api/model/interfaces/IIssues.java // public interface IIssues { // List<Issue> getIssues(); // } // Path: src/main/java/se/bjurr/gitchangelog/api/model/Tag.java import static se.bjurr.gitchangelog.internal.util.Preconditions.isNullOrEmpty; import java.io.Serializable; import java.util.List; import se.bjurr.gitchangelog.api.model.interfaces.IAuthors; import se.bjurr.gitchangelog.api.model.interfaces.ICommits; import se.bjurr.gitchangelog.api.model.interfaces.IIssues; package se.bjurr.gitchangelog.api.model; public class Tag implements ICommits, IAuthors, IIssues, Serializable { private static final long serialVersionUID = 2140208294219785889L; private final String annotation; private final List<Author> authors; private final List<Commit> commits; private final List<Issue> issues; private final List<IssueType> issueTypes; private final String name; private final String tagTime; private final Long tagTimeLong; private final boolean hasTagTime; public Tag( final String name, final String annotation, final List<Commit> commits, final List<Author> authors, final List<Issue> issues, final List<IssueType> issueTypes, final String tagTime, final Long tagTimeLong) { this.commits = commits; this.authors = authors; this.issues = issues; this.name = name; this.annotation = annotation; this.issueTypes = issueTypes; this.tagTime = tagTime; this.tagTimeLong = tagTimeLong;
this.hasTagTime = !isNullOrEmpty(tagTime);
natmoh/IfcOpenShell
src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java
// Path: src/ifcjni2/src/org/ifcopenshell/util/Utils.java // public final class Utils { // // public static String floatArrayToString(String tag, float[] arr) { // StringBuilder builder = new StringBuilder(); // if (tag != null) { // builder.append("\"" + tag + "\"" + ":"); // } // builder.append("["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // if (arr.length > 0) // builder.append(arr[arr.length - 1]); // builder.append("]"); // return builder.toString(); // } // // public static String intArrayToString(String tag, int[] arr) { // StringBuilder builder = new StringBuilder("\""); // builder.append(tag + "\"" + ":["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // builder.append(arr[arr.length - 1] + "]"); // return builder.toString(); // } // // }
import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringEscapeUtils; import org.ifcopenshell.util.Utils;
} public String getName() { return name; } public List<IfcObject> getChildren() { return children; } protected void matrixTo4_4() { float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, matrix[9], matrix[10], matrix[11], 1 }; matrix = mat; } public void addChild(IfcObject object) { children.add(object); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("\"id\":").append("\"").append(id).append("\","); builder.append("\"pid\":").append("\"").append(parent_id).append("\","); builder.append("\"ty\":").append("\"").append(type).append("\","); builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); builder.append("\"mat\":").append(
// Path: src/ifcjni2/src/org/ifcopenshell/util/Utils.java // public final class Utils { // // public static String floatArrayToString(String tag, float[] arr) { // StringBuilder builder = new StringBuilder(); // if (tag != null) { // builder.append("\"" + tag + "\"" + ":"); // } // builder.append("["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // if (arr.length > 0) // builder.append(arr[arr.length - 1]); // builder.append("]"); // return builder.toString(); // } // // public static String intArrayToString(String tag, int[] arr) { // StringBuilder builder = new StringBuilder("\""); // builder.append(tag + "\"" + ":["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // builder.append(arr[arr.length - 1] + "]"); // return builder.toString(); // } // // } // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringEscapeUtils; import org.ifcopenshell.util.Utils; } public String getName() { return name; } public List<IfcObject> getChildren() { return children; } protected void matrixTo4_4() { float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, matrix[9], matrix[10], matrix[11], 1 }; matrix = mat; } public void addChild(IfcObject object) { children.add(object); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("\"id\":").append("\"").append(id).append("\","); builder.append("\"pid\":").append("\"").append(parent_id).append("\","); builder.append("\"ty\":").append("\"").append(type).append("\","); builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); builder.append("\"mat\":").append(
Utils.floatArrayToString(null, matrix));
natmoh/IfcOpenShell
src/ifcjni2/src/org/ifcopenshell/jni/Library.java
// Path: src/ifcjni2/src/org/ifcopenshell/model/IfcGeometryObject.java // public class IfcGeometryObject extends IfcObject { // // private final IfcMesh mesh; // // public IfcGeometryObject(int id, int parent_id, IfcMesh mesh, // float[] matrix, String type, String guid, String name) { // super(id, parent_id, type, guid, name, matrix); // this.mesh = mesh; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public IfcMesh getMesh() { // return mesh; // } // // public float[] getMatrix() { // return matrix; // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(super.toString()); // builder.append(","); // builder.append("\"geo\":{").append(mesh).append("}"); // builder.append("}"); // return builder.toString(); // } // // } // // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java // public class IfcObject { // protected final int id; // protected final int parent_id; // protected final String type; // protected final String guid; // protected final String name; // protected float[] matrix; // protected List<IfcObject> children; // protected IfcObject parent; // // public IfcObject(int id, int parent_id, String type, String guid, // String name, float[] matrix) { // this.id = id; // this.parent_id = parent_id; // this.type = type; // this.guid = guid; // this.matrix = matrix; // this.name = name; // matrixTo4_4(); // children = new ArrayList<IfcObject>(); // } // // public String getType() { // return type; // } // // public String getGuid() { // return guid; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public float[] getMatrix() { // return matrix; // } // // public IfcObject getParent() { // return parent; // } // // public void setParent(IfcObject parent) { // this.parent = parent; // parent.addChild(this); // } // // public String getName() { // return name; // } // // public List<IfcObject> getChildren() { // return children; // } // // protected void matrixTo4_4() { // float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], // matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, // matrix[9], matrix[10], matrix[11], 1 }; // matrix = mat; // } // // public void addChild(IfcObject object) { // children.add(object); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append("\"id\":").append("\"").append(id).append("\","); // builder.append("\"pid\":").append("\"").append(parent_id).append("\","); // builder.append("\"ty\":").append("\"").append(type).append("\","); // builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); // builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); // builder.append("\"mat\":").append( // Utils.floatArrayToString(null, matrix)); // return builder.toString(); // } // // }
import java.io.File; import org.ifcopenshell.model.IfcGeometryObject; import org.ifcopenshell.model.IfcObject;
package org.ifcopenshell.jni; public class Library { public Library(String libPath) throws Exception{ File file = new File(libPath); if (file.exists()) { System.load(file.getAbsolutePath()); }else{ throw new Exception("Path not Found"); } } public native boolean setIfcData(byte[] data); public native boolean setIfcPath(String fname);
// Path: src/ifcjni2/src/org/ifcopenshell/model/IfcGeometryObject.java // public class IfcGeometryObject extends IfcObject { // // private final IfcMesh mesh; // // public IfcGeometryObject(int id, int parent_id, IfcMesh mesh, // float[] matrix, String type, String guid, String name) { // super(id, parent_id, type, guid, name, matrix); // this.mesh = mesh; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public IfcMesh getMesh() { // return mesh; // } // // public float[] getMatrix() { // return matrix; // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(super.toString()); // builder.append(","); // builder.append("\"geo\":{").append(mesh).append("}"); // builder.append("}"); // return builder.toString(); // } // // } // // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java // public class IfcObject { // protected final int id; // protected final int parent_id; // protected final String type; // protected final String guid; // protected final String name; // protected float[] matrix; // protected List<IfcObject> children; // protected IfcObject parent; // // public IfcObject(int id, int parent_id, String type, String guid, // String name, float[] matrix) { // this.id = id; // this.parent_id = parent_id; // this.type = type; // this.guid = guid; // this.matrix = matrix; // this.name = name; // matrixTo4_4(); // children = new ArrayList<IfcObject>(); // } // // public String getType() { // return type; // } // // public String getGuid() { // return guid; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public float[] getMatrix() { // return matrix; // } // // public IfcObject getParent() { // return parent; // } // // public void setParent(IfcObject parent) { // this.parent = parent; // parent.addChild(this); // } // // public String getName() { // return name; // } // // public List<IfcObject> getChildren() { // return children; // } // // protected void matrixTo4_4() { // float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], // matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, // matrix[9], matrix[10], matrix[11], 1 }; // matrix = mat; // } // // public void addChild(IfcObject object) { // children.add(object); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append("\"id\":").append("\"").append(id).append("\","); // builder.append("\"pid\":").append("\"").append(parent_id).append("\","); // builder.append("\"ty\":").append("\"").append(type).append("\","); // builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); // builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); // builder.append("\"mat\":").append( // Utils.floatArrayToString(null, matrix)); // return builder.toString(); // } // // } // Path: src/ifcjni2/src/org/ifcopenshell/jni/Library.java import java.io.File; import org.ifcopenshell.model.IfcGeometryObject; import org.ifcopenshell.model.IfcObject; package org.ifcopenshell.jni; public class Library { public Library(String libPath) throws Exception{ File file = new File(libPath); if (file.exists()) { System.load(file.getAbsolutePath()); }else{ throw new Exception("Path not Found"); } } public native boolean setIfcData(byte[] data); public native boolean setIfcPath(String fname);
public native IfcGeometryObject getIfcGeometry();
natmoh/IfcOpenShell
src/ifcjni2/src/org/ifcopenshell/jni/Library.java
// Path: src/ifcjni2/src/org/ifcopenshell/model/IfcGeometryObject.java // public class IfcGeometryObject extends IfcObject { // // private final IfcMesh mesh; // // public IfcGeometryObject(int id, int parent_id, IfcMesh mesh, // float[] matrix, String type, String guid, String name) { // super(id, parent_id, type, guid, name, matrix); // this.mesh = mesh; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public IfcMesh getMesh() { // return mesh; // } // // public float[] getMatrix() { // return matrix; // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(super.toString()); // builder.append(","); // builder.append("\"geo\":{").append(mesh).append("}"); // builder.append("}"); // return builder.toString(); // } // // } // // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java // public class IfcObject { // protected final int id; // protected final int parent_id; // protected final String type; // protected final String guid; // protected final String name; // protected float[] matrix; // protected List<IfcObject> children; // protected IfcObject parent; // // public IfcObject(int id, int parent_id, String type, String guid, // String name, float[] matrix) { // this.id = id; // this.parent_id = parent_id; // this.type = type; // this.guid = guid; // this.matrix = matrix; // this.name = name; // matrixTo4_4(); // children = new ArrayList<IfcObject>(); // } // // public String getType() { // return type; // } // // public String getGuid() { // return guid; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public float[] getMatrix() { // return matrix; // } // // public IfcObject getParent() { // return parent; // } // // public void setParent(IfcObject parent) { // this.parent = parent; // parent.addChild(this); // } // // public String getName() { // return name; // } // // public List<IfcObject> getChildren() { // return children; // } // // protected void matrixTo4_4() { // float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], // matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, // matrix[9], matrix[10], matrix[11], 1 }; // matrix = mat; // } // // public void addChild(IfcObject object) { // children.add(object); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append("\"id\":").append("\"").append(id).append("\","); // builder.append("\"pid\":").append("\"").append(parent_id).append("\","); // builder.append("\"ty\":").append("\"").append(type).append("\","); // builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); // builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); // builder.append("\"mat\":").append( // Utils.floatArrayToString(null, matrix)); // return builder.toString(); // } // // }
import java.io.File; import org.ifcopenshell.model.IfcGeometryObject; import org.ifcopenshell.model.IfcObject;
package org.ifcopenshell.jni; public class Library { public Library(String libPath) throws Exception{ File file = new File(libPath); if (file.exists()) { System.load(file.getAbsolutePath()); }else{ throw new Exception("Path not Found"); } } public native boolean setIfcData(byte[] data); public native boolean setIfcPath(String fname); public native IfcGeometryObject getIfcGeometry();
// Path: src/ifcjni2/src/org/ifcopenshell/model/IfcGeometryObject.java // public class IfcGeometryObject extends IfcObject { // // private final IfcMesh mesh; // // public IfcGeometryObject(int id, int parent_id, IfcMesh mesh, // float[] matrix, String type, String guid, String name) { // super(id, parent_id, type, guid, name, matrix); // this.mesh = mesh; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public IfcMesh getMesh() { // return mesh; // } // // public float[] getMatrix() { // return matrix; // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(super.toString()); // builder.append(","); // builder.append("\"geo\":{").append(mesh).append("}"); // builder.append("}"); // return builder.toString(); // } // // } // // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcObject.java // public class IfcObject { // protected final int id; // protected final int parent_id; // protected final String type; // protected final String guid; // protected final String name; // protected float[] matrix; // protected List<IfcObject> children; // protected IfcObject parent; // // public IfcObject(int id, int parent_id, String type, String guid, // String name, float[] matrix) { // this.id = id; // this.parent_id = parent_id; // this.type = type; // this.guid = guid; // this.matrix = matrix; // this.name = name; // matrixTo4_4(); // children = new ArrayList<IfcObject>(); // } // // public String getType() { // return type; // } // // public String getGuid() { // return guid; // } // // public int getId() { // return id; // } // // public int getParent_id() { // return parent_id; // } // // public float[] getMatrix() { // return matrix; // } // // public IfcObject getParent() { // return parent; // } // // public void setParent(IfcObject parent) { // this.parent = parent; // parent.addChild(this); // } // // public String getName() { // return name; // } // // public List<IfcObject> getChildren() { // return children; // } // // protected void matrixTo4_4() { // float mat[] = { matrix[0], matrix[1], matrix[2], 0, matrix[3], // matrix[4], matrix[5], 0, matrix[6], matrix[7], matrix[8], 0, // matrix[9], matrix[10], matrix[11], 1 }; // matrix = mat; // } // // public void addChild(IfcObject object) { // children.add(object); // } // // @Override // public String toString() { // StringBuilder builder = new StringBuilder(); // builder.append("\"id\":").append("\"").append(id).append("\","); // builder.append("\"pid\":").append("\"").append(parent_id).append("\","); // builder.append("\"ty\":").append("\"").append(type).append("\","); // builder.append("\"guid\":").append("\"").append(StringEscapeUtils.escapeJava(guid)).append("\","); // builder.append("\"nm\":").append("\"").append(StringEscapeUtils.escapeJava(name)).append("\","); // builder.append("\"mat\":").append( // Utils.floatArrayToString(null, matrix)); // return builder.toString(); // } // // } // Path: src/ifcjni2/src/org/ifcopenshell/jni/Library.java import java.io.File; import org.ifcopenshell.model.IfcGeometryObject; import org.ifcopenshell.model.IfcObject; package org.ifcopenshell.jni; public class Library { public Library(String libPath) throws Exception{ File file = new File(libPath); if (file.exists()) { System.load(file.getAbsolutePath()); }else{ throw new Exception("Path not Found"); } } public native boolean setIfcData(byte[] data); public native boolean setIfcPath(String fname); public native IfcGeometryObject getIfcGeometry();
public native IfcObject getObject(int id);
natmoh/IfcOpenShell
src/ifcjni2/src/org/ifcopenshell/model/IfcMesh.java
// Path: src/ifcjni2/src/org/ifcopenshell/util/Utils.java // public final class Utils { // // public static String floatArrayToString(String tag, float[] arr) { // StringBuilder builder = new StringBuilder(); // if (tag != null) { // builder.append("\"" + tag + "\"" + ":"); // } // builder.append("["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // if (arr.length > 0) // builder.append(arr[arr.length - 1]); // builder.append("]"); // return builder.toString(); // } // // public static String intArrayToString(String tag, int[] arr) { // StringBuilder builder = new StringBuilder("\""); // builder.append(tag + "\"" + ":["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // builder.append(arr[arr.length - 1] + "]"); // return builder.toString(); // } // // }
import org.ifcopenshell.util.Utils;
package org.ifcopenshell.model; public final class IfcMesh { private final int[] indices; private final float[] vertices; public IfcMesh(int[] indices, float[] vertices) { this.indices = indices; this.vertices = vertices; } public int[] getIndices() { return indices; } public float[] getVertices() { return vertices; } @Override public String toString() { StringBuilder builder = new StringBuilder();
// Path: src/ifcjni2/src/org/ifcopenshell/util/Utils.java // public final class Utils { // // public static String floatArrayToString(String tag, float[] arr) { // StringBuilder builder = new StringBuilder(); // if (tag != null) { // builder.append("\"" + tag + "\"" + ":"); // } // builder.append("["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // if (arr.length > 0) // builder.append(arr[arr.length - 1]); // builder.append("]"); // return builder.toString(); // } // // public static String intArrayToString(String tag, int[] arr) { // StringBuilder builder = new StringBuilder("\""); // builder.append(tag + "\"" + ":["); // for (int i = 0, len = arr.length; i < len - 1; i++) // builder.append(arr[i] + ","); // builder.append(arr[arr.length - 1] + "]"); // return builder.toString(); // } // // } // Path: src/ifcjni2/src/org/ifcopenshell/model/IfcMesh.java import org.ifcopenshell.util.Utils; package org.ifcopenshell.model; public final class IfcMesh { private final int[] indices; private final float[] vertices; public IfcMesh(int[] indices, float[] vertices) { this.indices = indices; this.vertices = vertices; } public int[] getIndices() { return indices; } public float[] getVertices() { return vertices; } @Override public String toString() { StringBuilder builder = new StringBuilder();
builder.append("\"mesh\":{" + Utils.intArrayToString("f", indices)