[BAEL-16005] moved articles from libraries to libraries-security and libraries testing. Renamed TinkUnitTest to TinkLiveTest failing due InvalidKeyException

This commit is contained in:
Sjmillington
2019-08-13 16:47:26 +01:00
parent 23cc42b0f1
commit 13f818cccf
53 changed files with 400 additions and 193 deletions

View File

@@ -0,0 +1,19 @@
package com.baeldung.serenity.github;
public class GitHubUser {
private String login;
public GitHubUser() {
super();
}
public String getLogin() {
return login;
}
public void setLogin(final String login) {
this.login = login;
}
}

View File

@@ -0,0 +1,16 @@
package com.baeldung.serenity.membership;
/**
* @author aiet
*/
public enum Commodity {
MacBookPro(1499), GoProHero5(400);
public final int price;
Commodity(int price) {
this.price = price;
}
}

View File

@@ -0,0 +1,38 @@
package com.baeldung.serenity.membership;
import static com.baeldung.serenity.membership.MemberGrade.Bronze;
import static com.baeldung.serenity.membership.MemberGrade.Gold;
import static com.baeldung.serenity.membership.MemberGrade.Silver;
/**
* @author aiet
*/
public class Member {
private int points;
private Member(int points) {
if (points < 0)
throw new IllegalArgumentException("points must not be negative!");
this.points = points;
}
public static Member withInitialPoints(int initialPoints) {
return new Member(initialPoints);
}
public MemberGrade getGrade() {
if (points < 1000)
return Bronze;
else if (points >= 1000 && points < 5000)
return Silver;
else
return Gold;
}
public void spend(int moneySpent) {
points += moneySpent / 10;
}
}

View File

@@ -0,0 +1,10 @@
package com.baeldung.serenity.membership;
/**
* @author aiet
*/
public enum MemberGrade {
Bronze, Silver, Gold;
}

View File

@@ -0,0 +1,29 @@
package com.baeldung.serenity.spring;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
* @author aiet
*/
@RequestMapping(value = "/adder", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
public class AdderController {
private AdderService adderService;
public AdderController(AdderService adderService) {
this.adderService = adderService;
}
@GetMapping("/current")
public int currentNum() {
return adderService.currentBase();
}
@PostMapping
public int add(@RequestParam int num) {
return adderService.add(num);
}
}

View File

@@ -0,0 +1,25 @@
package com.baeldung.serenity.spring;
import org.springframework.stereotype.Service;
@Service
public class AdderService {
private int num;
public void baseNum(int base) {
this.num = base;
}
public int currentBase() {
return num;
}
public int add(int adder) {
return this.num + adder;
}
public int accumulate(int adder) {
return this.num += adder;
}
}

View File

@@ -0,0 +1,26 @@
package com.baeldung.serenity.spring;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
* @author aiet
*/
@RequestMapping(value = "/adder", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
public class PlainAdderController {
private final int currentNumber = RandomUtils.nextInt();
@GetMapping("/current")
public int currentNum() {
return currentNumber;
}
@PostMapping
public int add(@RequestParam int num) {
return currentNumber + num;
}
}