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.hamcrest.MatcherAssert | |
import org.hamcrest.Matchers | |
import org.junit.Before | |
import org.junit.Test | |
import org.mockito.InjectMocks | |
import org.mockito.Mock | |
import org.mockito.Mockito | |
import org.mockito.MockitoAnnotations | |
import javax.inject.Inject | |
import javax.servlet.http.HttpServletRequest |
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
module.exports.request = () => { | |
class IncomingMessage extends require('http').IncomingMessage { | |
} | |
const request = new IncomingMessage(); | |
request.__proto__ = require('express')().request; | |
return request; | |
}; | |
module.exports.response = (request) => { | |
class ServerResponse extends require('http').ServerResponse { | |
} |
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
package sample.json; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.databind.ObjectReader; | |
import com.google.common.reflect.TypeToken; | |
import sample.json.Json; | |
import org.springframework.util.StringUtils; | |
import javax.annotation.Nonnull; |
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
package sample.stackanswers; | |
import android.app.Activity | |
import org.junit.Assert | |
import org.junit.Before; | |
import org.junit.Rule | |
import org.junit.Test | |
import org.junit.runner.RunWith; | |
import org.mockito.* | |
import org.mockito.junit.MockitoJUnit |
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 RetrofitTest { | |
@Test | |
public void configure() throws Exception { | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); | |
mapper.registerModule(new JodaModule()); | |
Retrofit retrofit = new Retrofit.Builder() |
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 PageAppearanceSection : ConfigurationSection<IPageAppearance> | |
{ | |
} | |
public interface IPageAppearance | |
{ | |
bool RemoteOnly { get; } | |
IFont Font { get; } | |
IColor Color { get; } | |
} |
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
{ | |
"Version": "2008-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "ec2.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} |
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 pl.brightinventions.databinding.databinding.ActivityRegisterBinding; | |
public class RegisterActivity extends Activity { | |
RegisterApi registerApi; // inject or create remote api | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
ActivityRegisterBinding viewDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_register); |
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
interface Action2<T,Throwable> { | |
void call(T t, Throwable error); | |
} | |
interface RegisterApi { | |
class RegistrationModel { | |
String firstName; | |
} | |
void register(RegistrationModel data, Action2<RegistrationModel, Throwable> result); | |
} |
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 abstract class UserBehavior { | |
private boolean shouldRunDefault; | |
public void byDefault(UserReference reference){} | |
public void onAnonymous(UserReference user){ | |
shouldRunDefault = true; | |
} | |
public void onRegular(RegularUserReference user) { | |
shouldRunDefault = true; |