This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
@NoArgsConstructor | |
@AllArgsConstructor | |
public class SignupForm { | |
@NotEmpty(message = "{validation.id.NotEmpty}") | |
@Pattern(regexp = "^[a-zA-Z]{1}[a-zA-Z0-9_]{4,20}$", message = "{validation.id.Pattern}") | |
private String id; | |
@NotEmpty(message = "{validation.email.NotEmpty}") | |
@Email(message = "{validation.email.Email}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Before | |
public Member getMemberIfExceedsBasePrice(Order order, long basePrice) { | |
if (order != null && order.getTotalPrice() > basePrice) { | |
return order.getMember(); | |
} | |
} | |
// After | |
public Optional<Member> getMemberIfExceedsBasePrice(Order order, long basePrice) { | |
return Optional.ofNullable(order) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Id starts with alphabet and alphanumeric characters. Minimum length 4, Maximum length 20. | |
@Pattern(regexp = "^[a-zA-Z]{1}[a-zA-Z0-9_]{4,20}$") | |
// Password requires at least number, capital character, non-capital character and special character. Minimum length 8, Maximum length 20. | |
// ^ # start-of-string | |
// (?=.*[0-9]) # a digit must occur at least once | |
// (?=.*[a-z]) # a lower case letter must occur at least once | |
// (?=.*[A-Z]) # an upper case letter must occur at least once | |
// (?=.*[@#$%^&+=]) # a special character must occur at least once | |
// (?=\S+$) # no whitespace allowed in the entire string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void testLogin() throws Exception { | |
this.mockMvc.perform((post("/login").accept(MediaType.ALL).param("id", "admin").param("password", "admin").with(csrf()))) | |
.andDo(print()) | |
.andExpect(status().is3xxRedirection()) | |
.andExpect(request().sessionAttribute("SPRING_SECURITY_LAST_EXCEPTION", instanceOf(BadCredentialsException.class))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean kiss = true; | |
boolean hug = true; | |
boolean slap = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class SpringConfig { | |
@Profile("development") | |
@Bean | |
public TestComponent testComponent() { | |
return new DevTestComponent(); | |
} | |
@Profile({ "production", "staging" }) | |
@Bean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run command format | |
$ docker run -d -p <host port>:<container port> -v <host volume>:<container volume> --name <container name> <image> | |
# sample | |
$ docker run -d -p 8080:8080 -v /host/data:/container/data --name my_container my_container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming an Ubuntu Docker image and there's no ENTRYPOINT | |
$ docker run -it <image> /bin/bash | |
# Assuming an Ubuntu Docker image and override ENTRYPOINT | |
$ docker run -it --entrypoint "/bin/bash" <image> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
example json text in dir/input.json | |
{ "key": "value" } | |
*/ | |
def props = readJSON file: 'dir/input.json' | |
assert props['key'] == 'value' | |
assert props.key == 'value' | |
def props = readJSON text: '{ "key": "value" }' | |
assert props['key'] == 'value' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pattern = "\\(([^)]+)\\)" | |
def matcher = "test string (abc)" =~ pattern | |
// matcher[0][1] will return abc | |
println("extracted string : " + matcher[0][1]) |
NewerOlder