-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a015a8
commit 8e72fff
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/test/java/com/fluentinterface/examples/MapConstructor.java
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
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; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/com/fluentinterface/examples/MapConstructorBuilder.java
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
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
22
src/test/java/com/fluentinterface/examples/MapConstructorTest.java
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
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")); | ||
} | ||
} |