Skip to content

Instantly share code, notes, and snippets.

View DaddyMoe's full-sized avatar

Moses Mansaray DaddyMoe

View GitHub Profile
@DaddyMoe
DaddyMoe / JavaJunitParameterizedTest.java
Last active April 23, 2017 15:26
Java Junit Parameterized tests for when you are not in the mood to repeat yourself DRY: source: https://github.com/junit-team/junit4/wiki/Parameterized-tests
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@DaddyMoe
DaddyMoe / TransportClientSniffingTestMain.java
Created February 19, 2017 02:37
TransportClient setup with Sniffing set to true to discover other nodes in the Elasticsearch cluster Raw
package com.euromoney.elasticsearch;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
public class TransportClientSniffingTestMain {
@DaddyMoe
DaddyMoe / ConvertObjectToEnumOneLineInstantiation.java
Created February 19, 2017 02:36
Converts Class Object to Enum equivalent
public class ConvertObjectToEnumOneLineInstantiation {
/*
* To:
`HIGHLIGHT("highlight", false, "field", false, "title,description,body", null),`
*
* From:
*
`HIGHLIGHT {
@DaddyMoe
DaddyMoe / ShouldHaveAPrivateConstructor.java
Last active December 18, 2017 10:03
Test private constructor - For the days you want to be predantic
/**
* For the days you want to be predantic
*/
@Test
public void shouldHaveAPrivateConstructor() throws Exception {
Constructor constructor = EuroSemanticResponse.class.getDeclaredConstructor();
assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers()));
constructor.setAccessible(true);
constructor.newInstance();