Skip to content

Commit

Permalink
Test to verify issue #13
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmarquis committed Aug 18, 2018
1 parent 2a015a8 commit 8e72fff
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/com/fluentinterface/examples/MapConstructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fluentinterface.examples;

import java.util.Map;

public class MapConstructor {
public Map<String, Object> map;

public MapConstructor(Map<String, Object> map) {
this.map = map;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.fluentinterface.examples;

import com.fluentinterface.ReflectionBuilder;
import com.fluentinterface.annotation.Constructs;
import com.fluentinterface.builder.Builder;

import java.util.Map;

public interface MapConstructorBuilder extends Builder<MapConstructor> {
@Constructs
MapConstructorBuilder of(Map<String, Object> map);

static MapConstructorBuilder aMapConstructor() {
return ReflectionBuilder.implementationFor(MapConstructorBuilder.class).create();
}
}
22 changes: 22 additions & 0 deletions src/test/java/com/fluentinterface/examples/MapConstructorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.fluentinterface.examples;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static com.fluentinterface.examples.MapConstructorBuilder.aMapConstructor;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

public class MapConstructorTest {
@Test
public void instantiatesWithHashMap() {
Map<String, Object> map = new HashMap<>();
map.put("key", "value");

MapConstructor created = aMapConstructor().of(map).build();

assertThat(created.map.get("key"), is("value"));
}
}

0 comments on commit 8e72fff

Please sign in to comment.