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 |
|---|---|---|---|---|---|---|
pinussilvestrus/bncl | core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclParser.java | // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
| import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level; | package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclParser extends AbstractBnclParser {
public static final String BEGINNING_GROUP = "lets create a process";
public static final String ELEMENT_BEGINNING = "with";
public static final String INDEFINITE_ARTICLE_A = "a";
public static final String INDEFINITE_ARTICLE_AN = "an";
private static final String PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD = "A valid bncl statement has to begin with \"lets create a process\"";
| // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
// Path: core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclParser.java
import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclParser extends AbstractBnclParser {
public static final String BEGINNING_GROUP = "lets create a process";
public static final String ELEMENT_BEGINNING = "with";
public static final String INDEFINITE_ARTICLE_A = "a";
public static final String INDEFINITE_ARTICLE_AN = "an";
private static final String PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD = "A valid bncl statement has to begin with \"lets create a process\"";
| private BPMNModelBuilder builder; |
pinussilvestrus/bncl | core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java | // Path: core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclParser.java
// public class BnclParser extends AbstractBnclParser {
//
// public static final String BEGINNING_GROUP = "lets create a process";
// public static final String ELEMENT_BEGINNING = "with";
// public static final String INDEFINITE_ARTICLE_A = "a";
// public static final String INDEFINITE_ARTICLE_AN = "an";
//
// private static final String PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD = "A valid bncl statement has to begin with \"lets create a process\"";
//
// private BPMNModelBuilder builder;
// private BpmnModelInstance modelInstance;
//
// // granular parsers
// private BnclEventParser eventParser;
// private BnclTaskParser taskParser;
// private BnclSequenceFlowParser sequenceFlowParser;
// private BnclGatewayParser gatewayParser;
//
// private String copy;
//
// public BnclParser() {
// builder = new BPMNModelBuilder();
// eventParser = new BnclEventParser(builder);
// taskParser = new BnclTaskParser(builder);
// sequenceFlowParser = new BnclSequenceFlowParser(builder);
// gatewayParser = new BnclGatewayParser(builder);
// logger().setLevel(Level.INFO);
// }
//
// public static boolean checkWords(List<String> withoutSpaces) {
// try {
// withoutSpaces.get(0);
// } catch (Exception e) {
// return false;
// }
//
// return true;
// }
//
// public static List<String> getWordsWithoutSpaces(String element) {
// List<String> words = new ArrayList<>();
// Collections.addAll(words, element.split(" "));
//
// // remove spaces
// List<String> withoutSpaces = new ArrayList<>();
// for (String word : words) {
// if (!word.equals(" ") && !word.equals("")) {
// withoutSpaces.add(word);
// }
// }
//
// return withoutSpaces;
// }
//
// public BpmnModelInstance parseBncl(String bnclString) throws Exception {
// if (bnclString.toLowerCase().indexOf(BEGINNING_GROUP) != 0) {
// throw new Exception(PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD);
// }
//
// copy = bnclString;
//
// try {
// copy = copy.substring(bnclString.indexOf(BEGINNING_GROUP) + BEGINNING_GROUP.length() + 1, copy.length());
// } catch (StringIndexOutOfBoundsException e) {
// throw e;
// }
//
// builder.createDefinitions();
// builder.createProcess();
// buildElements(copy);
//
// modelInstance = builder.getModel();
// return modelInstance;
// }
//
// private void buildElements(String bncl) throws Exception {
// List<String> elements = splitBnclToElements(bncl);
//
// for (String element : elements) {
// eventParser.parseEvent(element);
// taskParser.parseTask(element);
// sequenceFlowParser.parseSequenceFlow(element);
// gatewayParser.parseGateway(element);
// }
// }
//
// private List<String> splitBnclToElements(String bncl) throws Exception {
// String[] splittedElements = bncl.toLowerCase().split(ELEMENT_BEGINNING);
// List<String> elements = new ArrayList<>();
//
// for(int i = 0; i < splittedElements.length; i++) {
// String element = splittedElements[i];
//
// // remove space on first position if necessary
// if (element.startsWith(" ")) {
// element = element.substring(1);
// }
//
// // check if 'a' or 'an' comes ofter 'with' and remove it
// if (element.startsWith(INDEFINITE_ARTICLE_A)) {
// element = element.substring(INDEFINITE_ARTICLE_A.length());
// } else if (element.startsWith(INDEFINITE_ARTICLE_AN)) {
// element = element.substring(INDEFINITE_ARTICLE_AN.length());
// }
// elements.add(element);
// }
//
// return elements;
//
// }
//
// }
| import de.niklaskiefer.bnclCore.parser.BnclParser;
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger; | public void createBPMNFile(String bncl) throws Exception {
BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
File fileBPMN = new File(fileName + ".bpmn");
File fileXML = new File(fileName + ".xml");
Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
logger.info("Successfully save bpmn file to " + fileName);
}
public void createBPMNFileFromFile(String file) throws Exception {
String bncl = getStringFromFileReaderAndClose(file);
createBPMNFile(bncl);
}
public String convertBnclToXML(String bncl) throws Exception {
BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
String xmlString = Bpmn.convertToString(bpmnModelInstance);
logger.info("Successfully convert bncl statement to xml");
return xmlString;
}
public String convertBnclFileToXML(String fileName) throws Exception {
String bncl = getStringFromFileReaderAndClose(fileName);
return convertBnclToXML(bncl);
}
private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception { | // Path: core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclParser.java
// public class BnclParser extends AbstractBnclParser {
//
// public static final String BEGINNING_GROUP = "lets create a process";
// public static final String ELEMENT_BEGINNING = "with";
// public static final String INDEFINITE_ARTICLE_A = "a";
// public static final String INDEFINITE_ARTICLE_AN = "an";
//
// private static final String PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD = "A valid bncl statement has to begin with \"lets create a process\"";
//
// private BPMNModelBuilder builder;
// private BpmnModelInstance modelInstance;
//
// // granular parsers
// private BnclEventParser eventParser;
// private BnclTaskParser taskParser;
// private BnclSequenceFlowParser sequenceFlowParser;
// private BnclGatewayParser gatewayParser;
//
// private String copy;
//
// public BnclParser() {
// builder = new BPMNModelBuilder();
// eventParser = new BnclEventParser(builder);
// taskParser = new BnclTaskParser(builder);
// sequenceFlowParser = new BnclSequenceFlowParser(builder);
// gatewayParser = new BnclGatewayParser(builder);
// logger().setLevel(Level.INFO);
// }
//
// public static boolean checkWords(List<String> withoutSpaces) {
// try {
// withoutSpaces.get(0);
// } catch (Exception e) {
// return false;
// }
//
// return true;
// }
//
// public static List<String> getWordsWithoutSpaces(String element) {
// List<String> words = new ArrayList<>();
// Collections.addAll(words, element.split(" "));
//
// // remove spaces
// List<String> withoutSpaces = new ArrayList<>();
// for (String word : words) {
// if (!word.equals(" ") && !word.equals("")) {
// withoutSpaces.add(word);
// }
// }
//
// return withoutSpaces;
// }
//
// public BpmnModelInstance parseBncl(String bnclString) throws Exception {
// if (bnclString.toLowerCase().indexOf(BEGINNING_GROUP) != 0) {
// throw new Exception(PARSING_FAILS_MESSAGE_BEGINNING_KEYWORD);
// }
//
// copy = bnclString;
//
// try {
// copy = copy.substring(bnclString.indexOf(BEGINNING_GROUP) + BEGINNING_GROUP.length() + 1, copy.length());
// } catch (StringIndexOutOfBoundsException e) {
// throw e;
// }
//
// builder.createDefinitions();
// builder.createProcess();
// buildElements(copy);
//
// modelInstance = builder.getModel();
// return modelInstance;
// }
//
// private void buildElements(String bncl) throws Exception {
// List<String> elements = splitBnclToElements(bncl);
//
// for (String element : elements) {
// eventParser.parseEvent(element);
// taskParser.parseTask(element);
// sequenceFlowParser.parseSequenceFlow(element);
// gatewayParser.parseGateway(element);
// }
// }
//
// private List<String> splitBnclToElements(String bncl) throws Exception {
// String[] splittedElements = bncl.toLowerCase().split(ELEMENT_BEGINNING);
// List<String> elements = new ArrayList<>();
//
// for(int i = 0; i < splittedElements.length; i++) {
// String element = splittedElements[i];
//
// // remove space on first position if necessary
// if (element.startsWith(" ")) {
// element = element.substring(1);
// }
//
// // check if 'a' or 'an' comes ofter 'with' and remove it
// if (element.startsWith(INDEFINITE_ARTICLE_A)) {
// element = element.substring(INDEFINITE_ARTICLE_A.length());
// } else if (element.startsWith(INDEFINITE_ARTICLE_AN)) {
// element = element.substring(INDEFINITE_ARTICLE_AN.length());
// }
// elements.add(element);
// }
//
// return elements;
//
// }
//
// }
// Path: core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java
import de.niklaskiefer.bnclCore.parser.BnclParser;
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger;
public void createBPMNFile(String bncl) throws Exception {
BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
File fileBPMN = new File(fileName + ".bpmn");
File fileXML = new File(fileName + ".xml");
Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
logger.info("Successfully save bpmn file to " + fileName);
}
public void createBPMNFileFromFile(String file) throws Exception {
String bncl = getStringFromFileReaderAndClose(file);
createBPMNFile(bncl);
}
public String convertBnclToXML(String bncl) throws Exception {
BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
String xmlString = Bpmn.convertToString(bpmnModelInstance);
logger.info("Successfully convert bncl statement to xml");
return xmlString;
}
public String convertBnclFileToXML(String fileName) throws Exception {
String bncl = getStringFromFileReaderAndClose(fileName);
return convertBnclToXML(bncl);
}
private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception { | BnclParser parser = new BnclParser(); |
pinussilvestrus/bncl | core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclSequenceFlowParser.java | // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
| import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
import java.util.List; | package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclSequenceFlowParser extends AbstractBnclParser {
public static final String SEQUENCE_FLOW_KEYWORD = "sequenceflow";
// attributes
public static final String COMES_FROM = "comesfrom";
public static final String GOES_TO = "goesto";
| // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
// Path: core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclSequenceFlowParser.java
import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
import java.util.List;
package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclSequenceFlowParser extends AbstractBnclParser {
public static final String SEQUENCE_FLOW_KEYWORD = "sequenceflow";
// attributes
public static final String COMES_FROM = "comesfrom";
public static final String GOES_TO = "goesto";
| private BPMNModelBuilder builder; |
pinussilvestrus/bncl | web/src/main/java/de/niklaskiefer/bnclWeb/ApiController.java | // Path: core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java
// public class BnclToXmlWriter {
//
// private String fileName;
// private static final Logger logger = Logger.getLogger(BnclToXmlWriter.class.getName());
//
// public BnclToXmlWriter() {
// logger.setLevel(Level.INFO);
// fileName = "test_process";
// }
//
// public void createBPMNFile(String bncl) throws Exception {
// BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
//
// File fileBPMN = new File(fileName + ".bpmn");
// File fileXML = new File(fileName + ".xml");
// Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
// Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
//
// logger.info("Successfully save bpmn file to " + fileName);
// }
//
// public void createBPMNFileFromFile(String file) throws Exception {
// String bncl = getStringFromFileReaderAndClose(file);
// createBPMNFile(bncl);
// }
//
// public String convertBnclToXML(String bncl) throws Exception {
// BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
// String xmlString = Bpmn.convertToString(bpmnModelInstance);
//
// logger.info("Successfully convert bncl statement to xml");
// return xmlString;
// }
//
// public String convertBnclFileToXML(String fileName) throws Exception {
// String bncl = getStringFromFileReaderAndClose(fileName);
// return convertBnclToXML(bncl);
// }
//
// private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception {
// BnclParser parser = new BnclParser();
// BpmnModelInstance modelInstance;
// modelInstance = parser.parseBncl(bncl);
// return modelInstance;
// }
//
// private String getStringFromFileReaderAndClose(String fileName) throws Exception {
// StringBuilder result = new StringBuilder();
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new FileReader(fileName));
// while (reader.ready()) {
// result.append(reader.readLine());
// }
// } finally {
// if (reader != null) {
// reader.close();
// }
// }
//
// return result.toString();
// }
// }
| import de.niklaskiefer.bnclCore.BnclToXmlWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; | package de.niklaskiefer.bnclWeb;
@RestController
public class ApiController {
private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);
@RequestMapping(value = "/api/convert", method = RequestMethod.POST)
public String convert(@RequestBody String bncl) throws Exception {
return convertBnclToXML(bncl);
}
private String convertBnclToXML(String bncl) throws Exception { | // Path: core/src/main/java/de/niklaskiefer/bnclCore/BnclToXmlWriter.java
// public class BnclToXmlWriter {
//
// private String fileName;
// private static final Logger logger = Logger.getLogger(BnclToXmlWriter.class.getName());
//
// public BnclToXmlWriter() {
// logger.setLevel(Level.INFO);
// fileName = "test_process";
// }
//
// public void createBPMNFile(String bncl) throws Exception {
// BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
//
// File fileBPMN = new File(fileName + ".bpmn");
// File fileXML = new File(fileName + ".xml");
// Bpmn.writeModelToFile(fileBPMN, bpmnModelInstance);
// Bpmn.writeModelToFile(fileXML, bpmnModelInstance);
//
// logger.info("Successfully save bpmn file to " + fileName);
// }
//
// public void createBPMNFileFromFile(String file) throws Exception {
// String bncl = getStringFromFileReaderAndClose(file);
// createBPMNFile(bncl);
// }
//
// public String convertBnclToXML(String bncl) throws Exception {
// BpmnModelInstance bpmnModelInstance = createBPMModelInstance(bncl);
// String xmlString = Bpmn.convertToString(bpmnModelInstance);
//
// logger.info("Successfully convert bncl statement to xml");
// return xmlString;
// }
//
// public String convertBnclFileToXML(String fileName) throws Exception {
// String bncl = getStringFromFileReaderAndClose(fileName);
// return convertBnclToXML(bncl);
// }
//
// private BpmnModelInstance createBPMModelInstance(String bncl) throws Exception {
// BnclParser parser = new BnclParser();
// BpmnModelInstance modelInstance;
// modelInstance = parser.parseBncl(bncl);
// return modelInstance;
// }
//
// private String getStringFromFileReaderAndClose(String fileName) throws Exception {
// StringBuilder result = new StringBuilder();
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new FileReader(fileName));
// while (reader.ready()) {
// result.append(reader.readLine());
// }
// } finally {
// if (reader != null) {
// reader.close();
// }
// }
//
// return result.toString();
// }
// }
// Path: web/src/main/java/de/niklaskiefer/bnclWeb/ApiController.java
import de.niklaskiefer.bnclCore.BnclToXmlWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
package de.niklaskiefer.bnclWeb;
@RestController
public class ApiController {
private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);
@RequestMapping(value = "/api/convert", method = RequestMethod.POST)
public String convert(@RequestBody String bncl) throws Exception {
return convertBnclToXML(bncl);
}
private String convertBnclToXML(String bncl) throws Exception { | BnclToXmlWriter writer = new BnclToXmlWriter(); |
pinussilvestrus/bncl | core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclGatewayParser.java | // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
| import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.instance.EventBasedGateway;
import org.camunda.bpm.model.bpmn.instance.ExclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.Gateway;
import org.camunda.bpm.model.bpmn.instance.InclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.ParallelGateway;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; | package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclGatewayParser extends BnclElementParser {
private List<GatewayType> gatewayTypes = new ArrayList<>();
| // Path: core/src/main/java/de/niklaskiefer/bnclCore/BPMNModelBuilder.java
// public class BPMNModelBuilder {
//
// private static final String CAMUNDA_NAMESPACE = "http://camunda.org/examples";
//
// private BpmnModelInstance bpmnModelInstance;
// private Process process;
// private List<BpmnModelElementInstance> elements = new ArrayList<>();
//
// public BPMNModelBuilder() {
// String id = "pid-" + UUID.randomUUID().toString();
// bpmnModelInstance = Bpmn.createExecutableProcess(id)
// .startEvent()
// .userTask()
// .endEvent()
// .done();
// }
//
//
// public Process createProcess() {
// String id = "pid-" + UUID.randomUUID().toString();
// process = createElement(bpmnModelInstance.getDefinitions(), id, Process.class);
// return process;
// }
//
// public void createDefinitions() {
// Definitions definitions = bpmnModelInstance.newInstance(Definitions.class);
// definitions.setTargetNamespace(CAMUNDA_NAMESPACE);
// bpmnModelInstance.setDefinitions(definitions);
// }
//
// public <T extends EventDefinition> T createEventDefinition(BpmnModelElementInstance parentElement, Process process, Class<T> eventDefinitionClass) {
// T element = bpmnModelInstance.newInstance(eventDefinitionClass);
// parentElement.addChildElement(element);
// elements.add(element);
// return element;
// }
//
// public SequenceFlow createSequenceFlow(Process process, String idFrom, String idTo) {
// FlowNode from = null;
// FlowNode to = null;
// for (BpmnModelElementInstance element : elements) {
// if (element.getAttributeValue("id").equals(idFrom)) {
// from = (FlowNode) element;
// } else if (element.getAttributeValue("id").equals(idTo)) {
// to = (FlowNode) element;
// }
// }
//
// if (from != null && to != null) {
// return createSequenceFlow(process, from, to);
// }
//
// return null;
// }
//
// public Gateway createGateway(Process process, Map<String, String> attributes, Class type) {
// return (Gateway) createElement(process, type, attributes);
// }
//
// public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
// String identifier = from.getId() + "-" + to.getId();
// SequenceFlow sequenceFlow = createElement(process, identifier, SequenceFlow.class);
// process.addChildElement(sequenceFlow);
// sequenceFlow.setSource(from);
// from.getOutgoing().add(sequenceFlow);
// sequenceFlow.setTarget(to);
// to.getIncoming().add(sequenceFlow);
// return sequenceFlow;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, Class<T> elementClass, Map<String, String> attributes) {
// T element = createElement(parentElement, "dump", elementClass);
// for (Map.Entry<String, String> s : attributes.entrySet()) {
// element.setAttributeValue(s.getKey(), s.getValue(), false);
// }
// return element;
// }
//
// public <T extends BpmnModelElementInstance> T createElement(BpmnModelElementInstance parentElement, String id, Class<T> elementClass) {
// T element = bpmnModelInstance.newInstance(elementClass);
// element.setAttributeValue("id", id, true);
// parentElement.addChildElement(element);
// elements.add(element); // save all elements for later referencing
// return element;
// }
//
// public BpmnModelInstance getModel() {
// return bpmnModelInstance;
// }
//
//
// public Process getProcess() {
// return process;
// }
// }
// Path: core/src/main/java/de/niklaskiefer/bnclCore/parser/BnclGatewayParser.java
import de.niklaskiefer.bnclCore.BPMNModelBuilder;
import org.camunda.bpm.model.bpmn.instance.EventBasedGateway;
import org.camunda.bpm.model.bpmn.instance.ExclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.Gateway;
import org.camunda.bpm.model.bpmn.instance.InclusiveGateway;
import org.camunda.bpm.model.bpmn.instance.ParallelGateway;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
package de.niklaskiefer.bnclCore.parser;
/**
* @author Niklas Kiefer
*/
public class BnclGatewayParser extends BnclElementParser {
private List<GatewayType> gatewayTypes = new ArrayList<>();
| public BnclGatewayParser(BPMNModelBuilder builder) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/PostService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class PostService {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/PostService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class PostService {
@Autowired | private PostRepository postRepository; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/PostService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class PostService {
@Autowired
private PostRepository postRepository;
@Autowired
private TagService tagService;
| // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/PostService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class PostService {
@Autowired
private PostRepository postRepository;
@Autowired
private TagService tagService;
| public Page<Post> getPosts(Integer page, Integer pageSize) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/PostService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; | public Post getOpenPostById(Long id) {
if (id == null) {
throw new IllegalArgumentException("id is null");
}
return postRepository.findOpenPostById(id);
}
public Post getByTitle(String title) {
if (Strings.isNullOrEmpty(title)) {
throw new IllegalArgumentException("title is null or empty");
}
return postRepository.findByTitle(title);
}
public Post getByPermalink(String permalink) {
if (Strings.isNullOrEmpty(permalink)) {
throw new IllegalArgumentException("permalink is null or empty");
}
return postRepository.findByPermalink(permalink);
}
public Post createPost(Post post) {
if (post == null) {
throw new IllegalArgumentException("post is null");
}
if (StringUtils.isEmpty(post.getTitle()) || StringUtils.isEmpty(post.getContent())) {
throw new IllegalArgumentException("post is empty");
}
//默认开放状态
if (post.getStatus() == null) { | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/PostService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public Post getOpenPostById(Long id) {
if (id == null) {
throw new IllegalArgumentException("id is null");
}
return postRepository.findOpenPostById(id);
}
public Post getByTitle(String title) {
if (Strings.isNullOrEmpty(title)) {
throw new IllegalArgumentException("title is null or empty");
}
return postRepository.findByTitle(title);
}
public Post getByPermalink(String permalink) {
if (Strings.isNullOrEmpty(permalink)) {
throw new IllegalArgumentException("permalink is null or empty");
}
return postRepository.findByPermalink(permalink);
}
public Post createPost(Post post) {
if (post == null) {
throw new IllegalArgumentException("post is null");
}
if (StringUtils.isEmpty(post.getTitle()) || StringUtils.isEmpty(post.getContent())) {
throw new IllegalArgumentException("post is empty");
}
//默认开放状态
if (post.getStatus() == null) { | post.setStatus(PostStatusEnum.OPEN.getValue()); |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/PostService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; | }
post.setTags(getSavedTags(post.getTags()));
return postRepository.save(post);
}
public Post updatePost(Post post) {
if (post == null) {
throw new IllegalArgumentException("post is null");
}
if (post.getId() == null || StringUtils.isEmpty(post.getTitle()) || StringUtils.isEmpty(post.getContent())) {
throw new IllegalArgumentException("post is empty");
}
post.setTags(getSavedTags(post.getTags()));
return postRepository.save(post);
}
public Post close(Post post) {
if (post == null || post.getId() == null) {
throw new IllegalArgumentException("post is null");
}
Post target = getById(post.getId());
target.setStatus(PostStatusEnum.CLOSED.getValue());
return postRepository.save(target);
}
/**
* 查询并补全已存在的tag属性
* @param tags
* @return
*/ | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/enums/PostStatusEnum.java
// public enum PostStatusEnum {
//
// CLOSED(-1 ,"关闭"),
// OPEN(1, "开放"),
// DRAFT(2, "草稿");
//
// @Getter
// private Integer value;
// @Getter
// private String desc;
//
// PostStatusEnum(Integer value, String desc) {
// this.value = value;
// this.desc = desc;
// }
//
// public static String getDescByValue(Integer value) {
// for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) {
// if (postStatusEnum.getValue().equals(value)) {
// return postStatusEnum.getDesc();
// }
// }
// return "";
// }
//
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long> {
// Post findByTitle(String title);
//
// Post findByPermalink(String permalink);
//
// @Query("from Post post where post.status = '1' and post.id = ?1")
// Post findOpenPostById(Long id);
//
// Page<Post> findAll(Pageable pageable);
//
// @Query("from Post post where post.status = '1' order by post.createTime desc")
// Page<Post> findAllOpenPosts(Pageable pageable);
//
// @Query("from Post post where post.status = '1' and post.title like ?1% order by post.createTime desc")
// Page<Post> findOpenPostsByKeyword(String keyword, Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/PostService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.model.enums.PostStatusEnum;
import co.lilpilot.blog.repository.PostRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
}
post.setTags(getSavedTags(post.getTags()));
return postRepository.save(post);
}
public Post updatePost(Post post) {
if (post == null) {
throw new IllegalArgumentException("post is null");
}
if (post.getId() == null || StringUtils.isEmpty(post.getTitle()) || StringUtils.isEmpty(post.getContent())) {
throw new IllegalArgumentException("post is empty");
}
post.setTags(getSavedTags(post.getTags()));
return postRepository.save(post);
}
public Post close(Post post) {
if (post == null || post.getId() == null) {
throw new IllegalArgumentException("post is null");
}
Post target = getById(post.getId());
target.setStatus(PostStatusEnum.CLOSED.getValue());
return postRepository.save(target);
}
/**
* 查询并补全已存在的tag属性
* @param tags
* @return
*/ | private List<Tag> getSavedTags(List<Tag> tags) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/TagService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/3.
*/
@Service
public class TagService {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/3.
*/
@Service
public class TagService {
@Autowired | private TagRepository tagRepository; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/TagService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/3.
*/
@Service
public class TagService {
@Autowired
private TagRepository tagRepository;
@Autowired
private PostService postService;
| // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/3.
*/
@Service
public class TagService {
@Autowired
private TagRepository tagRepository;
@Autowired
private PostService postService;
| public List<Tag> getAllTags() { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/TagService.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List; |
public List<Tag> getAllTags() {
return tagRepository.findAll();
}
public Tag getById(Long id) {
if (id == null) {
throw new IllegalArgumentException("id is null");
}
return tagRepository.findOne(id);
}
public Tag getByName(String name) {
if (Strings.isNullOrEmpty(name)) {
throw new IllegalArgumentException("name is null");
}
return tagRepository.findByName(name);
}
public Tag saveOrUpdate(Tag tag) {
if (tag == null) {
throw new IllegalArgumentException("tag is null");
}
return tagRepository.save(tag);
}
public Tag delete(Tag tag) {
if (tag == null || tag.getId() == null) {
throw new IllegalArgumentException("tag is null");
} | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/TagRepository.java
// public interface TagRepository extends JpaRepository<Tag, Long> {
// Tag findByName(String name);
//
// Page<Tag> findAll(Pageable pageable);
// }
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.repository.TagRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
public List<Tag> getAllTags() {
return tagRepository.findAll();
}
public Tag getById(Long id) {
if (id == null) {
throw new IllegalArgumentException("id is null");
}
return tagRepository.findOne(id);
}
public Tag getByName(String name) {
if (Strings.isNullOrEmpty(name)) {
throw new IllegalArgumentException("name is null");
}
return tagRepository.findByName(name);
}
public Tag saveOrUpdate(Tag tag) {
if (tag == null) {
throw new IllegalArgumentException("tag is null");
}
return tagRepository.save(tag);
}
public Tag delete(Tag tag) {
if (tag == null || tag.getId() == null) {
throw new IllegalArgumentException("tag is null");
} | for(Post post : tag.getPosts()) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/UserService.java | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/UserRepository.java
// @Repository
// public interface UserRepository extends JpaRepository<User, Long> {
// User findByUsername(String username);
// }
| import co.lilpilot.blog.model.User;
import co.lilpilot.blog.repository.UserRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class UserService {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/UserRepository.java
// @Repository
// public interface UserRepository extends JpaRepository<User, Long> {
// User findByUsername(String username);
// }
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
import co.lilpilot.blog.model.User;
import co.lilpilot.blog.repository.UserRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class UserService {
@Autowired | private UserRepository userRepository; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/service/UserService.java | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/UserRepository.java
// @Repository
// public interface UserRepository extends JpaRepository<User, Long> {
// User findByUsername(String username);
// }
| import co.lilpilot.blog.model.User;
import co.lilpilot.blog.repository.UserRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; | package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
| // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/repository/UserRepository.java
// @Repository
// public interface UserRepository extends JpaRepository<User, Long> {
// User findByUsername(String username);
// }
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
import co.lilpilot.blog.model.User;
import co.lilpilot.blog.repository.UserRepository;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
package co.lilpilot.blog.service;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class UserService {
@Autowired
private UserRepository userRepository;
| public User createUser(String username, String password) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/config/SecurityConfig.java | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
| import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
// Path: src/main/java/co/lilpilot/blog/config/SecurityConfig.java
import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired | private CustomUserDetailsService userDetailsService; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/config/SecurityConfig.java | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
| import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomUserDetailsService userDetailsService;
@Autowired | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
// Path: src/main/java/co/lilpilot/blog/config/SecurityConfig.java
import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomUserDetailsService userDetailsService;
@Autowired | private UnauthorizedHandler unauthorizedHandler; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/config/SecurityConfig.java | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
| import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomUserDetailsService userDetailsService;
@Autowired
private UnauthorizedHandler unauthorizedHandler;
@Autowired | // Path: src/main/java/co/lilpilot/blog/security/AuthenticationTokenFilter.java
// @Component
// public class AuthenticationTokenFilter extends OncePerRequestFilter {
//
// private String tokenHeader = "Authorization";
//
// @Autowired
// private JwtTokenUtil jwtTokenUtil;
// @Autowired
// private CustomUserDetailsService userDetailsService;
//
// @Override
// protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
// String authToken = httpServletRequest.getHeader(this.tokenHeader);
// // authToken.startsWith("Bearer ")
// // String authToken = header.substring(7);
// String username = jwtTokenUtil.getUsernameFromToken(authToken);
//
// // System.out.println("checking authentication for user " + username);
//
// if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
//
// // It is not compelling necessary to load the use details from the database. You could also store the information
// // in the token and read it from it. It's up to you ;)
// UserDetails userDetails = userDetailsService.loadUserByUsername(username);
//
// // For simple validation it is completely sufficient to just check the token integrity. You don't have to call
// // the database compellingly. Again it's up to you ;)
// if (jwtTokenUtil.validateToken(authToken, userDetails)) {
// UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
// System.out.println("authenticated user " + username + ", setting security context");
// SecurityContextHolder.getContext().setAuthentication(authentication);
// }
// }
//
// filterChain.doFilter(httpServletRequest, httpServletResponse);
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
// @Service
// public class CustomUserDetailsService implements UserDetailsService {
//
// @Autowired
// private UserService userService;
//
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// User user = userService.getByUsername(username);
// if (user == null) {
// throw new UsernameNotFoundException("username not found:" + username);
// }
// /*
// * 例如:
// * 在使用hasRole('ADMIN')时
// * spring security会加上ROLE_即ROLE_ADMIN去校对 所以手动加上ROLE_
// * */
// return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPasswordHashed(), AuthorityUtils.createAuthorityList("ROLE_" + user.getRole()));
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/security/UnauthorizedHandler.java
// @Component
// public class UnauthorizedHandler implements AuthenticationEntryPoint {
// @Override
// public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
// // This is invoked when user tries to access a secured REST resource without supplying any credentials
// // We should just send a 401 Unauthorized response because there is no 'login page' to redirect to
// httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
// }
// }
// Path: src/main/java/co/lilpilot/blog/config/SecurityConfig.java
import co.lilpilot.blog.security.AuthenticationTokenFilter;
import co.lilpilot.blog.security.CustomUserDetailsService;
import co.lilpilot.blog.security.UnauthorizedHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
package co.lilpilot.blog.config;
/**
* Created by lilpilot on 2017/5/1.
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private CustomUserDetailsService userDetailsService;
@Autowired
private UnauthorizedHandler unauthorizedHandler;
@Autowired | private AuthenticationTokenFilter authenticationTokenFilter; |
xuzhenyang/ZeroCola | src/test/java/co/lilpilot/blog/service/PostServiceTest.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; | package co.lilpilot.blog.service;
/**
* PostService Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>05/07/2017</pre>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class PostServiceTest {
@Autowired
private PostService postService;
@Autowired
private TagService tagService;
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
| // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
// Path: src/test/java/co/lilpilot/blog/service/PostServiceTest.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
package co.lilpilot.blog.service;
/**
* PostService Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>05/07/2017</pre>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class PostServiceTest {
@Autowired
private PostService postService;
@Autowired
private TagService tagService;
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
| public static Post createPost(String title) { |
xuzhenyang/ZeroCola | src/test/java/co/lilpilot/blog/service/PostServiceTest.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; | public void before() throws Exception {
}
@After
public void after() throws Exception {
}
public static Post createPost(String title) {
Post post = new Post();
post.setTitle(title);
return post;
}
public static Post createPost(String title, String content) {
Post post = new Post();
post.setTitle(title);
post.setContent(content);
return post;
}
public static Post createPost(String title, String content, Integer status) {
Post post = new Post();
post.setTitle(title);
post.setContent(content);
post.setStatus(status);
return post;
}
| // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
// Path: src/test/java/co/lilpilot/blog/service/PostServiceTest.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
public static Post createPost(String title) {
Post post = new Post();
post.setTitle(title);
return post;
}
public static Post createPost(String title, String content) {
Post post = new Post();
post.setTitle(title);
post.setContent(content);
return post;
}
public static Post createPost(String title, String content, Integer status) {
Post post = new Post();
post.setTitle(title);
post.setContent(content);
post.setStatus(status);
return post;
}
| public static Post createPost(String title, String content, Tag tag) { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
//
// @Autowired
// private UserRepository userRepository;
//
// public User createUser(String username, String password) {
// if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
// throw new IllegalArgumentException("username or password is empty");
// }
// User user = new User();
// user.setUsername(username);
// user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
// user.setRole("ADMIN");
// return saveOrUpdate(user);
// }
//
// public User saveOrUpdate(User user) {
// if (user == null) {
// throw new IllegalArgumentException("user is null");
// }
// return userRepository.save(user);
// }
//
// public User getByUsername(String username) {
// if (Strings.isNullOrEmpty(username)) {
// throw new IllegalArgumentException("username is empty");
// }
// return userRepository.findByUsername(username);
// }
// }
| import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; | package co.lilpilot.blog.security;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class CustomUserDetailsService implements UserDetailsService {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
//
// @Autowired
// private UserRepository userRepository;
//
// public User createUser(String username, String password) {
// if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
// throw new IllegalArgumentException("username or password is empty");
// }
// User user = new User();
// user.setUsername(username);
// user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
// user.setRole("ADMIN");
// return saveOrUpdate(user);
// }
//
// public User saveOrUpdate(User user) {
// if (user == null) {
// throw new IllegalArgumentException("user is null");
// }
// return userRepository.save(user);
// }
//
// public User getByUsername(String username) {
// if (Strings.isNullOrEmpty(username)) {
// throw new IllegalArgumentException("username is empty");
// }
// return userRepository.findByUsername(username);
// }
// }
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
package co.lilpilot.blog.security;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class CustomUserDetailsService implements UserDetailsService {
@Autowired | private UserService userService; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
//
// @Autowired
// private UserRepository userRepository;
//
// public User createUser(String username, String password) {
// if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
// throw new IllegalArgumentException("username or password is empty");
// }
// User user = new User();
// user.setUsername(username);
// user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
// user.setRole("ADMIN");
// return saveOrUpdate(user);
// }
//
// public User saveOrUpdate(User user) {
// if (user == null) {
// throw new IllegalArgumentException("user is null");
// }
// return userRepository.save(user);
// }
//
// public User getByUsername(String username) {
// if (Strings.isNullOrEmpty(username)) {
// throw new IllegalArgumentException("username is empty");
// }
// return userRepository.findByUsername(username);
// }
// }
| import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service; | package co.lilpilot.blog.security;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class CustomUserDetailsService implements UserDetailsService {
@Autowired
private UserService userService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | // Path: src/main/java/co/lilpilot/blog/model/User.java
// @Data
// @Entity
// public class User extends BaseModel {
// @ApiModelProperty(value = "用户名")
// private String username;
// @ApiModelProperty(value = "密码(md5)")
// private String passwordHashed;
// @ApiModelProperty(value = "角色")
// private String role;
// }
//
// Path: src/main/java/co/lilpilot/blog/service/UserService.java
// @Service
// public class UserService {
//
// @Autowired
// private UserRepository userRepository;
//
// public User createUser(String username, String password) {
// if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
// throw new IllegalArgumentException("username or password is empty");
// }
// User user = new User();
// user.setUsername(username);
// user.setPasswordHashed(new BCryptPasswordEncoder().encode(password));
// user.setRole("ADMIN");
// return saveOrUpdate(user);
// }
//
// public User saveOrUpdate(User user) {
// if (user == null) {
// throw new IllegalArgumentException("user is null");
// }
// return userRepository.save(user);
// }
//
// public User getByUsername(String username) {
// if (Strings.isNullOrEmpty(username)) {
// throw new IllegalArgumentException("username is empty");
// }
// return userRepository.findByUsername(username);
// }
// }
// Path: src/main/java/co/lilpilot/blog/security/CustomUserDetailsService.java
import co.lilpilot.blog.model.User;
import co.lilpilot.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
package co.lilpilot.blog.security;
/**
* Created by lilpilot on 2017/5/2.
*/
@Service
public class CustomUserDetailsService implements UserDetailsService {
@Autowired
private UserService userService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | User user = userService.getByUsername(username); |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/model/vo/PostListVO.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
| import co.lilpilot.blog.model.Tag;
import lombok.Data;
import java.util.Date;
import java.util.List; | package co.lilpilot.blog.model.vo;
/**
* Created by lilpilot on 2017/7/5.
*/
@Data
public class PostListVO {
private Long id;
private Date createTime;
private Date updateTime;
private String title;
private String permalink;
private Integer status;
private String statusDesc;
| // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
// Path: src/main/java/co/lilpilot/blog/model/vo/PostListVO.java
import co.lilpilot.blog.model.Tag;
import lombok.Data;
import java.util.Date;
import java.util.List;
package co.lilpilot.blog.model.vo;
/**
* Created by lilpilot on 2017/7/5.
*/
@Data
public class PostListVO {
private Long id;
private Date createTime;
private Date updateTime;
private String title;
private String permalink;
private Integer status;
private String statusDesc;
| private List<Tag> tags; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/AdminTagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/AdminTagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired | private TagService tagService; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/AdminTagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired
private TagService tagService;
@PostMapping("/tags")
@ApiOperation(value = "创建新标签") | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/AdminTagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired
private TagService tagService;
@PostMapping("/tags")
@ApiOperation(value = "创建新标签") | @ApiImplicitParam(name = "tag", value = "标签类", required = true, dataType = "Tag", paramType = "body") |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/AdminTagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired
private TagService tagService;
@PostMapping("/tags")
@ApiOperation(value = "创建新标签")
@ApiImplicitParam(name = "tag", value = "标签类", required = true, dataType = "Tag", paramType = "body") | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/AdminTagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/25.
*/
@RestController
@RequestMapping("/api/v1/admin")
@Slf4j
public class AdminTagController {
@Autowired
private TagService tagService;
@PostMapping("/tags")
@ApiOperation(value = "创建新标签")
@ApiImplicitParam(name = "tag", value = "标签类", required = true, dataType = "Tag", paramType = "body") | public Result<Tag> createTag(@RequestBody Tag tag) { |
xuzhenyang/ZeroCola | src/test/java/co/lilpilot/blog/service/TagServiceTest.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; | package co.lilpilot.blog.service;
/**
* TagService Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>05/07/2017</pre>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class TagServiceTest {
@Autowired
private TagService tagService;
@Autowired
private PostService postService;
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
| // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
// Path: src/test/java/co/lilpilot/blog/service/TagServiceTest.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
package co.lilpilot.blog.service;
/**
* TagService Tester.
*
* @author <Authors name>
* @version 1.0
* @since <pre>05/07/2017</pre>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class TagServiceTest {
@Autowired
private TagService tagService;
@Autowired
private PostService postService;
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
| public static Tag createTag(String name) { |
xuzhenyang/ZeroCola | src/test/java/co/lilpilot/blog/service/TagServiceTest.java | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
| import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; | /**
* Method: getAllTags()
*/
@Test
public void testGetAllTags() throws Exception {
Assert.assertEquals(0, tagService.getAllTags().size());
Tag tag_1 = createTag("test1");
Tag tag_2 = createTag("test2");
tagService.saveOrUpdate(tag_1);
tagService.saveOrUpdate(tag_2);
Assert.assertEquals(2, tagService.getAllTags().size());
}
/**
* Method: getByName(String name)
*/
@Test
public void testGetByName() throws Exception {
Tag tag = createTag("test");
tagService.saveOrUpdate(tag);
Tag result = tagService.getByName("test");
Assert.assertNotNull(result);
}
/*
* test the link of post and test
* */
@Test
public void testLink() {
Tag tag = createTag("link_test"); | // Path: src/main/java/co/lilpilot/blog/model/Post.java
// @Entity
// @Data
// @Table(name = "posts")
// public class Post extends BaseModel {
//
// @ApiModelProperty(value = "文章标题")
// @Column(nullable = false)
// private String title;
//
// @ApiModelProperty(value = "文章内容")
// @Lob
// @Column(length = 16777216)
// private String content;
//
// @ApiModelProperty(value = "永久链接")
// private String permalink;
//
// @ApiModelProperty(value = "状态 0关闭 1开放 2草稿")
// private Integer status;
//
// @ApiModelProperty(value = "标签列表")
// //FetchType.EAGER : 默认LAZY会使用代理通过get()去获取 但在session关闭后查询不到
// @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
// @JoinTable(joinColumns = {@JoinColumn(name = "post_id")},
// inverseJoinColumns = {@JoinColumn(name = "tag_id")})
// private List<Tag> tags = new ArrayList<>();
//
// //维护多对多关系两端的状态
// //提供对子实体增加/删除的帮助类是很好的实践
// public void addTag(Tag tag) {
// tags.add(tag);
// tag.getPosts().add(this);
// }
//
// public void removeTag(Tag tag) {
// tags.remove(tag);
// tag.getPosts().remove(this);
// }
//
// //toString不包含tags 避免死循环
// @Override
// public String toString() {
// return "Post{" +
// "title='" + title + '\'' +
// ", content='" + content + '\'' +
// ", permalink='" + permalink + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
// Path: src/test/java/co/lilpilot/blog/service/TagServiceTest.java
import co.lilpilot.blog.model.Post;
import co.lilpilot.blog.model.Tag;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
* Method: getAllTags()
*/
@Test
public void testGetAllTags() throws Exception {
Assert.assertEquals(0, tagService.getAllTags().size());
Tag tag_1 = createTag("test1");
Tag tag_2 = createTag("test2");
tagService.saveOrUpdate(tag_1);
tagService.saveOrUpdate(tag_2);
Assert.assertEquals(2, tagService.getAllTags().size());
}
/**
* Method: getByName(String name)
*/
@Test
public void testGetByName() throws Exception {
Tag tag = createTag("test");
tagService.saveOrUpdate(tag);
Tag result = tagService.getByName("test");
Assert.assertNotNull(result);
}
/*
* test the link of post and test
* */
@Test
public void testLink() {
Tag tag = createTag("link_test"); | Post post_1 = PostServiceTest.createPost("test1", "hello1", tag); |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/TagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/TagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired | private TagService tagService; |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/TagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired
private TagService tagService;
@GetMapping("/tags")
@ApiOperation(value = "获取所有标签") | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/TagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired
private TagService tagService;
@GetMapping("/tags")
@ApiOperation(value = "获取所有标签") | public Result<List<Tag>> getAllTags() { |
xuzhenyang/ZeroCola | src/main/java/co/lilpilot/blog/controller/TagController.java | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
| import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List; | package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired
private TagService tagService;
@GetMapping("/tags")
@ApiOperation(value = "获取所有标签") | // Path: src/main/java/co/lilpilot/blog/model/Tag.java
// @Data
// @Entity
// @Table(name = "tags")
// public class Tag extends BaseModel {
// @Column(nullable = false, unique = true)
// private String name;
//
// @ManyToMany(mappedBy = "tags")
// // @JsonIgnore避免response中的json数据产生死循环
// @JsonIgnore
// private List<Post> posts = new ArrayList<>();
//
// //toString不包含posts 避免死循环
// @Override
// public String toString() {
// return "Tag{" +
// "name='" + name + '\'' +
// "}" + super.toString();
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/service/TagService.java
// @Service
// public class TagService {
//
// @Autowired
// private TagRepository tagRepository;
// @Autowired
// private PostService postService;
//
// public List<Tag> getAllTags() {
// return tagRepository.findAll();
// }
//
// public Tag getById(Long id) {
// if (id == null) {
// throw new IllegalArgumentException("id is null");
// }
// return tagRepository.findOne(id);
// }
//
// public Tag getByName(String name) {
// if (Strings.isNullOrEmpty(name)) {
// throw new IllegalArgumentException("name is null");
// }
// return tagRepository.findByName(name);
// }
//
// public Tag saveOrUpdate(Tag tag) {
// if (tag == null) {
// throw new IllegalArgumentException("tag is null");
// }
// return tagRepository.save(tag);
// }
//
// public Tag delete(Tag tag) {
// if (tag == null || tag.getId() == null) {
// throw new IllegalArgumentException("tag is null");
// }
// for(Post post : tag.getPosts()) {
// post.getTags().remove(tag);
// }
// tagRepository.delete(tag);
// return tag;
// }
// }
//
// Path: src/main/java/co/lilpilot/blog/util/Result.java
// @Data
// public class Result<T> {
// private boolean success = false;
// private Map<String, T> data = null;
// private String msg = "";
// private String code = "500";
//
// public static <T> Result<T> success(T data) {
// Result result = new Result();
// result.setData(data);
// result.setCode("200");
// result.setMsg("success");
// result.setSuccess(true);
// return result;
// }
//
// public static <T> Result<T> fail(String code, String msg) {
// Result result = new Result();
// result.setSuccess(false);
// result.setCode(code);
// result.setMsg(msg);
// return result;
// }
//
// public Result<T> setData(T data) {
// Map map = new HashMap();
// map.put("result", data);
// this.data = map;
// return this;
// }
//
// public Result<T> setData(String key, T data) {
// Map map = new HashMap();
// map.put(key, data);
// this.data = map;
// return this;
// }
//
// //一定要有这个get方法 不然swagger获取不到data信息
// public T getData() {
// if(this.data != null && !this.data.isEmpty()) {
// Iterator iterator = this.data.keySet().iterator();
// if(iterator.hasNext()) {
// String key = (String)iterator.next();
// return this.data.get(key);
// } else {
// return null;
// }
// } else {
// return null;
// }
// }
// }
// Path: src/main/java/co/lilpilot/blog/controller/TagController.java
import co.lilpilot.blog.model.Tag;
import co.lilpilot.blog.service.TagService;
import co.lilpilot.blog.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
package co.lilpilot.blog.controller;
/**
* Created by lilpilot on 2017/5/23.
*/
@RestController
@RequestMapping("/api/v1")
public class TagController {
@Autowired
private TagService tagService;
@GetMapping("/tags")
@ApiOperation(value = "获取所有标签") | public Result<List<Tag>> getAllTags() { |
Lukx19/Vrep-map-generator | src/MapGenerator/KruskalsAlg/KruskalsGraph.java | // Path: src/MapGenerator/Graph/Edge.java
// public class Edge<T> implements Comparable<Edge<T>> {
// private Node<T> from;
// private Node<T> to;
// private int weight;
//
//
// /**
// * @param from start node
// * @param to end node
// * @param weight weight of the edge
// */
// public Edge(Node<T> from, Node<T> to, int weight) {
// this.from = from;
// this.to = to;
// this.weight = weight;
// }
//
// /**
// * @return return edge start node
// */
// public Node<T> getFrom() {
// return from;
// }
//
// /**
// * @param from sets edge starts node
// */
// public void setFrom(Node<T> from) {
// this.from = from;
// }
//
// /**
// * @return edge end node
// */
// public Node<T> getTo() {
// return to;
// }
//
// /**
// * @param to edge end node
// */
// public void setTo(Node<T> to) {
// this.to = to;
// }
//
// /**
// * @return weight on the edge
// */
// public int getWeight() {
// return weight;
// }
//
// /**
// * @param weight changes edge's weight
// */
// public void setWeight(int weight) {
// this.weight = weight;
// }
//
// /**
// * @param other edge to compare with
// * @return -1 this is less than other; 0 this equals to other; 1 this is greater than other
// */
// @Override
// public int compareTo(Edge<T> other) {
// if(this.getWeight()<other.getWeight())
// return -1;
// else if (this.getWeight() == other.getWeight())
// return 0;
// else
// return 1;
// }
//
// /**
// * @return String representation of the edge node a to node b
// */
// @Override
// public String toString() {
// StringBuilder outp = new StringBuilder();
// outp.append(from.toString());
// outp.append("->");
// outp.append(to.toString());
// outp.append("\n");
// return outp.toString();
// }
// }
//
// Path: src/MapGenerator/Graph/Graph.java
// public class Graph<T> {
//
// protected ArrayList<Node<T>> nodes;
// protected ArrayList<Edge<T>> edges;
//
// /**
// * Creates empty graph
// */
// public Graph(){
// nodes = new ArrayList<>();
// edges= new ArrayList<>();
// }
//
// /**
// * Creates edge from a to b
// * @param a from this node
// * @param b to this node
// * @param weight weight on the edge
// */
// public void addEdge(Node<T> a, Node<T> b, int weight){
// // check if this kind of edge doesn't exists already- no multi-edges
// if(a.getEdges().stream().filter(aa -> aa.getFrom() == b || aa.getTo() == b ).count() == 0){
// Edge<T> edge=new Edge<>(a,b,weight);
// edges.add(edge);
// a.addEdge(edge);
// b.addEdge(edge);
// }
// }
//
// /**
// * Creates new node.
// * @param data data to be stored in the graph node
// */
// public void addNode(T data){
// // check if this node is not already pressent in the graph
// if(getNode(data) == null){
// Node<T> node = new Node<>(nodes.size()-1,data);
// nodes.add(node);
// }
//
// }
//
// /**
// * Finds node which contains data
// * @param data reference to data object
// * @return node which contains data block
// */
// public Node<T> getNode(T data){
// Optional<Node<T>> out = nodes.stream().filter(c->c.getData() == data).findFirst();
// if (out.isPresent()) return out.get();
// else return null;
// }
//
// /**
// * @return all edges in the Graph
// */
// public ArrayList<Edge<T>> getEdges(){
// return edges;
// }
//
// /**
// * @param new_edges redefine edges in the Graph as new_edges
// */
// public void addAllEdges(ArrayList<Edge<T>> new_edges){
// edges = new_edges;
// }
//
// /**
// * @return all nodes in the graph
// */
// public ArrayList<Node<T>> getNodes(){
// return nodes;
// }
//
// /**
// * @return Graph representation of edges node a to node b
// */
// @Override
// public String toString() {
// StringBuilder outp = new StringBuilder();
// edges.stream().forEach(c->c.toString());
// return outp.toString();
// }
// }
| import MapGenerator.Graph.Edge;
import MapGenerator.Graph.Graph;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; | package MapGenerator.KruskalsAlg;
/**
* Creates specific graph for Kruskal's algorithm. Calculate minimal spanning tree
* @author Lukas Jelinek
* @param <T> data type of node
*/
public class KruskalsGraph<T> extends Graph<T>{
private LinkedList<DisJointSet<T>> sets;
int setsCounter;
/**
* Creates empty graph
*/
public KruskalsGraph() {
super();
sets = new LinkedList<>();
setsCounter=0;
}
/**
* @param data data to be stored in the graph node
*/
@Override
public void addNode(T data) {
// check if this node is not already pressent in the graph
if(getNode(data) == null) {
DisJointSet<T> disJointSet = new DisJointSet<>(setsCounter++);
KruskalsNode<T> node = new KruskalsNode<>(disJointSet.getID(), data);
nodes.add(node);
disJointSet.addNode(node);
sets.add(disJointSet);
}
}
/**
* Calculate minimal spanning tree
* @return edges in minimal spanning tree
*/ | // Path: src/MapGenerator/Graph/Edge.java
// public class Edge<T> implements Comparable<Edge<T>> {
// private Node<T> from;
// private Node<T> to;
// private int weight;
//
//
// /**
// * @param from start node
// * @param to end node
// * @param weight weight of the edge
// */
// public Edge(Node<T> from, Node<T> to, int weight) {
// this.from = from;
// this.to = to;
// this.weight = weight;
// }
//
// /**
// * @return return edge start node
// */
// public Node<T> getFrom() {
// return from;
// }
//
// /**
// * @param from sets edge starts node
// */
// public void setFrom(Node<T> from) {
// this.from = from;
// }
//
// /**
// * @return edge end node
// */
// public Node<T> getTo() {
// return to;
// }
//
// /**
// * @param to edge end node
// */
// public void setTo(Node<T> to) {
// this.to = to;
// }
//
// /**
// * @return weight on the edge
// */
// public int getWeight() {
// return weight;
// }
//
// /**
// * @param weight changes edge's weight
// */
// public void setWeight(int weight) {
// this.weight = weight;
// }
//
// /**
// * @param other edge to compare with
// * @return -1 this is less than other; 0 this equals to other; 1 this is greater than other
// */
// @Override
// public int compareTo(Edge<T> other) {
// if(this.getWeight()<other.getWeight())
// return -1;
// else if (this.getWeight() == other.getWeight())
// return 0;
// else
// return 1;
// }
//
// /**
// * @return String representation of the edge node a to node b
// */
// @Override
// public String toString() {
// StringBuilder outp = new StringBuilder();
// outp.append(from.toString());
// outp.append("->");
// outp.append(to.toString());
// outp.append("\n");
// return outp.toString();
// }
// }
//
// Path: src/MapGenerator/Graph/Graph.java
// public class Graph<T> {
//
// protected ArrayList<Node<T>> nodes;
// protected ArrayList<Edge<T>> edges;
//
// /**
// * Creates empty graph
// */
// public Graph(){
// nodes = new ArrayList<>();
// edges= new ArrayList<>();
// }
//
// /**
// * Creates edge from a to b
// * @param a from this node
// * @param b to this node
// * @param weight weight on the edge
// */
// public void addEdge(Node<T> a, Node<T> b, int weight){
// // check if this kind of edge doesn't exists already- no multi-edges
// if(a.getEdges().stream().filter(aa -> aa.getFrom() == b || aa.getTo() == b ).count() == 0){
// Edge<T> edge=new Edge<>(a,b,weight);
// edges.add(edge);
// a.addEdge(edge);
// b.addEdge(edge);
// }
// }
//
// /**
// * Creates new node.
// * @param data data to be stored in the graph node
// */
// public void addNode(T data){
// // check if this node is not already pressent in the graph
// if(getNode(data) == null){
// Node<T> node = new Node<>(nodes.size()-1,data);
// nodes.add(node);
// }
//
// }
//
// /**
// * Finds node which contains data
// * @param data reference to data object
// * @return node which contains data block
// */
// public Node<T> getNode(T data){
// Optional<Node<T>> out = nodes.stream().filter(c->c.getData() == data).findFirst();
// if (out.isPresent()) return out.get();
// else return null;
// }
//
// /**
// * @return all edges in the Graph
// */
// public ArrayList<Edge<T>> getEdges(){
// return edges;
// }
//
// /**
// * @param new_edges redefine edges in the Graph as new_edges
// */
// public void addAllEdges(ArrayList<Edge<T>> new_edges){
// edges = new_edges;
// }
//
// /**
// * @return all nodes in the graph
// */
// public ArrayList<Node<T>> getNodes(){
// return nodes;
// }
//
// /**
// * @return Graph representation of edges node a to node b
// */
// @Override
// public String toString() {
// StringBuilder outp = new StringBuilder();
// edges.stream().forEach(c->c.toString());
// return outp.toString();
// }
// }
// Path: src/MapGenerator/KruskalsAlg/KruskalsGraph.java
import MapGenerator.Graph.Edge;
import MapGenerator.Graph.Graph;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
package MapGenerator.KruskalsAlg;
/**
* Creates specific graph for Kruskal's algorithm. Calculate minimal spanning tree
* @author Lukas Jelinek
* @param <T> data type of node
*/
public class KruskalsGraph<T> extends Graph<T>{
private LinkedList<DisJointSet<T>> sets;
int setsCounter;
/**
* Creates empty graph
*/
public KruskalsGraph() {
super();
sets = new LinkedList<>();
setsCounter=0;
}
/**
* @param data data to be stored in the graph node
*/
@Override
public void addNode(T data) {
// check if this node is not already pressent in the graph
if(getNode(data) == null) {
DisJointSet<T> disJointSet = new DisJointSet<>(setsCounter++);
KruskalsNode<T> node = new KruskalsNode<>(disJointSet.getID(), data);
nodes.add(node);
disJointSet.addNode(node);
sets.add(disJointSet);
}
}
/**
* Calculate minimal spanning tree
* @return edges in minimal spanning tree
*/ | public List<Edge<T>> calcSpanningTree() { |
mgreau/docker4dev-tennistour-app | app/tennistour-rest-api/src/main/java/com/mgreau/tennistour/core/rest/api/PlayerEndpoint.java | // Path: app/tennistour-core/src/main/java/com/mgreau/tennistour/core/entities/Player.java
// @Entity
// @Table(name = "PLAYER", uniqueConstraints = @UniqueConstraint(columnNames = { "NAME" }))
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
// @NamedQuery(name = "Player.findById", query = "SELECT p FROM Player p WHERE p.id = :id"),
// @NamedQuery(name = "Player.findBySexe", query = "SELECT p FROM Player p WHERE p.sexe = :sexe"),
// @NamedQuery(name = "Player.findByName", query = "SELECT p FROM Player p WHERE p.name = :name") })
// public class Player implements Serializable
// {
// private static final long serialVersionUID = 1L;
//
// @Id
// @Basic(optional = false)
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Integer id;
//
// @Basic(optional = false)
// @NotNull
// @Size(min = 1, max = 50)
// private String name;
//
// @Basic(optional = false)
// @NotNull
// private Character sexe;
//
// public Player()
// {
//
// }
//
// public Integer getId()
// {
// return id;
// }
//
// public void setId(Integer id)
// {
// this.id = id;
// }
//
// public String getName()
// {
// return name;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// public Character getSexe()
// {
// return sexe;
// }
//
// public void setSexe(Character sexe)
// {
// this.sexe = sexe;
// }
//
// @Override
// public int hashCode()
// {
// int hash = 0;
// hash += (id != null ? id.hashCode() : 0);
// return hash;
// }
//
// @Override
// public boolean equals(Object object)
// {
// if (!(object instanceof Player))
// {
// return false;
// }
// Player other = (Player) object;
// if ((this.id == null && other.id != null)
// || (this.id != null && !this.id.equals(other.id)))
// {
// return false;
// }
// else if (this.id == null && other.id == null)
// {
// if (this.name != null && other.name != null
// && this.name.equals(other.name))
// return true;
// }
// return false;
// }
//
// @Override
// public String toString()
// {
// return "Player@" + hashCode() + "[id = " + id + "; name = " + name
// + "]";
// }
//
// }
| import com.mgreau.tennistour.core.entities.Player;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder; | package com.mgreau.tennistour.core.rest.api;
/**
*
*/
@Stateless
@Path("/players")
public class PlayerEndpoint
{
@PersistenceContext(unitName = "tennistour")
private EntityManager em;
@POST
@Consumes("application/json") | // Path: app/tennistour-core/src/main/java/com/mgreau/tennistour/core/entities/Player.java
// @Entity
// @Table(name = "PLAYER", uniqueConstraints = @UniqueConstraint(columnNames = { "NAME" }))
// @XmlRootElement
// @NamedQueries({
// @NamedQuery(name = "Player.findAll", query = "SELECT p FROM Player p"),
// @NamedQuery(name = "Player.findById", query = "SELECT p FROM Player p WHERE p.id = :id"),
// @NamedQuery(name = "Player.findBySexe", query = "SELECT p FROM Player p WHERE p.sexe = :sexe"),
// @NamedQuery(name = "Player.findByName", query = "SELECT p FROM Player p WHERE p.name = :name") })
// public class Player implements Serializable
// {
// private static final long serialVersionUID = 1L;
//
// @Id
// @Basic(optional = false)
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// private Integer id;
//
// @Basic(optional = false)
// @NotNull
// @Size(min = 1, max = 50)
// private String name;
//
// @Basic(optional = false)
// @NotNull
// private Character sexe;
//
// public Player()
// {
//
// }
//
// public Integer getId()
// {
// return id;
// }
//
// public void setId(Integer id)
// {
// this.id = id;
// }
//
// public String getName()
// {
// return name;
// }
//
// public void setName(String name)
// {
// this.name = name;
// }
//
// public Character getSexe()
// {
// return sexe;
// }
//
// public void setSexe(Character sexe)
// {
// this.sexe = sexe;
// }
//
// @Override
// public int hashCode()
// {
// int hash = 0;
// hash += (id != null ? id.hashCode() : 0);
// return hash;
// }
//
// @Override
// public boolean equals(Object object)
// {
// if (!(object instanceof Player))
// {
// return false;
// }
// Player other = (Player) object;
// if ((this.id == null && other.id != null)
// || (this.id != null && !this.id.equals(other.id)))
// {
// return false;
// }
// else if (this.id == null && other.id == null)
// {
// if (this.name != null && other.name != null
// && this.name.equals(other.name))
// return true;
// }
// return false;
// }
//
// @Override
// public String toString()
// {
// return "Player@" + hashCode() + "[id = " + id + "; name = " + name
// + "]";
// }
//
// }
// Path: app/tennistour-rest-api/src/main/java/com/mgreau/tennistour/core/rest/api/PlayerEndpoint.java
import com.mgreau.tennistour.core.entities.Player;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;
package com.mgreau.tennistour.core.rest.api;
/**
*
*/
@Stateless
@Path("/players")
public class PlayerEndpoint
{
@PersistenceContext(unitName = "tennistour")
private EntityManager em;
@POST
@Consumes("application/json") | public Response create(Player entity) |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/IPad.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface IPad {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/IPad.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface IPad {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
| import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf; | package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
// Path: src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java
import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf;
package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) { | super(StringUtils.indent("\nElement:\n" + htmlOf(webElement), INDENT)); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
| import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf; | package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
// Path: src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java
import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf;
package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) { | super(StringUtils.indent("\nElement:\n" + htmlOf(webElement), INDENT)); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
| import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf; | package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) {
super(StringUtils.indent("\nElement:\n" + htmlOf(webElement), INDENT));
}
public WebAssertionError(String detailMessage, WebElement webElement) {
super(detailMessage + getDebugInfo(webElement));
}
public WebAssertionError(String detailMessage, String name, String value) {
super(detailMessage + StringUtils.indent("\n" + name + ": " + value, INDENT));
}
public WebAssertionError(String detailMessage, String name, double actual) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/NumberUtils.java
// public class NumberUtils {
//
// private NumberUtils() {}
//
// public static String toString(double number) {
// if (number == (int) number) {
// return String.format("%d", (int) number);
// } else {
// return String.format("%s", number);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/StringUtils.java
// public class StringUtils {
//
// private StringUtils() {}
//
// public static String appendNewLineIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string;
// }
// return string;
// }
//
// public static String surroundNewLinesIfContainsNewLine(String string) {
// if (contains(string, "\n")) {
// return "\n" + string + "\n";
// }
// return string;
// }
//
// public static String prependSpaceIfNotBlank(String string) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(string)) {
// return " " + string;
// }
// return string;
// }
//
// public static String quote(String text) {
// return "\"" + text + "\"";
// }
//
// public static String quote(double number) {
// return "\"" + NumberUtils.toString(number) + "\"";
// }
//
// public static String indent(String string, String indent) {
// return string.replaceAll("\n", "\n" + indent);
// }
//
// public static boolean isBlank(String string) {
// return org.apache.commons.lang3.StringUtils.isBlank(string);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/BotUtils.java
// public static String htmlOf(WebElement webElement) {
// if (webElement == null) {
// return "Element is null";
// }
// String innerHtml = innerHtmlOf(webElement);
// if (StringUtils.isBlank(innerHtml)) {
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + " />";
// }
// return "<" + Bot.tagNameOf(webElement) + prependSpaceIfNotBlank(attributesIn(webElement)) + ">"
// + surroundNewLinesIfContainsNewLine(innerHtml)
// + "</" + Bot.tagNameOf(webElement) + ">";
//
// }
// Path: src/main/java/com/github/webdriverextensions/exceptions/WebAssertionError.java
import com.github.webdriverextensions.internal.utils.NumberUtils;
import com.github.webdriverextensions.internal.utils.StringUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import static com.github.webdriverextensions.internal.BotUtils.htmlOf;
package com.github.webdriverextensions.exceptions;
public class WebAssertionError extends java.lang.AssertionError {
private static final String INDENT = " ";
public WebAssertionError(WebElement webElement) {
super(StringUtils.indent("\nElement:\n" + htmlOf(webElement), INDENT));
}
public WebAssertionError(String detailMessage, WebElement webElement) {
super(detailMessage + getDebugInfo(webElement));
}
public WebAssertionError(String detailMessage, String name, String value) {
super(detailMessage + StringUtils.indent("\n" + name + ": " + value, INDENT));
}
public WebAssertionError(String detailMessage, String name, double actual) { | super(detailMessage + StringUtils.indent("\n" + name + ": " + NumberUtils.toString(actual), INDENT)); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Opera.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Opera {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Opera.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Opera {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/IPhone.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface IPhone {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/IPhone.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface IPhone {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/PhantomJS.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface PhantomJS {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/PhantomJS.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface PhantomJS {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/junitrunner/DisabledBrowserTest.java | // Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import org.junit.Test;
import com.github.webdriverextensions.WebDriverProperties; | package com.github.webdriverextensions.junitrunner;
public class DisabledBrowserTest {
@Test
public void testParseDisabledBrowserSring() {
assertThat(WebDriverRunner.parseDisabledBrowserString("").size(), is(0));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox").size(), is(1));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome").size(), is(2));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome"), hasItem("chrome"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome").size(), is(2));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome"), hasItem("chrome"));
}
@Test
public void testGetDisabledBrowsers() { | // Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/test/java/com/github/webdriverextensions/junitrunner/DisabledBrowserTest.java
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import org.junit.Test;
import com.github.webdriverextensions.WebDriverProperties;
package com.github.webdriverextensions.junitrunner;
public class DisabledBrowserTest {
@Test
public void testParseDisabledBrowserSring() {
assertThat(WebDriverRunner.parseDisabledBrowserString("").size(), is(0));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox").size(), is(1));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome").size(), is(2));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox,chrome"), hasItem("chrome"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome").size(), is(2));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome"), hasItem("firefox"));
assertThat(WebDriverRunner.parseDisabledBrowserString("firefox , chrome"), hasItem("chrome"));
}
@Test
public void testGetDisabledBrowsers() { | System.setProperty(WebDriverProperties.DISABLED_BROWSERS_PROPERTY_NAME, "firefox"); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/HtmlUnit.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface HtmlUnit {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/HtmlUnit.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface HtmlUnit {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; | package com.github.webdriverextensions.internal.junitrunner;
public class DriverPathLoader {
private DriverPathLoader() {}
public static void loadDriverPaths(DriverPaths driverPaths) {
loadChromeDriverPath(driverPaths != null ? driverPaths.chrome() : null);
loadFirefoxDriverPath(driverPaths != null ? driverPaths.firefox() : null);
loadEdgeDriverPath(driverPaths != null ? driverPaths.edge() : null);
loadInternetExplorerDriverPath(driverPaths != null ? driverPaths.internetExplorer() : null);
loadPhantomJsDriverPath(driverPaths != null ? driverPaths.phantomJs() : null);
makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
package com.github.webdriverextensions.internal.junitrunner;
public class DriverPathLoader {
private DriverPathLoader() {}
public static void loadDriverPaths(DriverPaths driverPaths) {
loadChromeDriverPath(driverPaths != null ? driverPaths.chrome() : null);
loadFirefoxDriverPath(driverPaths != null ? driverPaths.firefox() : null);
loadEdgeDriverPath(driverPaths != null ? driverPaths.edge() : null);
loadInternetExplorerDriverPath(driverPaths != null ? driverPaths.internetExplorer() : null);
loadPhantomJsDriverPath(driverPaths != null ? driverPaths.phantomJs() : null);
makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) { | PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, path); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; | package com.github.webdriverextensions.internal.junitrunner;
public class DriverPathLoader {
private DriverPathLoader() {}
public static void loadDriverPaths(DriverPaths driverPaths) {
loadChromeDriverPath(driverPaths != null ? driverPaths.chrome() : null);
loadFirefoxDriverPath(driverPaths != null ? driverPaths.firefox() : null);
loadEdgeDriverPath(driverPaths != null ? driverPaths.edge() : null);
loadInternetExplorerDriverPath(driverPaths != null ? driverPaths.internetExplorer() : null);
loadPhantomJsDriverPath(driverPaths != null ? driverPaths.phantomJs() : null);
makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
package com.github.webdriverextensions.internal.junitrunner;
public class DriverPathLoader {
private DriverPathLoader() {}
public static void loadDriverPaths(DriverPaths driverPaths) {
loadChromeDriverPath(driverPaths != null ? driverPaths.chrome() : null);
loadFirefoxDriverPath(driverPaths != null ? driverPaths.firefox() : null);
loadEdgeDriverPath(driverPaths != null ? driverPaths.edge() : null);
loadInternetExplorerDriverPath(driverPaths != null ? driverPaths.internetExplorer() : null);
loadPhantomJsDriverPath(driverPaths != null ? driverPaths.phantomJs() : null);
makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) { | PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, System.getProperty(INTERNET_EXPLORER_DRIVER_PROPERTY_NAME)); // Alternative property name that follows naming convention |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; | makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, System.getProperty(INTERNET_EXPLORER_DRIVER_PROPERTY_NAME)); // Alternative property name that follows naming convention
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, getInternetExplorerDriverDefaultPath());
}
private static void loadPhantomJsDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, getPhantomJsDefaultPath());
}
private static void makeSureDriversAreExecutable() { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
makeSureDriversAreExecutable();
}
private static void loadChromeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, System.getProperty(INTERNET_EXPLORER_DRIVER_PROPERTY_NAME)); // Alternative property name that follows naming convention
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, getInternetExplorerDriverDefaultPath());
}
private static void loadPhantomJsDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, getPhantomJsDefaultPath());
}
private static void makeSureDriversAreExecutable() { | FileUtils.makeExecutable(System.getProperty(CHROME_DRIVER_PROPERTY_NAME)); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; | PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, System.getProperty(INTERNET_EXPLORER_DRIVER_PROPERTY_NAME)); // Alternative property name that follows naming convention
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, getInternetExplorerDriverDefaultPath());
}
private static void loadPhantomJsDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, getPhantomJsDefaultPath());
}
private static void makeSureDriversAreExecutable() {
FileUtils.makeExecutable(System.getProperty(CHROME_DRIVER_PROPERTY_NAME));
FileUtils.makeExecutable(System.getProperty(IE_DRIVER_PROPERTY_NAME));
}
private static String getChromeDriverDefaultPath() { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
PropertyUtils.setPropertyIfNotExists(CHROME_DRIVER_PROPERTY_NAME, getChromeDriverDefaultPath());
}
private static void loadFirefoxDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(FIREFOX_DRIVER_PROPERTY_NAME, getFirefoxDriverDefaultPath());
}
private static void loadEdgeDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(EDGE_DRIVER_PROPERTY_NAME, getEdgeDefaultPath());
}
private static void loadInternetExplorerDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, System.getProperty(INTERNET_EXPLORER_DRIVER_PROPERTY_NAME)); // Alternative property name that follows naming convention
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(IE_DRIVER_PROPERTY_NAME, getInternetExplorerDriverDefaultPath());
}
private static void loadPhantomJsDriverPath(String path) {
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, path);
PropertyUtils.setPropertyIfNotExists(PHANTOMJS_BINARY_PROPERTY_NAME, getPhantomJsDefaultPath());
}
private static void makeSureDriversAreExecutable() {
FileUtils.makeExecutable(System.getProperty(CHROME_DRIVER_PROPERTY_NAME));
FileUtils.makeExecutable(System.getProperty(IE_DRIVER_PROPERTY_NAME));
}
private static String getChromeDriverDefaultPath() { | if (OsUtils.isWindows()) { |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; | }
private static String getEdgeDefaultPath() {
if (OsUtils.isWindows()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/edgedriver-windows-64bit.exe")) || Files.notExists(Paths.get("./drivers/edgedriver-windows-32bit.exe")))) {
return "drivers/edgedriver-windows-64bit.exe";
} else {
return "drivers/edgedriver-windows-32bit.exe";
}
}
return null;
}
private static String getPhantomJsDefaultPath() {
if (OsUtils.isWindows()) {
return "drivers/phantomjs-windows-64bit.exe";
} else if (OsUtils.isMac()) {
return "drivers/phantomjs-mac-64bit";
} else if (OsUtils.isLinux()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/phantomjs-linux-64bit")) || Files.notExists(Paths.get("./drivers/phantomjs-linux-32bit")))) {
return "drivers/phantomjs-linux-64bit";
} else {
return "drivers/phantomjs-linux-32bit";
}
}
return null;
}
private static String getInternetExplorerDriverDefaultPath() {
if (OsUtils.isWindows()) { | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
}
private static String getEdgeDefaultPath() {
if (OsUtils.isWindows()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/edgedriver-windows-64bit.exe")) || Files.notExists(Paths.get("./drivers/edgedriver-windows-32bit.exe")))) {
return "drivers/edgedriver-windows-64bit.exe";
} else {
return "drivers/edgedriver-windows-32bit.exe";
}
}
return null;
}
private static String getPhantomJsDefaultPath() {
if (OsUtils.isWindows()) {
return "drivers/phantomjs-windows-64bit.exe";
} else if (OsUtils.isMac()) {
return "drivers/phantomjs-mac-64bit";
} else if (OsUtils.isLinux()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/phantomjs-linux-64bit")) || Files.notExists(Paths.get("./drivers/phantomjs-linux-32bit")))) {
return "drivers/phantomjs-linux-64bit";
} else {
return "drivers/phantomjs-linux-32bit";
}
}
return null;
}
private static String getInternetExplorerDriverDefaultPath() {
if (OsUtils.isWindows()) { | if (!PropertyUtils.propertyExists(IE_DRIVER_USE64BIT_PROPERTY_NAME) |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
| import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*; |
private static String getEdgeDefaultPath() {
if (OsUtils.isWindows()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/edgedriver-windows-64bit.exe")) || Files.notExists(Paths.get("./drivers/edgedriver-windows-32bit.exe")))) {
return "drivers/edgedriver-windows-64bit.exe";
} else {
return "drivers/edgedriver-windows-32bit.exe";
}
}
return null;
}
private static String getPhantomJsDefaultPath() {
if (OsUtils.isWindows()) {
return "drivers/phantomjs-windows-64bit.exe";
} else if (OsUtils.isMac()) {
return "drivers/phantomjs-mac-64bit";
} else if (OsUtils.isLinux()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/phantomjs-linux-64bit")) || Files.notExists(Paths.get("./drivers/phantomjs-linux-32bit")))) {
return "drivers/phantomjs-linux-64bit";
} else {
return "drivers/phantomjs-linux-32bit";
}
}
return null;
}
private static String getInternetExplorerDriverDefaultPath() {
if (OsUtils.isWindows()) {
if (!PropertyUtils.propertyExists(IE_DRIVER_USE64BIT_PROPERTY_NAME) | // Path: src/main/java/com/github/webdriverextensions/internal/utils/FileUtils.java
// public class FileUtils {
//
// private FileUtils() {}
//
// public static void makeExecutable(String path) {
// if (path == null) {
// return;
// }
// File file = new File(path);
// if (file.exists() && !file.canExecute()) {
// file.setExecutable(true);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/OsUtils.java
// public class OsUtils {
//
// private OsUtils() {}
//
// public static boolean isWindows() {
// return Platform.getCurrent().is(Platform.WINDOWS);
// }
//
// public static boolean isWindows10() {
// return Platform.getCurrent().is(Platform.WIN10);
// }
//
// public static boolean isMac() {
// return Platform.getCurrent().is(Platform.MAC);
// }
//
// public static boolean isLinux() {
// return Platform.getCurrent().is(Platform.LINUX);
// }
//
// public static boolean isCurrentPlatform(String platform) {
// try {
// return Platform.getCurrent().is(Platform.valueOf(platform));
// } catch (IllegalArgumentException e) {
// return false;
// }
// }
//
// public static boolean is64Bit() {
// return com.sun.jna.Platform.is64Bit();
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String IE_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.ie.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_PROPERTY_NAME = "webdriver.internetexplorer.driver"; // Alternative property name that follows naming convention
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsProperties.java
// public static final String INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME = "webdriverextensions.internetexplorer.driver.use64Bit";
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverProperties.java
// public class WebDriverProperties {
// public static final String CHROME_DRIVER_PROPERTY_NAME = "webdriver.chrome.driver";
// public static final String CHROME_BINARY_PROPERTY_NAME = "chrome.binary.path";
// public static final String FIREFOX_DRIVER_PROPERTY_NAME = "webdriver.gecko.driver";
// public static final String IE_DRIVER_PROPERTY_NAME = "webdriver.ie.driver";
// public static final String PHANTOMJS_BINARY_PROPERTY_NAME = "phantomjs.binary.path";
// public static final String OPERA_DRIVER_PROPERTY_NAME = "webdriver.opera.driver";
// public static final String EDGE_DRIVER_PROPERTY_NAME = "webdriver.edge.driver";
// public static final String DISABLED_BROWSERS_PROPERTY_NAME = "webdriverextensions.disabledbrowsers";
// }
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/DriverPathLoader.java
import com.github.webdriverextensions.internal.utils.FileUtils;
import com.github.webdriverextensions.internal.utils.OsUtils;
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import com.github.webdriverextensions.junitrunner.annotations.DriverPaths;
import java.nio.file.Files;
import java.nio.file.Paths;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.IE_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverExtensionsProperties.INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME;
import static com.github.webdriverextensions.WebDriverProperties.*;
private static String getEdgeDefaultPath() {
if (OsUtils.isWindows()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/edgedriver-windows-64bit.exe")) || Files.notExists(Paths.get("./drivers/edgedriver-windows-32bit.exe")))) {
return "drivers/edgedriver-windows-64bit.exe";
} else {
return "drivers/edgedriver-windows-32bit.exe";
}
}
return null;
}
private static String getPhantomJsDefaultPath() {
if (OsUtils.isWindows()) {
return "drivers/phantomjs-windows-64bit.exe";
} else if (OsUtils.isMac()) {
return "drivers/phantomjs-mac-64bit";
} else if (OsUtils.isLinux()) {
if (OsUtils.is64Bit() && (Files.exists(Paths.get("./drivers/phantomjs-linux-64bit")) || Files.notExists(Paths.get("./drivers/phantomjs-linux-32bit")))) {
return "drivers/phantomjs-linux-64bit";
} else {
return "drivers/phantomjs-linux-32bit";
}
}
return null;
}
private static String getInternetExplorerDriverDefaultPath() {
if (OsUtils.isWindows()) {
if (!PropertyUtils.propertyExists(IE_DRIVER_USE64BIT_PROPERTY_NAME) | || !PropertyUtils.propertyExists(INTERNET_EXPLORER_DRIVER_USE64BIT_PROPERTY_NAME)) { |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Safari.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Safari {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Safari.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Safari {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Android.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Android {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Android.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Android {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/junitrunner/RemoteWebDriverRunnerTest.java | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertCurrentUrlContains(String searchText) {
// BotUtils.assertContains("Current url", searchText, currentUrl());
// }
//
// Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void open(String url) {
// driver().get(url);
// }
| import static com.github.webdriverextensions.Bot.assertCurrentUrlContains;
import static com.github.webdriverextensions.Bot.open;
import com.github.webdriverextensions.junitrunner.annotations.Browsers;
import com.github.webdriverextensions.junitrunner.annotations.Chrome;
import com.github.webdriverextensions.junitrunner.annotations.RemoteAddress;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner;
@RunWith(WebDriverRunner.class)
@RemoteAddress("http://andidev:80b7768e-dc06-4d5b-b793-5b3b83f0e24c@ondemand.saucelabs.com:80/wd/hub")
@Browsers(
chrome = {
@Chrome(platform = Platform.WINDOWS),
@Chrome(platform = Platform.LINUX),
@Chrome(platform = Platform.MAC)
}
)
public class RemoteWebDriverRunnerTest {
@Test
public void openGoogleTest() { | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertCurrentUrlContains(String searchText) {
// BotUtils.assertContains("Current url", searchText, currentUrl());
// }
//
// Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void open(String url) {
// driver().get(url);
// }
// Path: src/test/java/com/github/webdriverextensions/junitrunner/RemoteWebDriverRunnerTest.java
import static com.github.webdriverextensions.Bot.assertCurrentUrlContains;
import static com.github.webdriverextensions.Bot.open;
import com.github.webdriverextensions.junitrunner.annotations.Browsers;
import com.github.webdriverextensions.junitrunner.annotations.Chrome;
import com.github.webdriverextensions.junitrunner.annotations.RemoteAddress;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner;
@RunWith(WebDriverRunner.class)
@RemoteAddress("http://andidev:80b7768e-dc06-4d5b-b793-5b3b83f0e24c@ondemand.saucelabs.com:80/wd/hub")
@Browsers(
chrome = {
@Chrome(platform = Platform.WINDOWS),
@Chrome(platform = Platform.LINUX),
@Chrome(platform = Platform.MAC)
}
)
public class RemoteWebDriverRunnerTest {
@Test
public void openGoogleTest() { | open("https://github.com"); |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/junitrunner/RemoteWebDriverRunnerTest.java | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertCurrentUrlContains(String searchText) {
// BotUtils.assertContains("Current url", searchText, currentUrl());
// }
//
// Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void open(String url) {
// driver().get(url);
// }
| import static com.github.webdriverextensions.Bot.assertCurrentUrlContains;
import static com.github.webdriverextensions.Bot.open;
import com.github.webdriverextensions.junitrunner.annotations.Browsers;
import com.github.webdriverextensions.junitrunner.annotations.Chrome;
import com.github.webdriverextensions.junitrunner.annotations.RemoteAddress;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner;
@RunWith(WebDriverRunner.class)
@RemoteAddress("http://andidev:80b7768e-dc06-4d5b-b793-5b3b83f0e24c@ondemand.saucelabs.com:80/wd/hub")
@Browsers(
chrome = {
@Chrome(platform = Platform.WINDOWS),
@Chrome(platform = Platform.LINUX),
@Chrome(platform = Platform.MAC)
}
)
public class RemoteWebDriverRunnerTest {
@Test
public void openGoogleTest() {
open("https://github.com"); | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertCurrentUrlContains(String searchText) {
// BotUtils.assertContains("Current url", searchText, currentUrl());
// }
//
// Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void open(String url) {
// driver().get(url);
// }
// Path: src/test/java/com/github/webdriverextensions/junitrunner/RemoteWebDriverRunnerTest.java
import static com.github.webdriverextensions.Bot.assertCurrentUrlContains;
import static com.github.webdriverextensions.Bot.open;
import com.github.webdriverextensions.junitrunner.annotations.Browsers;
import com.github.webdriverextensions.junitrunner.annotations.Chrome;
import com.github.webdriverextensions.junitrunner.annotations.RemoteAddress;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner;
@RunWith(WebDriverRunner.class)
@RemoteAddress("http://andidev:80b7768e-dc06-4d5b-b793-5b3b83f0e24c@ondemand.saucelabs.com:80/wd/hub")
@Browsers(
chrome = {
@Chrome(platform = Platform.WINDOWS),
@Chrome(platform = Platform.LINUX),
@Chrome(platform = Platform.MAC)
}
)
public class RemoteWebDriverRunnerTest {
@Test
public void openGoogleTest() {
open("https://github.com"); | assertCurrentUrlContains("github"); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Firefox.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Firefox {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Firefox.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Firefox {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/ScreenshotsPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/WebDriverUtils.java
// public static final String SCREENSHOTSPATH_PROPERTY_NAME = "webdriverextensions.screenshotspath";
| import com.github.webdriverextensions.internal.utils.PropertyUtils;
import static com.github.webdriverextensions.internal.utils.WebDriverUtils.SCREENSHOTSPATH_PROPERTY_NAME;
import com.github.webdriverextensions.junitrunner.annotations.ScreenshotsPath; | package com.github.webdriverextensions.internal.junitrunner;
public class ScreenshotsPathLoader {
private ScreenshotsPathLoader() {}
public static void loadScreenshotsPath(ScreenshotsPath screenshotsPathAnnotation) {
String screenshotsPathAnnotationValue = screenshotsPathAnnotation != null ? screenshotsPathAnnotation.value() : null; | // Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/WebDriverUtils.java
// public static final String SCREENSHOTSPATH_PROPERTY_NAME = "webdriverextensions.screenshotspath";
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/ScreenshotsPathLoader.java
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import static com.github.webdriverextensions.internal.utils.WebDriverUtils.SCREENSHOTSPATH_PROPERTY_NAME;
import com.github.webdriverextensions.junitrunner.annotations.ScreenshotsPath;
package com.github.webdriverextensions.internal.junitrunner;
public class ScreenshotsPathLoader {
private ScreenshotsPathLoader() {}
public static void loadScreenshotsPath(ScreenshotsPath screenshotsPathAnnotation) {
String screenshotsPathAnnotationValue = screenshotsPathAnnotation != null ? screenshotsPathAnnotation.value() : null; | PropertyUtils.setPropertyIfNotExists(SCREENSHOTSPATH_PROPERTY_NAME, screenshotsPathAnnotationValue); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/junitrunner/ScreenshotsPathLoader.java | // Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/WebDriverUtils.java
// public static final String SCREENSHOTSPATH_PROPERTY_NAME = "webdriverextensions.screenshotspath";
| import com.github.webdriverextensions.internal.utils.PropertyUtils;
import static com.github.webdriverextensions.internal.utils.WebDriverUtils.SCREENSHOTSPATH_PROPERTY_NAME;
import com.github.webdriverextensions.junitrunner.annotations.ScreenshotsPath; | package com.github.webdriverextensions.internal.junitrunner;
public class ScreenshotsPathLoader {
private ScreenshotsPathLoader() {}
public static void loadScreenshotsPath(ScreenshotsPath screenshotsPathAnnotation) {
String screenshotsPathAnnotationValue = screenshotsPathAnnotation != null ? screenshotsPathAnnotation.value() : null; | // Path: src/main/java/com/github/webdriverextensions/internal/utils/PropertyUtils.java
// public class PropertyUtils {
//
// private PropertyUtils() {}
//
// public static boolean isTrue(String key) {
// return BooleanUtils.toBoolean(System.getProperty(key));
// }
//
// public static boolean propertyExists(String key) {
// return System.getProperty(key) != null;
// }
//
// public static void setPropertyIfNotExists(String key, String value) {
// if (value == null || StringUtils.isBlank(value)) {
// return;
// }
// if (!propertyExists(key)) {
// System.setProperty(key, value);
// }
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/utils/WebDriverUtils.java
// public static final String SCREENSHOTSPATH_PROPERTY_NAME = "webdriverextensions.screenshotspath";
// Path: src/main/java/com/github/webdriverextensions/internal/junitrunner/ScreenshotsPathLoader.java
import com.github.webdriverextensions.internal.utils.PropertyUtils;
import static com.github.webdriverextensions.internal.utils.WebDriverUtils.SCREENSHOTSPATH_PROPERTY_NAME;
import com.github.webdriverextensions.junitrunner.annotations.ScreenshotsPath;
package com.github.webdriverextensions.internal.junitrunner;
public class ScreenshotsPathLoader {
private ScreenshotsPathLoader() {}
public static void loadScreenshotsPath(ScreenshotsPath screenshotsPathAnnotation) {
String screenshotsPathAnnotationValue = screenshotsPathAnnotation != null ? screenshotsPathAnnotation.value() : null; | PropertyUtils.setPropertyIfNotExists(SCREENSHOTSPATH_PROPERTY_NAME, screenshotsPathAnnotationValue); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Chrome.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Chrome {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Chrome.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Chrome {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Edge.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import org.openqa.selenium.Platform;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Edge {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Edge.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import org.openqa.selenium.Platform;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Edge {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/Browser.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Browser {
String browserName();
String version() default "";
String platform() default "ANY";
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/Browser.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Browser {
String browserName();
String version() default "";
String platform() default "ANY";
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/junitrunner/annotations/InternetExplorer.java | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
| import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform; | package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface InternetExplorer {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | // Path: src/main/java/com/github/webdriverextensions/junitrunner/NoDesiredCapabilities.java
// public class NoDesiredCapabilities extends DesiredCapabilities {
// public NoDesiredCapabilities() {
// // Don't add any capability
// }
// }
// Path: src/main/java/com/github/webdriverextensions/junitrunner/annotations/InternetExplorer.java
import com.github.webdriverextensions.junitrunner.NoDesiredCapabilities;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.openqa.selenium.Platform;
package com.github.webdriverextensions.junitrunner.annotations;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface InternetExplorer {
String version() default "";
Platform platform() default Platform.ANY;
String desiredCapabilities() default ""; | Class desiredCapabilitiesClass() default NoDesiredCapabilities.class; |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
| import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils; | package com.github.webdriverextensions.internal.generator;
public class WebRepositoryBuilder implements Builder<Boolean> {
// Input Elements
final private ProcessingEnvironment processingEnv;
final private Set<TypeElement> webSiteElements;
final private Set<TypeElement> webPageElements;
final private Set<TypeElement> webRepositoryElements;
final private Set<TypeElement> otherElements;
final private JCodeModel codeModel;
// JClasses
private JDefinedClass generatedWebRepositoryClass;
public WebRepositoryBuilder(ProcessingEnvironment processingEnv, Set<TypeElement> webSiteElements,
Set<TypeElement> webPageElements, Set<TypeElement> webRepositoryElements, Set<TypeElement> otherElements) {
this.processingEnv = processingEnv;
this.webSiteElements = webSiteElements;
this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) { | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
// Path: src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java
import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils;
package com.github.webdriverextensions.internal.generator;
public class WebRepositoryBuilder implements Builder<Boolean> {
// Input Elements
final private ProcessingEnvironment processingEnv;
final private Set<TypeElement> webSiteElements;
final private Set<TypeElement> webPageElements;
final private Set<TypeElement> webRepositoryElements;
final private Set<TypeElement> otherElements;
final private JCodeModel codeModel;
// JClasses
private JDefinedClass generatedWebRepositoryClass;
public WebRepositoryBuilder(ProcessingEnvironment processingEnv, Set<TypeElement> webSiteElements,
Set<TypeElement> webPageElements, Set<TypeElement> webRepositoryElements, Set<TypeElement> otherElements) {
this.processingEnv = processingEnv;
this.webSiteElements = webSiteElements;
this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) { | error("Failed to generate GeneratedWebRepository!", processingEnv); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
| import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils; | // JClasses
private JDefinedClass generatedWebRepositoryClass;
public WebRepositoryBuilder(ProcessingEnvironment processingEnv, Set<TypeElement> webSiteElements,
Set<TypeElement> webPageElements, Set<TypeElement> webRepositoryElements, Set<TypeElement> otherElements) {
this.processingEnv = processingEnv;
this.webSiteElements = webSiteElements;
this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) {
error("Failed to generate GeneratedWebRepository!", processingEnv);
error(ExceptionUtils.getStackTrace(ex), processingEnv);
return false;
}
}
private void createClass() throws JClassAlreadyExistsException {
generatedWebRepositoryClass = codeModel._class(JMod.PUBLIC | JMod.ABSTRACT, "com.github.webdriverextensions.generator.GeneratedWebRepository", ClassType.CLASS); | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
// Path: src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java
import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils;
// JClasses
private JDefinedClass generatedWebRepositoryClass;
public WebRepositoryBuilder(ProcessingEnvironment processingEnv, Set<TypeElement> webSiteElements,
Set<TypeElement> webPageElements, Set<TypeElement> webRepositoryElements, Set<TypeElement> otherElements) {
this.processingEnv = processingEnv;
this.webSiteElements = webSiteElements;
this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) {
error("Failed to generate GeneratedWebRepository!", processingEnv);
error(ExceptionUtils.getStackTrace(ex), processingEnv);
return false;
}
}
private void createClass() throws JClassAlreadyExistsException {
generatedWebRepositoryClass = codeModel._class(JMod.PUBLIC | JMod.ABSTRACT, "com.github.webdriverextensions.generator.GeneratedWebRepository", ClassType.CLASS); | generatedWebRepositoryClass._extends(codeModel.ref(WebRepository.class)); |
webdriverextensions/webdriverextensions | src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
| import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils; | this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) {
error("Failed to generate GeneratedWebRepository!", processingEnv);
error(ExceptionUtils.getStackTrace(ex), processingEnv);
return false;
}
}
private void createClass() throws JClassAlreadyExistsException {
generatedWebRepositoryClass = codeModel._class(JMod.PUBLIC | JMod.ABSTRACT, "com.github.webdriverextensions.generator.GeneratedWebRepository", ClassType.CLASS);
generatedWebRepositoryClass._extends(codeModel.ref(WebRepository.class));
}
private void createFields() {
// Declare WebSites
for (TypeElement webSiteElement : webSiteElements) {
JClass webSiteClass = codeModel.ref(webSiteElement.getQualifiedName().toString()); | // Path: src/main/java/com/github/webdriverextensions/WebRepository.java
// public abstract class WebRepository {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindByAnnotation(JFieldVar field, AnnotationMirror findBy) {
// JAnnotationUse annotation = field.annotate(FindBy.class);
// setFindByAnnotationValues(annotation, findBy);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) {
// JAnnotationUse findBysAnnotation = field.annotate(FindBys.class);
// JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value");
// for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) {
// JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class);
// setFindByAnnotationValues(findByAnnotation, findBy);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static void error(String msg, ProcessingEnvironment processingEnv) {
// processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static String getFieldName(Element element) {
// String className = element.getSimpleName().toString();
// return StringUtils.uncapitalize(className);
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindByAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBy")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static AnnotationMirror getFindBysAnnotation(TypeElement element) {
// for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
// if (annotationMirror.getAnnotationType().toString().equals("org.openqa.selenium.support.FindBys")) {
// return annotationMirror;
// }
// }
// return null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindByAnnotation(TypeElement element) {
// return getFindByAnnotation(element) != null;
// }
//
// Path: src/main/java/com/github/webdriverextensions/internal/generator/GeneratorUtils.java
// public static boolean hasFindBysAnnotation(TypeElement element) {
// return getFindBysAnnotation(element) != null;
// }
// Path: src/main/java/com/github/webdriverextensions/internal/generator/WebRepositoryBuilder.java
import com.github.webdriverextensions.WebRepository;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.annotateFieldWithFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.error;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFieldName;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.getFindBysAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindByAnnotation;
import static com.github.webdriverextensions.internal.generator.GeneratorUtils.hasFindBysAnnotation;
import com.sun.codemodel.ClassType;
import com.sun.codemodel.CodeWriter;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JClassAlreadyExistsException;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMod;
import java.io.IOException;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.TypeElement;
import org.apache.commons.lang3.builder.Builder;
import org.apache.commons.lang3.exception.ExceptionUtils;
this.webPageElements = webPageElements;
this.webRepositoryElements = webRepositoryElements;
this.otherElements = otherElements;
this.codeModel = new JCodeModel();
}
@Override
public Boolean build() {
try {
createClass();
createFields();
generate();
return true;
} catch (IOException|JClassAlreadyExistsException ex) {
error("Failed to generate GeneratedWebRepository!", processingEnv);
error(ExceptionUtils.getStackTrace(ex), processingEnv);
return false;
}
}
private void createClass() throws JClassAlreadyExistsException {
generatedWebRepositoryClass = codeModel._class(JMod.PUBLIC | JMod.ABSTRACT, "com.github.webdriverextensions.generator.GeneratedWebRepository", ClassType.CLASS);
generatedWebRepositoryClass._extends(codeModel.ref(WebRepository.class));
}
private void createFields() {
// Declare WebSites
for (TypeElement webSiteElement : webSiteElements) {
JClass webSiteClass = codeModel.ref(webSiteElement.getQualifiedName().toString()); | generatedWebRepositoryClass.field(JMod.PUBLIC, webSiteClass, getFieldName(webSiteElement)); |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
| import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; | @FindBy(css = "#floatnumber-input")
public WebElement floatNumberInput;
// Select/Options
@FindBy(css = "#select")
public WebElement select;
@FindBy(css = "#select option[value='option1value']")
public WebElement selectOption1;
@FindBy(css = "#select option[value='option2value']")
public WebElement selectOption2;
@FindBy(css = "#select option[value='option3value']")
public WebElement selectOption3;
@FindBy(css = "#select option")
public List<WebElement> selectAllOption;
@FindBy(css = "#multiple-select")
public WebElement multipleSelect;
@FindBy(css = "#multiple-select option[value='option1value']")
public WebElement multipleSelectOption1;
@FindBy(css = "#multiple-select option[value='option2value']")
public WebElement multipleSelectOption2;
@FindBy(css = "#multiple-select option[value='option3value']")
public WebElement multipleSelectOption3;
// Checkboxes
@FindBy(css = "#checkbox1")
public WebElement checkbox1;
@FindBy(css = "#checkbox2")
public WebElement checkbox2;
@FindBy(css = "#checkbox2") | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
// Path: src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java
import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@FindBy(css = "#floatnumber-input")
public WebElement floatNumberInput;
// Select/Options
@FindBy(css = "#select")
public WebElement select;
@FindBy(css = "#select option[value='option1value']")
public WebElement selectOption1;
@FindBy(css = "#select option[value='option2value']")
public WebElement selectOption2;
@FindBy(css = "#select option[value='option3value']")
public WebElement selectOption3;
@FindBy(css = "#select option")
public List<WebElement> selectAllOption;
@FindBy(css = "#multiple-select")
public WebElement multipleSelect;
@FindBy(css = "#multiple-select option[value='option1value']")
public WebElement multipleSelectOption1;
@FindBy(css = "#multiple-select option[value='option2value']")
public WebElement multipleSelectOption2;
@FindBy(css = "#multiple-select option[value='option3value']")
public WebElement multipleSelectOption3;
// Checkboxes
@FindBy(css = "#checkbox1")
public WebElement checkbox1;
@FindBy(css = "#checkbox2")
public WebElement checkbox2;
@FindBy(css = "#checkbox2") | public WebComponentExtended checkBox2WebComponentExtended; |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
| import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; | public WebElement checkbox1;
@FindBy(css = "#checkbox2")
public WebElement checkbox2;
@FindBy(css = "#checkbox2")
public WebComponentExtended checkBox2WebComponentExtended;
// Radiobuttons
@FindBy(css = "#radiobutton1")
public WebElement radiobutton1;
@FindBy(css = "#radiobutton2")
public WebElement radiobutton2;
// Attributes
@FindBy(css = "#prefixidsuffix")
public WebElement attributesSpan;
// Appended Span
@FindBy(css = "#firstappended-span")
public WebElement firstAppendedSpan;
@FindBy(css = "#secondappended-span")
public WebElement secondAppendedSpan;
@FindBy(css = ".appended-span")
public List<WebElement> appendedSpans;
// scrollTo
@FindBy(css = "#scroll-to")
public WebElement webElementToScrollTo;
// scrollTo
@FindBy(css = "#scroll-to") | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
// Path: src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java
import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public WebElement checkbox1;
@FindBy(css = "#checkbox2")
public WebElement checkbox2;
@FindBy(css = "#checkbox2")
public WebComponentExtended checkBox2WebComponentExtended;
// Radiobuttons
@FindBy(css = "#radiobutton1")
public WebElement radiobutton1;
@FindBy(css = "#radiobutton2")
public WebElement radiobutton2;
// Attributes
@FindBy(css = "#prefixidsuffix")
public WebElement attributesSpan;
// Appended Span
@FindBy(css = "#firstappended-span")
public WebElement firstAppendedSpan;
@FindBy(css = "#secondappended-span")
public WebElement secondAppendedSpan;
@FindBy(css = ".appended-span")
public List<WebElement> appendedSpans;
// scrollTo
@FindBy(css = "#scroll-to")
public WebElement webElementToScrollTo;
// scrollTo
@FindBy(css = "#scroll-to") | public ScrollTo webComponentToScrollTo; |
webdriverextensions/webdriverextensions | src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
| import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; | @FindBy(css = "#radiobutton2")
public WebElement radiobutton2;
// Attributes
@FindBy(css = "#prefixidsuffix")
public WebElement attributesSpan;
// Appended Span
@FindBy(css = "#firstappended-span")
public WebElement firstAppendedSpan;
@FindBy(css = "#secondappended-span")
public WebElement secondAppendedSpan;
@FindBy(css = ".appended-span")
public List<WebElement> appendedSpans;
// scrollTo
@FindBy(css = "#scroll-to")
public WebElement webElementToScrollTo;
// scrollTo
@FindBy(css = "#scroll-to")
public ScrollTo webComponentToScrollTo;
@Override
public void open(Object... arguments) {
getDriver().get(url);
}
@Override
public void assertIsOpen(Object... arguments) throws AssertionError { | // Path: src/main/java/com/github/webdriverextensions/Bot.java
// public static void assertIsDisplayed(WebElement webElement) {
// if (isNotDisplayed(webElement)) {
// throw new WebAssertionError("Element is not displayed", webElement);
// }
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebDriverExtensionsContext.java
// public class WebDriverExtensionsContext {
//
// private static InheritableThreadLocal<WebDriver> threadLocalDriver = new InheritableThreadLocal<>();
//
// public static WebDriver getDriver() {
// if (threadLocalDriver.get() == null) {
// throw new WebDriverExtensionException("Driver in WebDriverExtensionsContext is not set. Please set the driver with WebDriverExtensionsContext.setDriver(...) method before using the WebDriverExtensions framework. Note that the driver will be thread safe since ThreadLocal is used so don't worry about thread safety.");
// }
// return threadLocalDriver.get();
// }
//
// public static void removeDriver() {
// threadLocalDriver.remove();
// }
//
// public static void setDriver(WebDriver driver) {
// threadLocalDriver.set(driver);
// }
//
// }
//
// Path: src/main/java/com/github/webdriverextensions/WebPage.java
// public abstract class WebPage implements Openable {
//
// public void initElements() {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(WebDriverExtensionsContext.getDriver()), this);
// }
//
// public void initElements(WebDriver driver) {
// PageFactory.initElements(new WebDriverExtensionFieldDecorator(driver), this);
// }
//
// public void initElements(FieldDecorator decorator) {
// PageFactory.initElements(decorator, this);
// }
//
// @Override
// public abstract void open(Object... arguments);
//
// @Override
// public boolean isOpen(Object... arguments) {
// try {
// assertIsOpen(arguments);
// return true;
// } catch (AssertionError e) {
// return false;
// }
// }
//
// @Override
// public boolean isNotOpen(Object... arguments) {
// return !isOpen(arguments);
// }
//
// @Override
// public abstract void assertIsOpen(Object... arguments) throws AssertionError;
//
// @Override
// public void assertIsNotOpen(Object... arguments) throws AssertionError {
// if (isOpen(arguments)) {
// throw new AssertionError(this.getClass().getSimpleName() + " is open when it shouldn't");
// }
// }
//
//
//
// // WORKAROUND: Make Bot methods visible that are otherwise hidden when using static import
// public void open(String url) {
// Bot.open(url);
// }
//
// public void open(Openable openable, Object... arguments) {
// Bot.open(openable, arguments);
// }
//
// public boolean isOpen(Openable openable, Object... arguments) {
// return Bot.isOpen(openable, arguments);
// }
//
// public boolean isNotOpen(Openable openable, Object... arguments) {
// return Bot.isNotOpen(openable, arguments);
// }
//
// public void assertIsOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsOpen(openable, arguments);
// }
//
// public void assertIsNotOpen(Openable openable, Object... arguments) throws AssertionError {
// Bot.assertIsNotOpen(openable, arguments);
// }
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/ScrollTo.java
// public class ScrollTo extends WebComponent {
//
// }
//
// Path: src/test/java/com/github/webdriverextensions/model/components/WebComponentExtended.java
// public class WebComponentExtended extends WebComponent {
//
// }
// Path: src/test/java/com/github/webdriverextensions/model/pages/BotTestPage.java
import java.util.List;
import static com.github.webdriverextensions.Bot.assertIsDisplayed;
import static com.github.webdriverextensions.WebDriverExtensionsContext.*;
import com.github.webdriverextensions.WebPage;
import com.github.webdriverextensions.model.components.ScrollTo;
import com.github.webdriverextensions.model.components.WebComponentExtended;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@FindBy(css = "#radiobutton2")
public WebElement radiobutton2;
// Attributes
@FindBy(css = "#prefixidsuffix")
public WebElement attributesSpan;
// Appended Span
@FindBy(css = "#firstappended-span")
public WebElement firstAppendedSpan;
@FindBy(css = "#secondappended-span")
public WebElement secondAppendedSpan;
@FindBy(css = ".appended-span")
public List<WebElement> appendedSpans;
// scrollTo
@FindBy(css = "#scroll-to")
public WebElement webElementToScrollTo;
// scrollTo
@FindBy(css = "#scroll-to")
public ScrollTo webComponentToScrollTo;
@Override
public void open(Object... arguments) {
getDriver().get(url);
}
@Override
public void assertIsOpen(Object... arguments) throws AssertionError { | assertIsDisplayed(textSpan); |
iliasbartolini/AgileDayConferenceApp | AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java | // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
| /*
Copyright 2010
Author: Gian Marco Gherardi
Author: Ilias Bartolini
Author: Luigi Bozzo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package it.agileday.ui.twitter;
public class TwitterActivity extends ListActivity implements OnScrollListener {
private static final String TAG = TwitterActivity.class.getName();
| // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
// Path: AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
/*
Copyright 2010
Author: Gian Marco Gherardi
Author: Ilias Bartolini
Author: Luigi Bozzo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package it.agileday.ui.twitter;
public class TwitterActivity extends ListActivity implements OnScrollListener {
private static final String TAG = TwitterActivity.class.getName();
| private TweetRepository repository;
|
iliasbartolini/AgileDayConferenceApp | AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java | // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
| /*
Copyright 2010
Author: Gian Marco Gherardi
Author: Ilias Bartolini
Author: Luigi Bozzo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package it.agileday.ui.twitter;
public class TwitterActivity extends ListActivity implements OnScrollListener {
private static final String TAG = TwitterActivity.class.getName();
private TweetRepository repository;
private TweetsAdapter adapter;
private GetTweetsTask task;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.twitter);
| // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
// Path: AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
/*
Copyright 2010
Author: Gian Marco Gherardi
Author: Ilias Bartolini
Author: Luigi Bozzo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package it.agileday.ui.twitter;
public class TwitterActivity extends ListActivity implements OnScrollListener {
private static final String TAG = TwitterActivity.class.getName();
private TweetRepository repository;
private TweetsAdapter adapter;
private GetTweetsTask task;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.twitter);
| repository = new TweetRepository(getResources().getString(R.string.hash_tag), new BitmapCache());
|
iliasbartolini/AgileDayConferenceApp | AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java | // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
|
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
Log.i(TAG, "onScroll(firstVisibleItem=" + firstVisibleItem + ", visibleItemCount=" + visibleItemCount + ", totalItemCount=" + totalItemCount + ")");
boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;
if (loadMore && repository.hasNextPage()) {
loadTweets();
}
}
private void loadTweets() {
Log.i(TAG, "loadTweets");
synchronized (this) {
if (task == null) {
task = new GetTweetsTask();
adapter.addLoadingRow();
adapter.notifyDataSetChanged();
task.execute();
}
}
}
private Context getContext() {
return this;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
| // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
// Path: AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
Log.i(TAG, "onScroll(firstVisibleItem=" + firstVisibleItem + ", visibleItemCount=" + visibleItemCount + ", totalItemCount=" + totalItemCount + ")");
boolean loadMore = firstVisibleItem + visibleItemCount >= totalItemCount;
if (loadMore && repository.hasNextPage()) {
loadTweets();
}
}
private void loadTweets() {
Log.i(TAG, "loadTweets");
synchronized (this) {
if (task == null) {
task = new GetTweetsTask();
adapter.addLoadingRow();
adapter.notifyDataSetChanged();
task.execute();
}
}
}
private Context getContext() {
return this;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
| private class GetTweetsTask extends AsyncTask<Void, Void, List<Tweet>> {
|
iliasbartolini/AgileDayConferenceApp | AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java | // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
| import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
| if (loadMore && repository.hasNextPage()) {
loadTweets();
}
}
private void loadTweets() {
Log.i(TAG, "loadTweets");
synchronized (this) {
if (task == null) {
task = new GetTweetsTask();
adapter.addLoadingRow();
adapter.notifyDataSetChanged();
task.execute();
}
}
}
private Context getContext() {
return this;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
private class GetTweetsTask extends AsyncTask<Void, Void, List<Tweet>> {
private Throwable exception = null;
@Override
protected List<Tweet> doInBackground(Void... params) {
| // Path: AgileDayConferenceApp/src/it/agileday/utils/BitmapCache.java
// public class BitmapCache {
// private static final String TAG = BitmapCache.class.getName();
//
// private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>();
//
// public Bitmap get(String url) {
// if (!cache.containsKey(url)) {
// cache.put(url, HttpRestUtil.httpGetBitmap(url));
// Log.i(TAG, "Bitmap loaded: " + url);
// }
// return cache.get(url);
// }
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/Tweet.java
// public class Tweet {
// public long id;
// public String text;
// public String fromUser;
// public Bitmap profileImage;
// public Date date;
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetList.java
// public class TweetList extends ArrayList<Tweet> implements List<Tweet> {
// private static final long serialVersionUID = 1L;
// private static TweetList empty = new TweetList(0);
//
// public TweetList(int length) {
// super(length);
// }
//
// public static TweetList Empty() {
// return empty;
// }
//
// }
//
// Path: AgileDayConferenceApp/src/it/agileday/data/TweetRepository.java
// public class TweetRepository {
// @SuppressWarnings("unused")
// private static final String TAG = TweetRepository.class.getName();
// private static final String URL = "http://search.twitter.com/search.json";
//
// private String nextPageQueryString;
// private final BitmapCache bitmapCache;
//
// public TweetRepository(String hashTag, BitmapCache bitmapCache) {
// this.nextPageQueryString = "?result_type=recent&rpp=10&q=" + URLEncoder.encode(hashTag);
// this.bitmapCache = bitmapCache;
// }
//
// public TweetList getNextPage() {
//
// if (!hasNextPage())
// return TweetList.Empty();
//
// JSONObject json = HttpRestUtil.httpGetJsonObject(String.format("%s%s", URL, nextPageQueryString));
//
// nextPageQueryString = json.optString("next_page", null);
//
// try {
// return fromJson(json.getJSONArray("results"));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public boolean hasNextPage() {
// return nextPageQueryString != null;
// }
//
// private TweetList fromJson(JSONArray ary) throws Exception {
// TweetList tweets = new TweetList(ary.length());
// for (int i = 0; i < ary.length(); i++) {
// tweets.add(buildTweet(ary.getJSONObject(i)));
// }
// return tweets;
// }
//
// public Tweet buildTweet(JSONObject json) {
// Tweet ret = new Tweet();
// try {
// ret.id = json.getLong("id");
// ret.text = json.getString("text");
// ret.fromUser = json.getString("from_user");
// ret.date = Dates.fromTweeterString(json.getString("created_at"));
// ret.profileImage = bitmapCache.get(json.getString("profile_image_url"));
// } catch (JSONException e) {
// throw new RuntimeException(e);
// }
// return ret;
// }
//
// }
// Path: AgileDayConferenceApp/src/it/agileday/ui/twitter/TwitterActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Toast;
import it.agileday2011.R;
import it.agileday.utils.BitmapCache;
import it.agileday.data.Tweet;
import it.agileday.data.TweetList;
import it.agileday.data.TweetRepository;
import java.util.List;
import android.app.ListActivity;
import android.content.Context;
if (loadMore && repository.hasNextPage()) {
loadTweets();
}
}
private void loadTweets() {
Log.i(TAG, "loadTweets");
synchronized (this) {
if (task == null) {
task = new GetTweetsTask();
adapter.addLoadingRow();
adapter.notifyDataSetChanged();
task.execute();
}
}
}
private Context getContext() {
return this;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
private class GetTweetsTask extends AsyncTask<Void, Void, List<Tweet>> {
private Throwable exception = null;
@Override
protected List<Tweet> doInBackground(Void... params) {
| TweetList ret = null;
|
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest | @DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public class UpdateTearDownOnClassTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public class UpdateTearDownOnClassTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public class UpdateTearDownOnClassTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
public void test() throws Exception { | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnClassTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public class UpdateTearDownOnClassTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
public void test() throws Exception { | List<InventoryCategory> categories = inventoryRepository.findAll(); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | @DatabaseTearDown(value = "../refresh-db.xml", type = DatabaseOperation.REFRESH) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../refresh-db.xml", type = DatabaseOperation.REFRESH)
public void test() throws Exception { | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/RefreshTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class RefreshTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../refresh-db.xml", type = DatabaseOperation.REFRESH)
public void test() throws Exception { | List<InventoryCategory> categories = inventoryRepository.findAll(); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | @DatabaseSetup(value = "../truncate-db.xml", type = DatabaseOperation.TRUNCATE_TABLE) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseSetup(value = "../truncate-db.xml", type = DatabaseOperation.TRUNCATE_TABLE)
public void test() throws Exception {
List<String> names = inventoryRepository.findAllNames();
assertThat(names, contains("existing_category")); | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/TruncateSetupOnMethodTest.java
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class TruncateSetupOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseSetup(value = "../truncate-db.xml", type = DatabaseOperation.TRUNCATE_TABLE)
public void test() throws Exception {
List<String> names = inventoryRepository.findAllNames();
assertThat(names, contains("existing_category")); | InventoryCategory category = inventoryRepository.findByName("existing_category"); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class) | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class) | @DbUnitConfiguration(dataSetLoader = JsonDataSetLoader.class) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DbUnitConfiguration(dataSetLoader = JsonDataSetLoader.class)
@DatabaseTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DbUnitConfiguration(dataSetLoader = JsonDataSetLoader.class)
@DatabaseTest | @ExpectedDatabase(value = "../expected_fail.json", assertionMode = DatabaseAssertionMode.NON_STRICT) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DbUnitConfiguration(dataSetLoader = JsonDataSetLoader.class)
@DatabaseTest
@ExpectedDatabase(value = "../expected_fail.json", assertionMode = DatabaseAssertionMode.NON_STRICT)
public class ExpectedFailureOnClassJsonTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/JsonDataSetLoader.java
// public class JsonDataSetLoader extends AbstractDataSetLoader {
//
// @Override
// protected IDataSet createDataSet(URL resourceUrl) throws Exception {
// return new JsonDataSet(resourceUrl.openStream());
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassJsonTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DbUnitConfiguration;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.JsonDataSetLoader;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DbUnitConfiguration(dataSetLoader = JsonDataSetLoader.class)
@DatabaseTest
@ExpectedDatabase(value = "../expected_fail.json", assertionMode = DatabaseAssertionMode.NON_STRICT)
public class ExpectedFailureOnClassJsonTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit-sample/src/test/java/com/github/deltaspikedbunit/sample/inventory/service/InventoryServiceTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.sample.inventory.entity.*;
import com.github.deltaspikedbunit.deltaspike.*;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | package com.github.deltaspikedbunit.sample.inventory.service;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup("../setup-db.xml")
public class InventoryServiceTest {
@Inject
private InventoryService inventoryService;
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
// Path: deltaspike-dbunit-sample/src/test/java/com/github/deltaspikedbunit/sample/inventory/service/InventoryServiceTest.java
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.sample.inventory.entity.*;
import com.github.deltaspikedbunit.deltaspike.*;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
package com.github.deltaspikedbunit.sample.inventory.service;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup("../setup-db.xml")
public class InventoryServiceTest {
@Inject
private InventoryService inventoryService;
@Test | @ExpectedDatabase(value = "../setup-db.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest | @DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.DELETE_ALL) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.DELETE_ALL)
public class DeleteAllTearDownOnClassTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.DELETE_ALL)
public class DeleteAllTearDownOnClassTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.DELETE_ALL)
public class DeleteAllTearDownOnClassTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
public void test() throws Exception { | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/DeleteAllTearDownOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.DELETE_ALL)
public class DeleteAllTearDownOnClassTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
public void test() throws Exception { | List<InventoryCategory> categories = inventoryRepository.findAll(); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/ExpectedDatabase.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/DataSetModifier.java
// public interface DataSetModifier {
//
// /**
// * No-op {@link DataSetModifier}.
// */
// public static final DataSetModifier NONE = new DataSetModifier() {
//
// public IDataSet modify(IDataSet dataSet) {
// return dataSet;
// }
//
// };
//
// /**
// * Modifies the given {@link IDataSet}, for example by wrapping it with a {@link ReplacementDataSet}.
// *
// * @param dataSet the {@link IDataSet} to modify
// * @return the modified {@link IDataSet}
// */
// IDataSet modify(IDataSet dataSet);
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.DataSetModifier;
import org.dbunit.dataset.IDataSet; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.annotation;
/**
* Asserts that a database is in given state after tests have run.
*
* @author Luigi Bitonti
* @author Phillip Webb
* @author Mario Zagar
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface ExpectedDatabase {
/**
* Provides the location of the dataset that will be used to test the database.
* Locations are relative to the class under test.
*
* @return The dataset location
* @see DbUnitConfiguration#dataSetLoader()
*/
String value() default "";
/**
* Database assertion mode to use. Default is {@link DatabaseAssertionMode#DEFAULT}.
*
* @return Database assertion mode to use
*/ | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/DataSetModifier.java
// public interface DataSetModifier {
//
// /**
// * No-op {@link DataSetModifier}.
// */
// public static final DataSetModifier NONE = new DataSetModifier() {
//
// public IDataSet modify(IDataSet dataSet) {
// return dataSet;
// }
//
// };
//
// /**
// * Modifies the given {@link IDataSet}, for example by wrapping it with a {@link ReplacementDataSet}.
// *
// * @param dataSet the {@link IDataSet} to modify
// * @return the modified {@link IDataSet}
// */
// IDataSet modify(IDataSet dataSet);
//
// }
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/ExpectedDatabase.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.DataSetModifier;
import org.dbunit.dataset.IDataSet;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.annotation;
/**
* Asserts that a database is in given state after tests have run.
*
* @author Luigi Bitonti
* @author Phillip Webb
* @author Mario Zagar
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface ExpectedDatabase {
/**
* Provides the location of the dataset that will be used to test the database.
* Locations are relative to the class under test.
*
* @return The dataset location
* @see DbUnitConfiguration#dataSetLoader()
*/
String value() default "";
/**
* Database assertion mode to use. Default is {@link DatabaseAssertionMode#DEFAULT}.
*
* @return Database assertion mode to use
*/ | DatabaseAssertionMode assertionMode() default DatabaseAssertionMode.DEFAULT; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/ExpectedDatabase.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/DataSetModifier.java
// public interface DataSetModifier {
//
// /**
// * No-op {@link DataSetModifier}.
// */
// public static final DataSetModifier NONE = new DataSetModifier() {
//
// public IDataSet modify(IDataSet dataSet) {
// return dataSet;
// }
//
// };
//
// /**
// * Modifies the given {@link IDataSet}, for example by wrapping it with a {@link ReplacementDataSet}.
// *
// * @param dataSet the {@link IDataSet} to modify
// * @return the modified {@link IDataSet}
// */
// IDataSet modify(IDataSet dataSet);
//
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.DataSetModifier;
import org.dbunit.dataset.IDataSet; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.annotation;
/**
* Asserts that a database is in given state after tests have run.
*
* @author Luigi Bitonti
* @author Phillip Webb
* @author Mario Zagar
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface ExpectedDatabase {
/**
* Provides the location of the dataset that will be used to test the database.
* Locations are relative to the class under test.
*
* @return The dataset location
* @see DbUnitConfiguration#dataSetLoader()
*/
String value() default "";
/**
* Database assertion mode to use. Default is {@link DatabaseAssertionMode#DEFAULT}.
*
* @return Database assertion mode to use
*/
DatabaseAssertionMode assertionMode() default DatabaseAssertionMode.DEFAULT;
/**
* Optional table name that can be used to limit the comparison to a specific table.
*
* @return the table name
*/
String table() default "";
/**
* Optional SQL to retrieve the actual subset of the table rows from the database. NOTE: a {@link #table() table
* name} must also be specified when using a query.
*
* @return the SQL Query
*/
String query() default "";
/**
* If this expectation overrides any others that have been defined at a higher level. Defaults to {@code true}
* @return if this annotation overrides any others
*/
boolean override() default true;
/**
* A set of {@link DataSetModifier} that will be applied to the {@link IDataSet} before it is used. Can refer to a
* static or inner class of the test.
*
* @return the modifiers to apply
*/ | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/dataset/DataSetModifier.java
// public interface DataSetModifier {
//
// /**
// * No-op {@link DataSetModifier}.
// */
// public static final DataSetModifier NONE = new DataSetModifier() {
//
// public IDataSet modify(IDataSet dataSet) {
// return dataSet;
// }
//
// };
//
// /**
// * Modifies the given {@link IDataSet}, for example by wrapping it with a {@link ReplacementDataSet}.
// *
// * @param dataSet the {@link IDataSet} to modify
// * @return the modified {@link IDataSet}
// */
// IDataSet modify(IDataSet dataSet);
//
// }
// Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/ExpectedDatabase.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.dataset.DataSetModifier;
import org.dbunit.dataset.IDataSet;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.annotation;
/**
* Asserts that a database is in given state after tests have run.
*
* @author Luigi Bitonti
* @author Phillip Webb
* @author Mario Zagar
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface ExpectedDatabase {
/**
* Provides the location of the dataset that will be used to test the database.
* Locations are relative to the class under test.
*
* @return The dataset location
* @see DbUnitConfiguration#dataSetLoader()
*/
String value() default "";
/**
* Database assertion mode to use. Default is {@link DatabaseAssertionMode#DEFAULT}.
*
* @return Database assertion mode to use
*/
DatabaseAssertionMode assertionMode() default DatabaseAssertionMode.DEFAULT;
/**
* Optional table name that can be used to limit the comparison to a specific table.
*
* @return the table name
*/
String table() default "";
/**
* Optional SQL to retrieve the actual subset of the table rows from the database. NOTE: a {@link #table() table
* name} must also be specified when using a query.
*
* @return the SQL Query
*/
String query() default "";
/**
* If this expectation overrides any others that have been defined at a higher level. Defaults to {@code true}
* @return if this annotation overrides any others
*/
boolean override() default true;
/**
* A set of {@link DataSetModifier} that will be applied to the {@link IDataSet} before it is used. Can refer to a
* static or inner class of the test.
*
* @return the modifiers to apply
*/ | Class<? extends DataSetModifier>[] modifiers() default {}; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/MultipleInsertSetupOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/MultipleInsertSetupOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest | @DatabaseSetup(value = {"../setup-db.xml","../extra_category_with_items.xml"}, type = DatabaseOperation.INSERT) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/MultipleInsertSetupOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup(value = {"../setup-db.xml","../extra_category_with_items.xml"}, type = DatabaseOperation.INSERT)
public class MultipleInsertSetupOnClassTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/MultipleInsertSetupOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup(value = {"../setup-db.xml","../extra_category_with_items.xml"}, type = DatabaseOperation.INSERT)
public class MultipleInsertSetupOnClassTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/DeleteSetupOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/DeleteSetupOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest | @DatabaseSetup(value = "../setup-db.xml", type = DatabaseOperation.DELETE) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/DeleteSetupOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup(value = "../setup-db.xml", type = DatabaseOperation.DELETE)
public class DeleteSetupOnClassTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/setup/DeleteSetupOnClassTest.java
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseSetup;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.setup;
@RunWith(CdiTestRunner.class)
@DatabaseTest
@DatabaseSetup(value = "../setup-db.xml", type = DatabaseOperation.DELETE)
public class DeleteSetupOnClassTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | @DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public void test() throws Exception { | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/UpdateTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class UpdateTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../update-db.xml", type = DatabaseOperation.UPDATE)
public void test() throws Exception { | List<InventoryCategory> categories = inventoryRepository.findAll(); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedQueryNonStrictOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class ExpectedQueryNonStrictOnMethodTest {
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedQueryNonStrictOnMethodTest.java
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@DatabaseTest
public class ExpectedQueryNonStrictOnMethodTest {
@Test | @ExpectedDatabase(value = "../expected_query_nonstrict.xml", assertionMode = DatabaseAssertionMode.NON_STRICT, |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test | @DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.CLEAN_INSERT) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.CLEAN_INSERT)
public void test() throws Exception {
List<String> names = inventoryRepository.findAllNames();
assertThat(names, contains("existing_category"));
}
@After
public void afterTest() throws Exception { | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/entity/InventoryCategory.java
// @Entity
// @Table(name = "inventory_category")
// public class InventoryCategory {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// @Version
// @Column(name = "version")
// private int version;
// @Column(name = "category_name", nullable = false, unique = true)
// private String categoryName;
// @Column(name = "category_description")
// private String categoryDescription;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "category")
// private Set<InventoryItem> items = new HashSet<>();
//
//
// public InventoryCategory() {
// }
//
// public InventoryCategory(String categoryName, String categoryDescription) {
// this.categoryName = categoryName;
// this.categoryDescription = categoryDescription;
// }
//
//
// public String getCategoryName() {
// return categoryName;
// }
// public void setCategoryName(String name) {
// this.categoryName = name;
// }
//
// public String getCategoryDescription() {
// return categoryDescription;
// }
// public void setCategoryDescription(String description) {
// this.categoryDescription = description;
// }
//
// int getVersion() {
// return version;
// }
// void setVersion(int version) {
// this.version = version;
// }
//
// public int getId() {
// return id;
// }
// void setId(int id) {
// this.id = id;
// }
//
// public Set<InventoryItem> getItems() {
// return items;
// }
// void setItems(Set<InventoryItem> items) {
// this.items = items;
// }
//
// public void addItem(InventoryItem item) {
// if (item != null) {
// this.items.add(item);
// item.setCategory(this);
// }
// }
//
// public void addItems(InventoryItem... items) {
// if (items != null) {
// for (InventoryItem ii : items) {
// addItem(ii);
// }
// }
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/teardown/CleanInsertTearDownOnMethodTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
import com.github.deltaspikedbunit.annotation.DatabaseTearDown;
import com.github.deltaspikedbunit.deltaspike.DatabaseNoRollbackTest;
import com.github.deltaspikedbunit.sample.inventory.entity.InventoryCategory;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.teardown;
@RunWith(CdiTestRunner.class)
@DatabaseNoRollbackTest
public class CleanInsertTearDownOnMethodTest {
@Inject
private InventoryCategoryRepository inventoryRepository;
@Test
@DatabaseTearDown(value = "../setup-db.xml", type = DatabaseOperation.CLEAN_INSERT)
public void test() throws Exception {
List<String> names = inventoryRepository.findAllNames();
assertThat(names, contains("existing_category"));
}
@After
public void afterTest() throws Exception { | List<InventoryCategory> categories = inventoryRepository.findAll(); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/operation/DefaultDatabaseOperationLookupTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
| import static org.junit.Assert.assertSame;
import org.junit.Test;
import com.github.deltaspikedbunit.annotation.DatabaseOperation; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.operation;
/**
* Tests for {@link DefaultDatabaseOperationLookup}.
*
* @author Luigi Bitonti
* @author Phillip Webb
*/
public class DefaultDatabaseOperationLookupTest {
@Test
public void shouldLookup() throws Exception {
DefaultDatabaseOperationLookup lookup = new DefaultDatabaseOperationLookup(); | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/annotation/DatabaseOperation.java
// public enum DatabaseOperation {
//
// /**
// * Updates the contents of existing database tables from the dataset.
// */
// UPDATE,
//
// /**
// * Inserts new database tables and contents from the dataset.
// */
// INSERT,
//
// /**
// * Refresh the contents of existing database tables. Rows from the dataset will insert or replace existing data. Any
// * database rows that are not in the dataset remain unaffected.
// */
// REFRESH,
//
// /**
// * Deletes database table rows that match rows from the dataset.
// */
// DELETE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset remain unaffected.
// * @see #TRUNCATE_TABLE
// */
// DELETE_ALL,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset. Tables in the database but not
// * in the dataset are unaffected. Identical to {@link #DELETE_ALL} except this operation cannot be rolled back and
// * is supported by less database vendors.
// * @see #DELETE_ALL
// */
// TRUNCATE_TABLE,
//
// /**
// * Deletes all rows from a database table when the table is specified in the dataset and subsequently insert new
// * contents. Equivalent to calling {@link #DELETE_ALL} followed by {@link #INSERT}.
// */
// CLEAN_INSERT
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/operation/DefaultDatabaseOperationLookupTest.java
import static org.junit.Assert.assertSame;
import org.junit.Test;
import com.github.deltaspikedbunit.annotation.DatabaseOperation;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.operation;
/**
* Tests for {@link DefaultDatabaseOperationLookup}.
*
* @author Luigi Bitonti
* @author Phillip Webb
*/
public class DefaultDatabaseOperationLookupTest {
@Test
public void shouldLookup() throws Exception {
DefaultDatabaseOperationLookup lookup = new DefaultDatabaseOperationLookup(); | assertSame(org.dbunit.operation.DatabaseOperation.UPDATE, lookup.get(DatabaseOperation.UPDATE)); |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DatabaseTest | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassTest.java
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DatabaseTest | @ExpectedDatabase(value = "../expected_fail.xml", assertionMode = DatabaseAssertionMode.NON_STRICT) |
lbitonti/deltaspike-dbunit | deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassTest.java | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
| import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat; | /*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DatabaseTest
@ExpectedDatabase(value = "../expected_fail.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
public class ExpectedFailureOnClassTest {
@Inject | // Path: deltaspike-dbunit/src/main/java/com/github/deltaspikedbunit/assertion/DatabaseAssertionMode.java
// public enum DatabaseAssertionMode {
//
// /**
// * Default DbUnit data sets assertions (i.e. checks all columns and their order).
// */
// DEFAULT(new DefaultDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set. Unspecified tables and columns are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order must match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT(new NonStrictDatabaseAssertion()),
//
// /**
// * Allows specifying only specific columns and tables in expected data set and ignoring row orders in expected and
// * actual data set. Unspecified tables and columns are ignored. Row orders in expected and actual data sets are
// * ignored.
// * <p>
// * <strong>Notes:</strong>
// * <ul>
// * <li>Expected row order does not need to match order in actual data set.</li>
// * <li>Specified columns must match in all rows, e.g. specifying 'column1' value without 'column2' value in one row
// * and only 'column2' value in another is not allowed - both 'column1' and 'column2' values must be specified in all
// * rows.</li>
// * </ul>
// */
// NON_STRICT_UNORDERED(new NonStrictUnorderedDatabaseAssertion());
//
//
// private DatabaseAssertion databaseAssertion;
//
// DatabaseAssertionMode(DatabaseAssertion databaseAssertion) {
// this.databaseAssertion = databaseAssertion;
// }
//
//
// public DatabaseAssertion getDatabaseAssertion() {
// return this.databaseAssertion;
// }
//
// }
//
// Path: deltaspike-dbunit-sample/src/main/java/com/github/deltaspikedbunit/sample/inventory/repository/InventoryCategoryRepository.java
// @Repository
// public abstract class InventoryCategoryRepository extends AbstractEntityRepository<InventoryCategory, Integer> {
//
// @Query(value = "select ic from InventoryCategory ic where ic.categoryName = :categoryName",
// singleResult = SingleResultType.OPTIONAL)
// public abstract InventoryCategory findByName(@QueryParam("categoryName") String categoryName);
//
// }
// Path: deltaspike-dbunit/src/test/java/com/github/deltaspikedbunit/expected/ExpectedFailureOnClassTest.java
import static org.hamcrest.Matchers.contains;
import com.github.deltaspikedbunit.annotation.ExpectedDatabase;
import com.github.deltaspikedbunit.assertion.DatabaseAssertionMode;
import com.github.deltaspikedbunit.deltaspike.DatabaseTest;
import com.github.deltaspikedbunit.sample.inventory.repository.InventoryCategoryRepository;
import com.github.deltaspikedbunit.testutils.ExpectedFailure;
import junit.framework.ComparisonFailure;
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.Inject;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
/*
* Copyright 2002-2015 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.deltaspikedbunit.expected;
@RunWith(CdiTestRunner.class)
@ExpectedFailure(failure = ComparisonFailure.class)
@DatabaseTest
@ExpectedDatabase(value = "../expected_fail.xml", assertionMode = DatabaseAssertionMode.NON_STRICT)
public class ExpectedFailureOnClassTest {
@Inject | private InventoryCategoryRepository inventoryRepository; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.