Skip to content

Commit 8c0ce48

Browse files
mansi2392pivovarit
authored andcommitted
BAEL-1045 Lambda Behave (eugenp#2456)
* Example Code For Evaluation Article This is an example code for the evaluation article on "Different Types of Bean Injection in Spring" * Added unit tests * Minor changes to application context * Removed code committed for evaluation article * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Code Formatting and solving build issue * BAEL-944 Resolving build issue due to change in Spring version * BAEL-944 Resolving build issue * BAEL-944 Formatting code * BAEL-944 Moving tests to correct package * BAEL-944 Moving tests to correct package * BAEL-944 Replacing @RequestMapping by @GetMapping * BAEL-944 Remove unnecessary attribute name, "value" in annotations * BAEL-79 Intro to Activiti with Spring * BAEL-79 Intro to Activiti with Spring * BAEL-79 Adding activiti module to the parent modules * BAEL-79 Using latest version * BAEL-79 Update Spring boot version that works with Activiti * BAEL-79 Replace RequestMapping with GetMapping * BAEL-79 Use Java 8 Syntax * BAEL-79 Formatting * BAEL-79 changed module name * BAEL-378 A Guide to Activiti with Java * BAEL-79 Fixed unit tests * BAEL-79 Simplified the process * BAEL-79 Fix test cases * BAEL-1045 Lambda Behave * BAEL-1045 Lambda Behave * BAEL-1045 Lambda Behave
1 parent 822e868 commit 8c0ce48

3 files changed

Lines changed: 83 additions & 0 deletions

File tree

‎testing/pom.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
</parent>
1414

1515
<dependencies>
16+
<dependency>
17+
<groupId>com.insightfullogic</groupId>
18+
<artifactId>lambda-behave</artifactId>
19+
<version>0.4</version>
20+
</dependency>
1621
<dependency>
1722
<groupId>com.google.guava</groupId>
1823
<artifactId>guava</artifactId>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.lambdabehave;
2+
3+
public class Calculator {
4+
5+
private int x;
6+
private int y;
7+
8+
Calculator(int x, int y) {
9+
this.x = x;
10+
this.y = y;
11+
}
12+
13+
public int add() {
14+
return this.x + this.y;
15+
}
16+
17+
public int divide(int a, int b) {
18+
return a / b;
19+
}
20+
21+
public int add(int a, int b) {
22+
return a + b;
23+
}
24+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.baeldung.lambdabehave;
2+
3+
import com.insightfullogic.lambdabehave.JunitSuiteRunner;
4+
import com.insightfullogic.lambdabehave.Suite;
5+
import com.insightfullogic.lambdabehave.generators.Generator;
6+
import com.insightfullogic.lambdabehave.generators.SourceGenerator;
7+
import org.junit.runner.RunWith;
8+
9+
@RunWith(JunitSuiteRunner.class)
10+
public class CalculatorTest {
11+
12+
private Calculator calculator;
13+
14+
{
15+
Suite.describe("Lambda behave example tests", it -> {
16+
17+
it.isSetupWith(() -> {
18+
calculator = new Calculator(1, 2);
19+
});
20+
it.should("Add the given numbers", expect -> {
21+
expect.that(calculator.add()).is(3);
22+
});
23+
it.should("Throw an exception if divide by 0", expect -> {
24+
expect.exception(ArithmeticException.class, () -> {
25+
calculator.divide(1, 0);
26+
});
27+
});
28+
it.uses(2, 3, 5)
29+
.and(23, 10, 33)
30+
.toShow("%d + %d = %d", (expect, a, b, c) -> {
31+
expect.that(calculator.add(a, b)).is(c);
32+
});
33+
it.requires(2)
34+
.example(Generator.asciiStrings())
35+
.toShow("Reversing a String twice returns the original String", (expect, str) -> {
36+
String same = new StringBuilder(str).reverse()
37+
.reverse()
38+
.toString();
39+
expect.that(same)
40+
.isEqualTo(str);
41+
});
42+
it.requires(2)
43+
.withSource(SourceGenerator.deterministicNumbers(5626689007407L))
44+
.example(Generator.asciiStrings())
45+
.toShow("Reversing a String twice returns the original String", (expect, str) -> {
46+
String same = new StringBuilder(str).reverse()
47+
.reverse()
48+
.toString();
49+
expect.that(same)
50+
.isEqualTo(str);
51+
});
52+
});
53+
}
54+
}

0 commit comments

Comments
 (0)