Build opt 22 06 (#2132)
* Drools reformat * Further refactor * Further refactor * Refactor
This commit is contained in:
parent
38dc2041a1
commit
87049b63f4
|
@ -17,37 +17,39 @@ public class ApplicantServiceIntegrationTest {
|
|||
private ApplicantService applicantService;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
public void setup() {
|
||||
applicantService = new ApplicantService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCriteriaMatching_ThenSuggestManagerRole() throws IOException {
|
||||
Applicant applicant=new Applicant("Davis",37,1600000.0,11);
|
||||
SuggestedRole suggestedRole=new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
|
||||
assertEquals("Manager",suggestedRole.getRole());
|
||||
Applicant applicant = new Applicant("Davis", 37, 1600000.0, 11);
|
||||
SuggestedRole suggestedRole = new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
|
||||
assertEquals("Manager", suggestedRole.getRole());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCriteriaMatching_ThenSuggestSeniorDeveloperRole() throws IOException {
|
||||
Applicant applicant=new Applicant("John",37,1200000.0,8);
|
||||
SuggestedRole suggestedRole=new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
|
||||
assertEquals("Senior developer",suggestedRole.getRole());
|
||||
Applicant applicant = new Applicant("John", 37, 1200000.0, 8);
|
||||
SuggestedRole suggestedRole = new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
|
||||
assertEquals("Senior developer", suggestedRole.getRole());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCriteriaMatching_ThenSuggestDeveloperRole() throws IOException {
|
||||
Applicant applicant=new Applicant("Davis",37,800000.0,3);
|
||||
SuggestedRole suggestedRole=new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
|
||||
assertEquals("Developer",suggestedRole.getRole());
|
||||
Applicant applicant = new Applicant("Davis", 37, 800000.0, 3);
|
||||
SuggestedRole suggestedRole = new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
|
||||
assertEquals("Developer", suggestedRole.getRole());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenCriteriaNotMatching_ThenNoRole() throws IOException {
|
||||
Applicant applicant=new Applicant("John",37,1200000.0,5);
|
||||
SuggestedRole suggestedRole=new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
|
||||
Applicant applicant = new Applicant("John", 37, 1200000.0, 5);
|
||||
SuggestedRole suggestedRole = new SuggestedRole();
|
||||
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
|
||||
assertNull(suggestedRole.getRole());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.baeldung.drools.service;
|
|||
import com.baeldung.drools.model.Product;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
|
||||
|
@ -11,22 +12,22 @@ public class ProductServiceIntegrationTest {
|
|||
private ProductService productService;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
productService=new ProductService();
|
||||
public void setup() {
|
||||
productService = new ProductService();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenProductTypeElectronic_ThenLabelBarcode(){
|
||||
Product product=new Product("Microwave","Electronic");
|
||||
product=productService.applyLabelToProduct(product);
|
||||
assertEquals("BarCode",product.getLabel());
|
||||
public void whenProductTypeElectronic_ThenLabelBarcode() {
|
||||
Product product = new Product("Microwave", "Electronic");
|
||||
product = productService.applyLabelToProduct(product);
|
||||
assertEquals("BarCode", product.getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenProductTypeBook_ThenLabelIsbn(){
|
||||
Product product=new Product("AutoBiography","Book");
|
||||
product=productService.applyLabelToProduct(product);
|
||||
assertEquals("ISBN",product.getLabel());
|
||||
public void whenProductTypeBook_ThenLabelIsbn() {
|
||||
Product product = new Product("AutoBiography", "Book");
|
||||
product = productService.applyLabelToProduct(product);
|
||||
assertEquals("ISBN", product.getLabel());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,21 +13,20 @@ public class AsciidoctorDemo {
|
|||
|
||||
private final Asciidoctor asciidoctor;
|
||||
|
||||
public AsciidoctorDemo() {
|
||||
AsciidoctorDemo() {
|
||||
asciidoctor = create();
|
||||
}
|
||||
|
||||
public void generatePDFFromString(final String input) {
|
||||
|
||||
final Map<String, Object> options = options().inPlace(true)
|
||||
.backend("pdf")
|
||||
.asMap();
|
||||
.backend("pdf")
|
||||
.asMap();
|
||||
|
||||
final String outfile = asciidoctor.convertFile(new File("sample.adoc"), options);
|
||||
}
|
||||
|
||||
public String generateHTMLFromString(final String input) {
|
||||
final String output = asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
|
||||
return output;
|
||||
String generateHTMLFromString(final String input) {
|
||||
return asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,77 +2,78 @@ package com.baeldung.commons.lang3;
|
|||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ArrayUtilsUnitTest {
|
||||
@Test
|
||||
public void givenArray_whenAddingElementAtSpecifiedPosition_thenCorrect() {
|
||||
int[] oldArray = { 2, 3, 4, 5 };
|
||||
int[] oldArray = {2, 3, 4, 5};
|
||||
int[] newArray = ArrayUtils.add(oldArray, 0, 1);
|
||||
int[] expectedArray = { 1, 2, 3, 4, 5 };
|
||||
int[] expectedArray = {1, 2, 3, 4, 5};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenAddingElementAtTheEnd_thenCorrect() {
|
||||
int[] oldArray = { 2, 3, 4, 5 };
|
||||
int[] oldArray = {2, 3, 4, 5};
|
||||
int[] newArray = ArrayUtils.add(oldArray, 1);
|
||||
int[] expectedArray = { 2, 3, 4, 5, 1 };
|
||||
int[] expectedArray = {2, 3, 4, 5, 1};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenAddingAllElementsAtTheEnd_thenCorrect() {
|
||||
int[] oldArray = { 0, 1, 2 };
|
||||
int[] oldArray = {0, 1, 2};
|
||||
int[] newArray = ArrayUtils.addAll(oldArray, 3, 4, 5);
|
||||
int[] expectedArray = { 0, 1, 2, 3, 4, 5 };
|
||||
int[] expectedArray = {0, 1, 2, 3, 4, 5};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenRemovingElementAtSpecifiedPosition_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 3, 4, 5 };
|
||||
int[] oldArray = {1, 2, 3, 4, 5};
|
||||
int[] newArray = ArrayUtils.remove(oldArray, 1);
|
||||
int[] expectedArray = { 1, 3, 4, 5 };
|
||||
int[] expectedArray = {1, 3, 4, 5};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenRemovingAllElementsAtSpecifiedPositions_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 3, 4, 5 };
|
||||
int[] oldArray = {1, 2, 3, 4, 5};
|
||||
int[] newArray = ArrayUtils.removeAll(oldArray, 1, 3);
|
||||
int[] expectedArray = { 1, 3, 5 };
|
||||
int[] expectedArray = {1, 3, 5};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenRemovingAnElement_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 3, 3, 4 };
|
||||
int[] oldArray = {1, 2, 3, 3, 4};
|
||||
int[] newArray = ArrayUtils.removeElement(oldArray, 3);
|
||||
int[] expectedArray = { 1, 2, 3, 4 };
|
||||
int[] expectedArray = {1, 2, 3, 4};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenRemovingElements_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 3, 3, 4 };
|
||||
int[] oldArray = {1, 2, 3, 3, 4};
|
||||
int[] newArray = ArrayUtils.removeElements(oldArray, 2, 3, 5);
|
||||
int[] expectedArray = { 1, 3, 4 };
|
||||
int[] expectedArray = {1, 3, 4};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenRemovingAllElementOccurences_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 2, 2, 3 };
|
||||
int[] oldArray = {1, 2, 2, 2, 3};
|
||||
int[] newArray = ArrayUtils.removeAllOccurences(oldArray, 2);
|
||||
int[] expectedArray = { 1, 3 };
|
||||
int[] expectedArray = {1, 3};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenCheckingExistingElement_thenCorrect() {
|
||||
int[] array = { 1, 3, 5, 7, 9 };
|
||||
int[] array = {1, 3, 5, 7, 9};
|
||||
boolean evenContained = ArrayUtils.contains(array, 2);
|
||||
boolean oddContained = ArrayUtils.contains(array, 7);
|
||||
assertEquals(false, evenContained);
|
||||
|
@ -81,57 +82,57 @@ public class ArrayUtilsUnitTest {
|
|||
|
||||
@Test
|
||||
public void givenArray_whenReversingElementsWithinARange_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.reverse(originalArray, 1, 4);
|
||||
int[] expectedArray = { 1, 4, 3, 2, 5 };
|
||||
int[] expectedArray = {1, 4, 3, 2, 5};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenReversingAllElements_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.reverse(originalArray);
|
||||
int[] expectedArray = { 5, 4, 3, 2, 1 };
|
||||
int[] expectedArray = {5, 4, 3, 2, 1};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenShiftingElementsWithinARange_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.shift(originalArray, 1, 4, 1);
|
||||
int[] expectedArray = { 1, 4, 2, 3, 5 };
|
||||
int[] expectedArray = {1, 4, 2, 3, 5};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenShiftingAllElements_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.shift(originalArray, 1);
|
||||
int[] expectedArray = { 5, 1, 2, 3, 4 };
|
||||
int[] expectedArray = {5, 1, 2, 3, 4};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenExtractingElements_thenCorrect() {
|
||||
int[] oldArray = { 1, 2, 3, 4, 5 };
|
||||
int[] oldArray = {1, 2, 3, 4, 5};
|
||||
int[] newArray = ArrayUtils.subarray(oldArray, 2, 7);
|
||||
int[] expectedArray = { 3, 4, 5 };
|
||||
int[] expectedArray = {3, 4, 5};
|
||||
assertArrayEquals(expectedArray, newArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenSwapingElementsWithinARange_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.swap(originalArray, 0, 3, 2);
|
||||
int[] expectedArray = { 4, 5, 3, 1, 2 };
|
||||
int[] expectedArray = {4, 5, 3, 1, 2};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenSwapingElementsAtSpecifiedPositions_thenCorrect() {
|
||||
int[] originalArray = { 1, 2, 3, 4, 5 };
|
||||
int[] originalArray = {1, 2, 3, 4, 5};
|
||||
ArrayUtils.swap(originalArray, 0, 3);
|
||||
int[] expectedArray = { 4, 2, 3, 1, 5 };
|
||||
int[] expectedArray = {4, 2, 3, 1, 5};
|
||||
assertArrayEquals(expectedArray, originalArray);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ public class ComplexUnitTest {
|
|||
|
||||
@Test
|
||||
public void whenComplexPow_thenCorrect() {
|
||||
Complex first = new Complex(1.0, 3.0);
|
||||
Complex first = new Complex(1.0, 3.0);
|
||||
Complex second = new Complex(2.0, 5.0);
|
||||
|
||||
Complex power = first.pow(second);
|
||||
|
|
|
@ -35,9 +35,9 @@ public class WordCountIntegrationTest {
|
|||
//then
|
||||
List<Tuple2<String, Integer>> collect = result.collect();
|
||||
assertThat(collect).containsExactlyInAnyOrder(
|
||||
new Tuple2<>("a", 3), new Tuple2<>("sentence", 2), new Tuple2<>("word", 1),
|
||||
new Tuple2<>("is", 2), new Tuple2<>("this", 2), new Tuple2<>("second", 1),
|
||||
new Tuple2<>("first", 1), new Tuple2<>("with", 1), new Tuple2<>("one", 1));
|
||||
new Tuple2<>("a", 3), new Tuple2<>("sentence", 2), new Tuple2<>("word", 1),
|
||||
new Tuple2<>("is", 2), new Tuple2<>("this", 2), new Tuple2<>("second", 1),
|
||||
new Tuple2<>("first", 1), new Tuple2<>("with", 1), new Tuple2<>("one", 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,9 +48,9 @@ public class WordCountIntegrationTest {
|
|||
|
||||
//when
|
||||
List<Integer> collect = amounts
|
||||
.filter(a -> a > threshold)
|
||||
.reduce((integer, t1) -> integer + t1)
|
||||
.collect();
|
||||
.filter(a -> a > threshold)
|
||||
.reduce((integer, t1) -> integer + t1)
|
||||
.collect();
|
||||
|
||||
//then
|
||||
assertThat(collect.get(0)).isEqualTo(90);
|
||||
|
@ -78,13 +78,13 @@ public class WordCountIntegrationTest {
|
|||
Tuple2<Integer, String> fourthPerson = new Tuple2<>(200, "Michael");
|
||||
Tuple2<Integer, String> firstPerson = new Tuple2<>(1, "Jack");
|
||||
DataSet<Tuple2<Integer, String>> transactions = env.fromElements(fourthPerson, secondPerson,
|
||||
thirdPerson, firstPerson);
|
||||
thirdPerson, firstPerson);
|
||||
|
||||
|
||||
//when
|
||||
List<Tuple2<Integer, String>> sorted = transactions
|
||||
.sortPartition(new IdKeySelectorTransaction(), Order.ASCENDING)
|
||||
.collect();
|
||||
.sortPartition(new IdKeySelectorTransaction(), Order.ASCENDING)
|
||||
.collect();
|
||||
|
||||
//then
|
||||
assertThat(sorted).containsExactly(firstPerson, secondPerson, thirdPerson, fourthPerson);
|
||||
|
@ -99,15 +99,15 @@ public class WordCountIntegrationTest {
|
|||
|
||||
Tuple2<Integer, String> firstTransaction = new Tuple2<>(1, "Transaction_1");
|
||||
DataSet<Tuple2<Integer, String>> transactions =
|
||||
env.fromElements(firstTransaction, new Tuple2<>(12, "Transaction_2"));
|
||||
env.fromElements(firstTransaction, new Tuple2<>(12, "Transaction_2"));
|
||||
|
||||
|
||||
//when
|
||||
List<Tuple2<Tuple2<Integer, String>, Tuple3<Integer, String, String>>> joined =
|
||||
transactions.join(addresses)
|
||||
.where(new IdKeySelectorTransaction())
|
||||
.equalTo(new IdKeySelectorAddress())
|
||||
.collect();
|
||||
transactions.join(addresses)
|
||||
.where(new IdKeySelectorTransaction())
|
||||
.equalTo(new IdKeySelectorAddress())
|
||||
.collect();
|
||||
|
||||
//then
|
||||
assertThat(joined).hasSize(1);
|
||||
|
@ -121,7 +121,7 @@ public class WordCountIntegrationTest {
|
|||
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
||||
|
||||
DataStream<String> text
|
||||
= env.fromElements("This is a first sentence", "This is a second sentence with a one word");
|
||||
= env.fromElements("This is a first sentence", "This is a second sentence with a one word");
|
||||
|
||||
|
||||
SingleOutputStreamOperator<String> upperCase = text.map(String::toUpperCase);
|
||||
|
@ -139,8 +139,8 @@ public class WordCountIntegrationTest {
|
|||
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
|
||||
|
||||
SingleOutputStreamOperator<Tuple2<Integer, Long>> windowed = env.fromElements(
|
||||
new Tuple2<>(16, ZonedDateTime.now().plusMinutes(25).toInstant().getEpochSecond()),
|
||||
new Tuple2<>(15, ZonedDateTime.now().plusMinutes(2).toInstant().getEpochSecond())
|
||||
new Tuple2<>(16, ZonedDateTime.now().plusMinutes(25).toInstant().getEpochSecond()),
|
||||
new Tuple2<>(15, ZonedDateTime.now().plusMinutes(2).toInstant().getEpochSecond())
|
||||
).assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor<Tuple2<Integer, Long>>(Time.seconds(20)) {
|
||||
@Override
|
||||
public long extractTimestamp(Tuple2<Integer, Long> element) {
|
||||
|
@ -149,8 +149,8 @@ public class WordCountIntegrationTest {
|
|||
});
|
||||
|
||||
SingleOutputStreamOperator<Tuple2<Integer, Long>> reduced = windowed
|
||||
.windowAll(TumblingEventTimeWindows.of(Time.seconds(5)))
|
||||
.maxBy(0, true);
|
||||
.windowAll(TumblingEventTimeWindows.of(Time.seconds(5)))
|
||||
.maxBy(0, true);
|
||||
|
||||
reduced.print();
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.baeldung.hikaricp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class HikariCPUnitTest {
|
||||
|
|
|
@ -4,7 +4,15 @@ package com.baeldung.javassist;
|
|||
import javassist.CannotCompileException;
|
||||
import javassist.ClassPool;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.bytecode.*;
|
||||
import javassist.bytecode.AccessFlag;
|
||||
import javassist.bytecode.BadBytecode;
|
||||
import javassist.bytecode.Bytecode;
|
||||
import javassist.bytecode.ClassFile;
|
||||
import javassist.bytecode.CodeAttribute;
|
||||
import javassist.bytecode.CodeIterator;
|
||||
import javassist.bytecode.FieldInfo;
|
||||
import javassist.bytecode.MethodInfo;
|
||||
import javassist.bytecode.Mnemonic;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
|
@ -66,7 +74,7 @@ public class JavasisstUnitTest {
|
|||
|
||||
//then
|
||||
assertEquals(operations,
|
||||
Arrays.asList("aload_0", "iload_1", "putfield", "aload_0", "iload_2", "putfield", "return"));
|
||||
Arrays.asList("aload_0", "iload_1", "putfield", "aload_0", "iload_2", "putfield", "return"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,7 +120,7 @@ public class JavasisstUnitTest {
|
|||
}
|
||||
|
||||
assertEquals(operations,
|
||||
Arrays.asList("aload_0", "invokespecial", "return"));
|
||||
Arrays.asList("aload_0", "invokespecial", "return"));
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package com.baeldung.javatuples;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.javatuples.KeyValue;
|
||||
import org.javatuples.LabelValue;
|
||||
import org.javatuples.Pair;
|
||||
|
@ -13,6 +8,11 @@ import org.javatuples.Triplet;
|
|||
import org.javatuples.Unit;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class JavaTuplesUnitTest {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -26,7 +26,7 @@ public class JavaTuplesUnitTest {
|
|||
|
||||
Pair<String, String> pairFromList = Pair.fromIterable(collectionOfNames, 2);
|
||||
|
||||
String[] names = new String[] { "john", "doe", "anne" };
|
||||
String[] names = new String[]{"john", "doe", "anne"};
|
||||
Triplet<String, String, String> triplet2 = Triplet.fromArray(names);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,11 @@ public class JaversUnitTest {
|
|||
Javers javers = JaversBuilder.javers().build();
|
||||
|
||||
PersonWithAddress person =
|
||||
new PersonWithAddress(1, "Tom", Arrays.asList(new Address("England")));
|
||||
new PersonWithAddress(1, "Tom", Arrays.asList(new Address("England")));
|
||||
|
||||
PersonWithAddress personWithNewAddress =
|
||||
new PersonWithAddress(1, "Tom",
|
||||
Arrays.asList(new Address("England"), new Address("USA")));
|
||||
new PersonWithAddress(1, "Tom",
|
||||
Arrays.asList(new Address("England"), new Address("USA")));
|
||||
|
||||
|
||||
//when
|
||||
|
@ -96,10 +96,10 @@ public class JaversUnitTest {
|
|||
Javers javers = JaversBuilder.javers().build();
|
||||
|
||||
PersonWithAddress person =
|
||||
new PersonWithAddress(1, "Tom", Arrays.asList(new Address("England")));
|
||||
new PersonWithAddress(1, "Tom", Arrays.asList(new Address("England")));
|
||||
|
||||
PersonWithAddress personWithNewAddress =
|
||||
new PersonWithAddress(1, "Tom", Collections.emptyList());
|
||||
new PersonWithAddress(1, "Tom", Collections.emptyList());
|
||||
|
||||
|
||||
//when
|
||||
|
|
|
@ -24,14 +24,14 @@ public class GuideToJDOIntegrationTest {
|
|||
pumd.addProperty("javax.jdo.option.ConnectionURL", "jdbc:h2:mem:mypersistence");
|
||||
pumd.addProperty("javax.jdo.option.ConnectionUserName", "sa");
|
||||
pumd.addProperty("javax.jdo.option.ConnectionPassword", "");
|
||||
pumd.addProperty("datanucleus.autoCreateSchema", "true");
|
||||
pumd.addProperty("datanucleus.autoCreateSchema", "true");
|
||||
|
||||
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
Transaction tx = pm.currentTransaction();
|
||||
try {
|
||||
tx.begin();
|
||||
for (int i = 0; i < 100; i++){
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String nam = "Product-" + i;
|
||||
Product productx = new Product(nam, (double) i);
|
||||
pm.makePersistent(productx);
|
||||
|
@ -58,7 +58,7 @@ public class GuideToJDOIntegrationTest {
|
|||
pumd.addProperty("javax.jdo.option.ConnectionURL", "jdbc:h2:mem:mypersistence");
|
||||
pumd.addProperty("javax.jdo.option.ConnectionUserName", "sa");
|
||||
pumd.addProperty("javax.jdo.option.ConnectionPassword", "");
|
||||
pumd.addProperty("datanucleus.autoCreateSchema", "true");
|
||||
pumd.addProperty("datanucleus.autoCreateSchema", "true");
|
||||
|
||||
PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(pumd, null);
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
|
@ -93,9 +93,7 @@ public class GuideToJDOIntegrationTest {
|
|||
Query q = pm2.newQuery("SELECT FROM " + Product.class.getName() + " WHERE price == 200");
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Product> products = (List<Product>) q.execute();
|
||||
Iterator<Product> iter = products.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Product p = iter.next();
|
||||
for (Product p : products) {
|
||||
assertEquals("Laptop", p.name);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.baeldung.jsonassert;
|
||||
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
@ -13,6 +11,8 @@ import org.skyscreamer.jsonassert.RegularExpressionValueMatcher;
|
|||
import org.skyscreamer.jsonassert.comparator.ArraySizeComparator;
|
||||
import org.skyscreamer.jsonassert.comparator.CustomComparator;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class JsonAssertUnitTest {
|
||||
|
||||
@Test
|
||||
|
@ -44,7 +44,7 @@ public class JsonAssertUnitTest {
|
|||
@Test
|
||||
public void givenDifferentOrderForJsonObject_whenAssertEquals_thenPass() throws JSONException {
|
||||
String result = "{id:1,name:\"John\"}";
|
||||
|
||||
|
||||
JSONAssert.assertEquals("{name:\"John\",id:1}", result, JSONCompareMode.STRICT);
|
||||
JSONAssert.assertEquals("{name:\"John\",id:1}", result, JSONCompareMode.LENIENT);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class JsonAssertUnitTest {
|
|||
JSONObject actual = new JSONObject();
|
||||
expected.put("id", Integer.valueOf(12345));
|
||||
actual.put("id", Double.valueOf(12345));
|
||||
|
||||
|
||||
JSONAssert.assertEquals(expected, actual, false);
|
||||
JSONAssert.assertEquals(expected, actual, JSONCompareMode.LENIENT);
|
||||
}
|
||||
|
@ -63,11 +63,11 @@ public class JsonAssertUnitTest {
|
|||
@Test
|
||||
public void givenNestedObjects_whenAssertEquals_thenPass() throws JSONException {
|
||||
String result = "{id:1,name:\"Juergen\", address:{city:\"Hollywood\", "
|
||||
+ "state:\"LA\", zip:91601}}";
|
||||
+ "state:\"LA\", zip:91601}}";
|
||||
JSONAssert.assertEquals("{id:1,name:\"Juergen\", address:{city:\"Hollywood\", "
|
||||
+ "state:\"LA\", zip:91601}}", result, false);
|
||||
+ "state:\"LA\", zip:91601}}", result, false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenMessageUsedInAssertion_thenDisplayMessageOnFailure() throws JSONException {
|
||||
String actual = "{id:123,name:\"John\"}";
|
||||
|
@ -94,36 +94,36 @@ public class JsonAssertUnitTest {
|
|||
JSONAssert.assertNotEquals("[1,2,3]", result, JSONCompareMode.LENIENT);
|
||||
JSONAssert.assertNotEquals("[1,2,3,4,5,6]", result, JSONCompareMode.LENIENT);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenComparingSizeOfArray_thenPass() throws JSONException {
|
||||
String names = "{names:[Alex, Barbera, Charlie, Xavier]}";
|
||||
JSONAssert.assertEquals(
|
||||
"{names:[4]}",
|
||||
names,
|
||||
new ArraySizeComparator(JSONCompareMode.LENIENT));
|
||||
"{names:[4]}",
|
||||
names,
|
||||
new ArraySizeComparator(JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void whenComparingContentsOfArray_thenPass() throws JSONException {
|
||||
String ratings = "{ratings:[3.2,3.5,4.1,5,1]}";
|
||||
JSONAssert.assertEquals(
|
||||
"{ratings:[1,5]}",
|
||||
ratings,
|
||||
new ArraySizeComparator(JSONCompareMode.LENIENT));
|
||||
"{ratings:[1,5]}",
|
||||
ratings,
|
||||
new ArraySizeComparator(JSONCompareMode.LENIENT));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenValueMatcher_whenComparingUsingRegex_thenPass() throws IllegalArgumentException, JSONException {
|
||||
JSONAssert.assertEquals("{entry:{id:x}}", "{entry:{id:1, id:2}}",
|
||||
new CustomComparator(
|
||||
JSONCompareMode.STRICT,
|
||||
new Customization("entry.id",
|
||||
new RegularExpressionValueMatcher<Object>("\\d"))));
|
||||
|
||||
JSONAssert.assertNotEquals("{entry:{id:x}}", "{entry:{id:1, id:as}}",
|
||||
new CustomComparator(JSONCompareMode.STRICT,
|
||||
new Customization("entry.id",
|
||||
new RegularExpressionValueMatcher<Object>("\\d"))));
|
||||
JSONAssert.assertEquals("{entry:{id:x}}", "{entry:{id:1, id:2}}",
|
||||
new CustomComparator(
|
||||
JSONCompareMode.STRICT,
|
||||
new Customization("entry.id",
|
||||
new RegularExpressionValueMatcher<Object>("\\d"))));
|
||||
|
||||
JSONAssert.assertNotEquals("{entry:{id:x}}", "{entry:{id:1, id:as}}",
|
||||
new CustomComparator(JSONCompareMode.STRICT,
|
||||
new Customization("entry.id",
|
||||
new RegularExpressionValueMatcher<Object>("\\d"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.baeldung.junitparams;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import junitparams.FileParameters;
|
||||
import junitparams.JUnitParamsRunner;
|
||||
import junitparams.Parameters;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(JUnitParamsRunner.class)
|
||||
public class SafeAdditionUtilTest {
|
||||
|
@ -15,7 +14,7 @@ public class SafeAdditionUtilTest {
|
|||
private SafeAdditionUtil serviceUnderTest = new SafeAdditionUtil();
|
||||
|
||||
@Test
|
||||
@Parameters({ "1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15" })
|
||||
@Parameters({"1, 2, 3", "-10, 30, 20", "15, -5, 10", "-5, -10, -15"})
|
||||
public void whenCalledWithAnnotationProvidedParams_thenSafeAddAndReturn(int a, int b, int expectedValue) {
|
||||
assertEquals(expectedValue, serviceUnderTest.safeAdd(a, b));
|
||||
}
|
||||
|
@ -27,7 +26,7 @@ public class SafeAdditionUtilTest {
|
|||
}
|
||||
|
||||
private Object[] parametersToTestAdd() {
|
||||
return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } };
|
||||
return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -8, Integer.MIN_VALUE}};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -37,7 +36,7 @@ public class SafeAdditionUtilTest {
|
|||
}
|
||||
|
||||
private Object[] parametersForWhenCalledWithnoParam_thenLoadByNameSafeAddAndReturn() {
|
||||
return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -8, Integer.MIN_VALUE } };
|
||||
return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -8, Integer.MIN_VALUE}};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.baeldung.junitparams;
|
|||
public class TestDataProvider {
|
||||
|
||||
public static Object[] provideBasicData() {
|
||||
return new Object[] { new Object[] { 1, 2, 3 }, new Object[] { -10, 30, 20 }, new Object[] { 15, -5, 10 }, new Object[] { -5, -10, -15 } };
|
||||
return new Object[]{new Object[]{1, 2, 3}, new Object[]{-10, 30, 20}, new Object[]{15, -5, 10}, new Object[]{-5, -10, -15}};
|
||||
}
|
||||
|
||||
public static Object[] provideEdgeCaseData() {
|
||||
return new Object[] { new Object[] { Integer.MAX_VALUE, 2, Integer.MAX_VALUE }, new Object[] { Integer.MIN_VALUE, -2, Integer.MIN_VALUE }, };
|
||||
return new Object[]{new Object[]{Integer.MAX_VALUE, 2, Integer.MAX_VALUE}, new Object[]{Integer.MIN_VALUE, -2, Integer.MIN_VALUE},};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
package com.baeldung.opennlp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import opennlp.tools.chunker.ChunkerME;
|
||||
import opennlp.tools.chunker.ChunkerModel;
|
||||
import opennlp.tools.cmdline.postag.POSModelLoader;
|
||||
|
@ -31,14 +21,23 @@ import opennlp.tools.util.ObjectStream;
|
|||
import opennlp.tools.util.PlainTextByLineStream;
|
||||
import opennlp.tools.util.Span;
|
||||
import opennlp.tools.util.TrainingParameters;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OpenNLPTests {
|
||||
|
||||
private final static String text = "To get to the south: Go to the store. Buy a compass. Use the compass. Then walk to the south.";
|
||||
private final static String sentence[] = new String[] { "James", "Jordan", "live", "in", "Oklahoma", "city", "." };
|
||||
|
||||
private final static String sentence[] = new String[]{"James", "Jordan", "live", "in", "Oklahoma", "city", "."};
|
||||
|
||||
@Test
|
||||
public void givenText_WhenDetectSentences_ThenCountSentences(){
|
||||
public void givenText_WhenDetectSentences_ThenCountSentences() {
|
||||
InputStream is;
|
||||
SentenceModel model;
|
||||
try {
|
||||
|
@ -48,15 +47,13 @@ public class OpenNLPTests {
|
|||
String sentences[] = sdetector.sentDetect(text);
|
||||
assertEquals(4, sentences.length);
|
||||
is.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenText_WhenDetectTokens_ThenVerifyNames(){
|
||||
public void givenText_WhenDetectTokens_ThenVerifyNames() {
|
||||
InputStream is;
|
||||
TokenNameFinderModel model;
|
||||
try {
|
||||
|
@ -68,15 +65,13 @@ public class OpenNLPTests {
|
|||
String[] names = Span.spansToStrings(nameSpans, sentence);
|
||||
assertEquals(1, names.length);
|
||||
assertEquals("James Jordan", names[0]);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenText_WhenDetectTokens_ThenVerifyLocations(){
|
||||
public void givenText_WhenDetectTokens_ThenVerifyLocations() {
|
||||
InputStream is;
|
||||
TokenNameFinderModel model;
|
||||
try {
|
||||
|
@ -88,15 +83,13 @@ public class OpenNLPTests {
|
|||
String[] locations = Span.spansToStrings(locationSpans, sentence);
|
||||
assertEquals(1, locations.length);
|
||||
assertEquals("Oklahoma", locations[0]);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenText_WhenCategorizeDocument_ThenVerifyDocumentContent(){
|
||||
public void givenText_WhenCategorizeDocument_ThenVerifyDocumentContent() {
|
||||
DoccatModel docCatModel;
|
||||
try {
|
||||
InputStreamFactory isf = new InputStreamFactory() {
|
||||
|
@ -118,7 +111,7 @@ public class OpenNLPTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenText_WhenTagDocument_ThenVerifyTaggedString(){
|
||||
public void givenText_WhenTagDocument_ThenVerifyTaggedString() {
|
||||
try {
|
||||
POSModel posModel = new POSModelLoader().load(new File("OpenNLP/en-pos-maxent.bin"));
|
||||
POSTaggerME posTaggerME = new POSTaggerME(posModel);
|
||||
|
@ -140,19 +133,19 @@ public class OpenNLPTests {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void givenText_WhenChunked_ThenCountChunks(){
|
||||
public void givenText_WhenChunked_ThenCountChunks() {
|
||||
try {
|
||||
InputStream is = new FileInputStream("OpenNLP/en-chunker.bin");
|
||||
ChunkerModel cModel = new ChunkerModel(is);
|
||||
ChunkerME chunkerME = new ChunkerME(cModel);
|
||||
String pos[] = new String[] { "NNP", "NNP", "NNP", "POS", "NNP", "NN", "VBD"};
|
||||
String pos[] = new String[]{"NNP", "NNP", "NNP", "POS", "NNP", "NN", "VBD"};
|
||||
String chunks[] = chunkerME.chunk(sentence, pos);
|
||||
assertEquals(7, chunks.length);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package com.baeldung.serenity;
|
|||
|
||||
import net.serenitybdd.jbehave.SerenityStory;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubUserProfilePayloadIntegrationTest extends SerenityStory {
|
||||
|
||||
}
|
||||
|
|
|
@ -13,13 +13,11 @@ import static org.hamcrest.CoreMatchers.containsString;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
@RunWith(SerenityRunner.class)
|
||||
public class GoogleSearchLiveTest {
|
||||
|
||||
@Managed(driver = "chrome") private WebDriver browser;
|
||||
@Managed(driver = "chrome")
|
||||
private WebDriver browser;
|
||||
|
||||
@Test
|
||||
public void whenGoogleBaeldungThenShouldSeeEugen() {
|
||||
|
|
|
@ -7,15 +7,13 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
@RunWith(SerenityRunner.class)
|
||||
public class GoogleSearchPageObjectLiveTest {
|
||||
|
||||
@Managed(driver = "chrome") private WebDriver browser;
|
||||
@Managed(driver = "chrome")
|
||||
private WebDriver browser;
|
||||
|
||||
GoogleSearchPageObject googleSearch;
|
||||
private GoogleSearchPageObject googleSearch;
|
||||
|
||||
@Test
|
||||
public void whenGoogleBaeldungThenShouldSeeEugen() {
|
||||
|
|
|
@ -12,19 +12,20 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import static net.serenitybdd.screenplay.GivenWhenThen.*;
|
||||
import static net.serenitybdd.screenplay.GivenWhenThen.givenThat;
|
||||
import static net.serenitybdd.screenplay.GivenWhenThen.seeThat;
|
||||
import static net.serenitybdd.screenplay.GivenWhenThen.then;
|
||||
import static net.serenitybdd.screenplay.GivenWhenThen.when;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
@RunWith(SerenityRunner.class)
|
||||
public class GoogleSearchScreenplayLiveTest {
|
||||
|
||||
@Managed(driver = "chrome") WebDriver browser;
|
||||
@Managed(driver = "chrome")
|
||||
private WebDriver browser;
|
||||
|
||||
Actor kitty = Actor.named("kitty");
|
||||
private Actor kitty = Actor.named("kitty");
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
|
|
@ -16,7 +16,8 @@ import static com.baeldung.serenity.membership.MemberGrade.Silver;
|
|||
@RunWith(SerenityRunner.class)
|
||||
public class MemberStatusIntegrationTest {
|
||||
|
||||
@Steps MemberStatusSteps memberSteps;
|
||||
@Steps
|
||||
private MemberStatusSteps memberSteps;
|
||||
|
||||
@Test
|
||||
public void membersShouldStartWithBronzeStatus() {
|
||||
|
@ -42,7 +43,7 @@ public class MemberStatusIntegrationTest {
|
|||
|
||||
@Test
|
||||
@Title("Members with 50,000 points can exchange a MacBook Pro")
|
||||
public void memberWith50000PointsCanExchangeAMacbookpro(){
|
||||
public void memberWith50000PointsCanExchangeAMacbookpro() {
|
||||
memberSteps.aMemberHasPointsOf(50_000);
|
||||
memberSteps.aMemberExchangeA(MacBookPro);
|
||||
memberSteps.memberShouldHavePointsLeft();
|
||||
|
@ -55,7 +56,7 @@ public class MemberStatusIntegrationTest {
|
|||
@Test
|
||||
@Ignore
|
||||
@Title("Members with 500 points should have a Gold status when added 4,000 points ($40,000)")
|
||||
public void memberWith500PointsEarnsGoldAfterSpends$40000(){
|
||||
public void memberWith500PointsEarnsGoldAfterSpends$40000() {
|
||||
memberSteps.aMemberHasPointsOf(500);
|
||||
memberSteps.theMemberSpends(40_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Gold);
|
||||
|
@ -64,7 +65,7 @@ public class MemberStatusIntegrationTest {
|
|||
@Test
|
||||
@Ignore
|
||||
@Title("Members with 100 points would have a Gold status when added 10,000 points ($100,000)")
|
||||
public void memberWith100EarnsGoldAfterSpends$100000(){
|
||||
public void memberWith100EarnsGoldAfterSpends$100000() {
|
||||
memberSteps.aMemberHasPointsOf(100);
|
||||
memberSteps.theMemberSpends(100_000);
|
||||
memberSteps.theMemberShouldHaveAStatusOf(Gold);
|
||||
|
|
|
@ -8,25 +8,22 @@ import java.io.IOException;
|
|||
import static net.serenitybdd.rest.SerenityRest.rest;
|
||||
import static net.serenitybdd.rest.SerenityRest.then;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubRestAssuredUserAPISteps {
|
||||
class GithubRestAssuredUserAPISteps {
|
||||
|
||||
private String api;
|
||||
|
||||
@Step("Given the github REST API for user profile")
|
||||
public void withUserProfileAPIEndpoint() {
|
||||
void withUserProfileAPIEndpoint() {
|
||||
api = "https://api.github.com/users/{username}";
|
||||
}
|
||||
|
||||
@Step("When looking for {0} via the api")
|
||||
public void getProfileOfUser(String username) throws IOException {
|
||||
void getProfileOfUser(String username) throws IOException {
|
||||
rest().get(api, username);
|
||||
}
|
||||
|
||||
@Step("Then there should be a login field with value {0} in payload of user {0}")
|
||||
public void profilePayloadShouldContainLoginValue(String username) {
|
||||
void profilePayloadShouldContainLoginValue(String username) {
|
||||
then().body("login", Matchers.equalTo(username));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@ import java.io.IOException;
|
|||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class GithubRestUserAPISteps {
|
||||
|
||||
private String api;
|
||||
|
|
|
@ -9,11 +9,8 @@ import java.io.IOException;
|
|||
|
||||
public class GithubUserProfilePayloadStepDefinitions {
|
||||
|
||||
// @Steps
|
||||
// GithubRestUserAPISteps userAPISteps;
|
||||
|
||||
@Steps
|
||||
GithubRestAssuredUserAPISteps userAPISteps;
|
||||
private GithubRestAssuredUserAPISteps userAPISteps;
|
||||
|
||||
@Given("github user profile api")
|
||||
public void givenGithubUserProfileApi() {
|
||||
|
|
|
@ -6,12 +6,9 @@ import net.thucydides.core.annotations.Step;
|
|||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
public class MemberStatusSteps {
|
||||
|
||||
Member member;
|
||||
private Member member;
|
||||
|
||||
@Step("Given a member has {0} points")
|
||||
public void aMemberHasPointsOf(int points) {
|
||||
|
@ -35,7 +32,7 @@ public class MemberStatusSteps {
|
|||
|
||||
@Pending
|
||||
@Step("When the member exchange {}")
|
||||
public void aMemberExchangeA(Commodity commodity){
|
||||
public void aMemberExchangeA(Commodity commodity) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
|
|
@ -10,15 +10,14 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
|||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
@DefaultUrl("https://www.google.com/ncr")
|
||||
public class GoogleSearchPageObject extends PageObject {
|
||||
|
||||
@FindBy(name = "q") private WebElement search;
|
||||
@FindBy(name = "q")
|
||||
private WebElement search;
|
||||
|
||||
@FindBy(css = "._ksh") private WebElement result;
|
||||
@FindBy(css = "._ksh")
|
||||
private WebElement result;
|
||||
|
||||
public void searchFor(String keyword) {
|
||||
search.sendKeys(keyword, Keys.ENTER);
|
||||
|
|
|
@ -8,13 +8,13 @@ import net.thucydides.core.annotations.DefaultUrl;
|
|||
* @author baoqiang
|
||||
*/
|
||||
@DefaultUrl("https://www.google.com/ncr")
|
||||
public class GoogleSearchPage extends PageObject {
|
||||
class GoogleSearchPage extends PageObject {
|
||||
|
||||
public static final Target SEARCH_RESULT_TITLES = Target
|
||||
static final Target SEARCH_RESULT_TITLES = Target
|
||||
.the("search results")
|
||||
.locatedBy("._ksh");
|
||||
|
||||
public static final Target SEARCH_INPUT_BOX = Target
|
||||
static final Target SEARCH_INPUT_BOX = Target
|
||||
.the("search input box")
|
||||
.locatedBy("#lst-ib");
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ import net.serenitybdd.screenplay.questions.Text;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author baoqiang
|
||||
*/
|
||||
public class GoogleSearchResults implements Question<List<String>> {
|
||||
|
||||
public static Question<List<String>> displayed() {
|
||||
|
|
|
@ -7,9 +7,6 @@ import net.serenitybdd.screenplay.actions.Enter;
|
|||
import net.thucydides.core.annotations.Step;
|
||||
import org.openqa.selenium.Keys;
|
||||
|
||||
/**
|
||||
* @author baoqiang
|
||||
*/
|
||||
public class SearchForKeyword implements Task {
|
||||
|
||||
@Step("{0} searches for '#keyword'")
|
||||
|
|
|
@ -7,9 +7,6 @@ import net.thucydides.core.annotations.Step;
|
|||
|
||||
import static net.serenitybdd.screenplay.Tasks.instrumented;
|
||||
|
||||
/**
|
||||
* @author baoqiang
|
||||
*/
|
||||
public class StartWith implements Task {
|
||||
|
||||
public static StartWith googleSearchPage() {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.baeldung.stm;
|
||||
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
|
|
@ -17,10 +17,10 @@ public class JoolMergeStreamsTest {
|
|||
Stream<Integer> seq2 = Stream.of(2, 4, 6);
|
||||
|
||||
Stream<Integer> resultingSeq = Seq.ofType(seq1, Integer.class)
|
||||
.append(seq2);
|
||||
.append(seq2);
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6),
|
||||
resultingSeq.collect(Collectors.toList()));
|
||||
resultingSeq.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,10 +30,10 @@ public class JoolMergeStreamsTest {
|
|||
Stream<String> closingBracketSeq = Stream.of("]");
|
||||
|
||||
Stream<String> resultingStream = Seq.ofType(seq, String.class)
|
||||
.append(closingBracketSeq)
|
||||
.prepend(openingBracketSeq);
|
||||
.append(closingBracketSeq)
|
||||
.prepend(openingBracketSeq);
|
||||
|
||||
Assert.assertEquals(Arrays.asList("[", "foo", "bar", "]"),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
|
@ -17,10 +17,10 @@ public class MergeStreamsTest {
|
|||
Stream<Integer> stream2 = Stream.of(2, 4, 6);
|
||||
|
||||
Stream<Integer> resultingStream = Stream.concat(stream1,
|
||||
stream2);
|
||||
stream2);
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,11 +30,11 @@ public class MergeStreamsTest {
|
|||
Stream<Integer> stream3 = Stream.of(18, 15, 36);
|
||||
|
||||
Stream<Integer> resultingStream = Stream.concat(Stream.concat(stream1,
|
||||
stream2),
|
||||
stream3);
|
||||
stream2),
|
||||
stream3);
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6, 18, 15, 36),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +47,7 @@ public class MergeStreamsTest {
|
|||
Stream<Integer> resultingStream = Stream.of(stream1, stream2, stream3, stream4).flatMap(Function.identity());
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6, 18, 15, 36, 99),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ public class StreamExMergeStreamsTest {
|
|||
Stream<Integer> resultingStream = StreamEx.of(stream1).append(stream2);
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -30,12 +30,12 @@ public class StreamExMergeStreamsTest {
|
|||
Stream<Integer> stream4 = Stream.of(99);
|
||||
|
||||
Stream<Integer> resultingStream = StreamEx.of(stream1)
|
||||
.append(stream2)
|
||||
.append(stream3)
|
||||
.append(stream4);
|
||||
.append(stream2)
|
||||
.append(stream3)
|
||||
.append(stream4);
|
||||
|
||||
assertEquals(Arrays.asList(1, 3, 5, 2, 4, 6, 18, 15, 36, 99),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,10 @@ public class StreamExMergeStreamsTest {
|
|||
Stream<String> closingBracketStream = Stream.of("]");
|
||||
|
||||
Stream<String> resultingStream = StreamEx.of(stream1)
|
||||
.append(closingBracketStream)
|
||||
.prepend(openingBracketStream);
|
||||
.append(closingBracketStream)
|
||||
.prepend(openingBracketStream);
|
||||
|
||||
assertEquals(Arrays.asList("[", "foo", "bar", "]"),
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
resultingStream.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ public class ParallelIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void runTests() {
|
||||
final Class<?>[] classes = { Example1IntegrationTest.class, Example2IntegrationTest.class };
|
||||
final Class<?>[] classes = {Example1IntegrationTest.class, Example2IntegrationTest.class};
|
||||
|
||||
JUnitCore.runClasses(new Computer(), classes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runTestsInParallel() {
|
||||
final Class<?>[] classes = { Example1IntegrationTest.class, Example2IntegrationTest.class };
|
||||
final Class<?>[] classes = {Example1IntegrationTest.class, Example2IntegrationTest.class};
|
||||
|
||||
JUnitCore.runClasses(new ParallelComputer(true, true), classes);
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author aiet
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = Spring5JUnit4ConcurrentIntegrationTest.SimpleConfiguration.class)
|
||||
public class Spring5JUnit4ConcurrentIntegrationTest implements ApplicationContextAware, InitializingBean {
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.springframework.core.io.ClassPathResource;
|
|||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
|
|
|
@ -16,10 +16,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
class Spring5JUnit5ComposedAnnotationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
Task task;
|
||||
private Task task;
|
||||
|
||||
@Autowired
|
||||
List<Task> tasks;
|
||||
private List<Task> tasks;
|
||||
|
||||
@Test
|
||||
@DisplayName("ApplicationContext injected into method")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.baeldung.jupiter;
|
||||
|
||||
import com.baeldung.web.reactive.Task;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -10,14 +10,12 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = TestConfig.class)
|
||||
class Spring5JUnit5IntegrationTest {
|
||||
|
||||
@Autowired
|
||||
Task task;
|
||||
private Task task;
|
||||
|
||||
@Test
|
||||
void givenAMethodName_whenInjecting_thenApplicationContextInjectedIntoMetho(ApplicationContext applicationContext) {
|
||||
|
|
|
@ -7,10 +7,10 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.runner.Computer;
|
||||
import org.junit.runner.JUnitCore;
|
||||
|
||||
public class Spring5JUnit5ParallelIntegrationTest {
|
||||
class Spring5JUnit5ParallelIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingParallel() {
|
||||
void givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingParallel() {
|
||||
final Class<?>[] classes = {
|
||||
Example1IntegrationTest.class, Example2IntegrationTest.class
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ public class Spring5JUnit5ParallelIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingLinear() {
|
||||
void givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingLinear() {
|
||||
final Class<?>[] classes = {
|
||||
Example1IntegrationTest.class, Example2IntegrationTest.class
|
||||
};
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
package com.baeldung.jupiter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Spring5Java8NewFeaturesIntegrationTest {
|
||||
class Spring5Java8NewFeaturesIntegrationTest {
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FunctionalInterfaceExample<Input, Result> {
|
||||
Result reverseString(Input input);
|
||||
}
|
||||
|
||||
public class StringUtils{
|
||||
public FunctionalInterfaceExample<String, String>
|
||||
functionLambdaString = s -> {
|
||||
return Pattern.compile(" +").splitAsStream(s)
|
||||
.map(word->new StringBuilder(word).reverse())
|
||||
public class StringUtils {
|
||||
FunctionalInterfaceExample<String, String>
|
||||
functionLambdaString = s -> Pattern.compile(" +").splitAsStream(s)
|
||||
.map(word -> new StringBuilder(word).reverse())
|
||||
.collect(Collectors.joining(" "));
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,16 +3,8 @@ package com.baeldung.jupiter;
|
|||
import com.baeldung.web.reactive.Task;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
||||
import org.springframework.http.server.reactive.HttpHandler;
|
||||
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.ClientRequest;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFunction;
|
||||
import org.springframework.web.reactive.function.client.ExchangeFunctions;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
@ -21,10 +13,8 @@ import reactor.core.publisher.Mono;
|
|||
import reactor.ipc.netty.NettyContext;
|
||||
import reactor.ipc.netty.http.server.HttpServer;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
|
||||
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.baeldung.web;
|
||||
|
||||
import com.baeldung.web.PathPatternController;
|
||||
import com.baeldung.Spring5Application;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -11,92 +10,92 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class)
|
||||
public class PathPatternsUsingHandlerMethodTest {
|
||||
public class PathPatternsUsingHandlerMethodIntegrationTest {
|
||||
|
||||
private static WebTestClient client;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
client = WebTestClient.bindToController(new PathPatternController())
|
||||
.build();
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenMultipleURIVariablePattern_then200() {
|
||||
|
||||
client.get()
|
||||
.uri("/spring5/ab/cd")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/ab/cd");
|
||||
.uri("/spring5/ab/cd")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/ab/cd");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenURLWithWildcardTakingZeroOrMoreChar_then200() {
|
||||
|
||||
client.get()
|
||||
.uri("/spring5/userid")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/spring5/*id");
|
||||
.uri("/spring5/userid")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/spring5/*id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenURLWithWildcardTakingExactlyOneChar_then200() {
|
||||
|
||||
client.get()
|
||||
.uri("/string5")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/s?ring5");
|
||||
.uri("/string5")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/s?ring5");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenURLWithWildcardTakingZeroOrMorePathSegments_then200() {
|
||||
|
||||
client.get()
|
||||
.uri("/resources/baeldung")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/resources/**");
|
||||
.uri("/resources/baeldung")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("/resources/**");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenURLWithRegexInPathVariable_thenExpectedOutput() {
|
||||
|
||||
client.get()
|
||||
.uri("/abc")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("abc");
|
||||
.uri("/abc")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("abc");
|
||||
|
||||
client.get()
|
||||
.uri("/123")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is4xxClientError();
|
||||
.uri("/123")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is4xxClientError();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenHandlerMethod_whenURLWithMultiplePathVariablesInSameSegment_then200() {
|
||||
|
||||
client.get()
|
||||
.uri("/baeldung_tutorial")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("Two variables are var1=baeldung and var2=tutorial");
|
||||
.uri("/baeldung_tutorial")
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.is2xxSuccessful()
|
||||
.expectBody()
|
||||
.equals("Two variables are var1=baeldung and var2=tutorial");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>sprin-jooq</artifactId>
|
||||
<artifactId>spring-jooq</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.regex.Pattern;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
@ContextConfiguration(classes = {TestConfig.class}, loader = AnnotationConfigContextLoader.class)
|
||||
public class AopPublishingIntegrationTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -12,7 +12,7 @@ import io.restassured.authentication.FormAuthConfig;
|
|||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
|
||||
public class LiveTest {
|
||||
public class ApplicationLiveTest {
|
||||
|
||||
private final FormAuthConfig formAuthConfig = new FormAuthConfig("http://localhost:8082/spring-security-mvc-boot/login", "username", "password");
|
||||
|
|
@ -21,22 +21,22 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = { MvcConfig.class, SecurityConfig.class, PersistenceConfig.class })
|
||||
@SpringBootTest(classes = {MvcConfig.class, SecurityConfig.class, PersistenceConfig.class})
|
||||
@WebAppConfiguration
|
||||
public class CustomUserDetailsServiceIntegrationTest {
|
||||
|
||||
public static final String USERNAME = "user";
|
||||
public static final String PASSWORD = "pass";
|
||||
public static final String USERNAME2 = "user2";
|
||||
private static final String USERNAME = "user";
|
||||
private static final String PASSWORD = "pass";
|
||||
private static final String USERNAME2 = "user2";
|
||||
|
||||
@Autowired
|
||||
UserRepository myUserRepository;
|
||||
private UserRepository myUserRepository;
|
||||
|
||||
@Autowired
|
||||
AuthenticationProvider authenticationProvider;
|
||||
private AuthenticationProvider authenticationProvider;
|
||||
|
||||
@Autowired
|
||||
PasswordEncoder passwordEncoder;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
//
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = MultipleAuthProvidersApplication.class)
|
||||
public class MultipleAuthProvidersApplicationTests {
|
||||
public class MultipleAuthProvidersApplicationIntegrationTest {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
|
@ -21,6 +21,7 @@ import static org.springframework.security.test.web.servlet.request.SecurityMock
|
|||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = MultipleEntryPointsApplication.class)
|
||||
public class MultipleEntryPointsIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext wac;
|
||||
|
||||
|
|
Loading…
Reference in New Issue