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
mockery.when(() -> servlet.process( | |
ImmutableMap.of( | |
"code", new String[]{ codeValue}, | |
"state", new String[]{ state }), | |
"http://rescyoume/oauth", | |
response)). | |
then(expect -> { | |
expect.oneOf(stravaAuthenticator).fetchDetails(codeValue, oAuthAccount, clientState, "http://rescyoume/oauth"); | |
expect.will(returnValue(oAuthDetails)); | |
expect.oneOf(db).save(oAuthDetails); |
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 class TransformingMatcher<U, T> extends TypeSafeMatcher<U> { | |
private final Matcher<T> base; | |
private final Function<? super U, ? extends T> function; | |
public TransformingMatcher(Matcher<T> base, Function<? super U, ? extends T> function) { | |
this.base = base; | |
this.function = function; | |
} | |
@Override |
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
@Value public class User { | |
public final Optional<String> id; | |
public final DateTime createdDate; | |
public final String firstName; | |
public final String lastName; | |
@Wither public final Country country; | |
@Wither public final PhoneNumber phoneNumber; | |
@Wither public final String email; | |
@Wither public final Optional<String> stravaId; |
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
@Test | |
public void saves_results() throws IOException { | |
ImmutableList<Associate> associates = ImmutableList.of( | |
new Associate("id1", "fn1", "ln2"), | |
new Associate("id2", "fn1", "ln2")); | |
mockery.given((given) -> { | |
given.oneOf(source).findAssociates("token"); | |
given.will(returnValue(associates.stream())); | |
}); |
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
String user = "{" + | |
"isAccountNonLocked : true," + | |
"isEnabled : true," + | |
"isAccountNonExpired : true," + | |
"isPasswordProvided : true," + | |
"isCredentialsNonExpired : true," + | |
"}"; | |
mockery.checking(new JsonExpectations(user)); |
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
private User activeUser(Customer customer) { | |
return mock(User.class, | |
"isAccountNonLocked", true, | |
"isEnabled", true, | |
"isAccountNonExpired", true, | |
"isPasswordProvided", true, | |
"isCredentialsNonExpired", true, | |
"getCustomer", customer, | |
"getAuthorities", ImmutableList.of() | |
); |
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
private User activeUser(final Customer customer) { | |
return mock(User.class, | |
new Object() { | |
boolean isAccountNonLocked = true; | |
boolean isEnabled = true; | |
boolean isAccountNonExpired = true; | |
boolean isPasswordProvided = true; | |
boolean isCredentialsNonExpired = true; | |
Customer getCustomer = customer; | |
ImmutableList<?> getAuthorities = ImmutableList.of(); |
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
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class FakeValueTest { | |
public abstract class ValueToBeFaked { | |
public abstract String name(); | |
public abstract String operation(int arg); | |
public abstract String getProperty(); |
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
#!/bin/bash | |
set -e | |
# Uses javap to see whether there are any semantic differences between Java classes in different classpaths | |
classpath1=$1 | |
classpath2=$2 | |
result=0 | |
for class in ${@:3}; do |
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 class JMock8Test { | |
Mockery8 mockery = new Mockery8(); | |
Service service = mockery.mock(Service.class); | |
public static interface Service { | |
public int add(int a, int b); | |
} |
OlderNewer