Skip to content

Instantly share code, notes, and snippets.

View DominikMostek's full-sized avatar

Dominik Moštěk DominikMostek

View GitHub Profile
HugeIface mock = mock(HugeIface.class);
doReturn(5).when(mock).fooBar();
@Test
public void bar() {
Geometry mock = mock(Geometry.class);
doReturn(12.3).when(mock).tan(pi/2);
}
interface Geometry {
/**
* Must return null when x = pi/2
@Test
public void bar() {
ITest mock = mock(ITest.class);
doReturn(new BigDecimal(5)).when(mock).foo(1);
mock.foo(1L);
}
interface ITest {
interface Entity {
Collection data();
}
interface TraversableEntity {
Entity asEntity(); // this
TraversableEntity traverseTo(Property prop);
}
interface Entity {
Collection data();
}
interface TraversableEntity extends Entity {
TraversableEntity traverseTo(Property prop);
}
interface SingleRecord extends TraversableEntity {
Identifier id();
import com.netflix.config.ConfigurationManager;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixCommandProperties;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
protected Collection<Order> getOrders(List<Message> messages, Map<String, Message> messagesMap, List<Message> messagesToInhibitStorage,
Map<Message, String> messagesToReprocessStorage, Map<String, DateTime> statusDates)
throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException {
@DominikMostek
DominikMostek / ugly.java
Created August 21, 2015 13:56
Never, never do that
for (...) {
if (...) {
try {
try {
if (...) {
if (...) {
for (...) {
if (...) {
} else if (...) {
}
public static <T> Observable<T> takeWhileInclusive(Observable<T> source, Func1<T, Boolean> predicate) {
return source
.publish(selector ->
selector.takeWhile(predicate).concatWith(source.skipWhile(predicate).take(1)));
}
CREATE OR REPLACE PROCEDURE load_expression (dir NVARCHAR2, filename NVARCHAR2, id number) AS
dest_clob CLOB;
src_clob BFILE ;
dst_offset number := 1 ;
src_offset number := 1 ;
lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
warning number;
stmt VARCHAR2(500):= 'CREATE OR REPLACE DIRECTORY MY_DIR AS ' || '''' ||dir|| '''';
BEGIN
DBMS_OUTPUT.ENABLE(100000);