### Question:
BeanFactory { public <T> T create(Class<T> type, String... fixtureNames) { return create(DEFAULT_REFERENCE_PREFIX, type, fixtureNames); } BeanFactory();  BeanFactory(ObjectMapper objectMapper, FixtureScanner scanner);  BeanFactory(ObjectMapper objectMapper); void init(); void registerAll(Map<String, JsonNode> fixtures); void registerFixture(String name, JsonNode fixture); void unregisterAll(Collection<String> names); void unregisterFixture(String name); void setAllowUnknownProperties(boolean allowUnknownProperties); String createAsString(String... fixtureNames); String createAsString(boolean pretty, String... fixtureNames); String createAsString(boolean pretty, List<String> fixtureNames); String createAsString(boolean pretty, JsonNode jsonNode); T create(Class<T> type, String... fixtureNames); T create(JavaType type, String... fixtureNames); T create(String referencePrefix, JavaType type, String... fixtureNames); T create(String referencePrefix, Class<T> type, String... fixtureNames); Optional<JsonNode> getFixtureAsJsonNode(String fixtureName); static final String DEFAULT_REFERENCE_PREFIX; }### Answer:
@Test(expected = IllegalArgumentException.class) public void failsToCreateEmptyBean() throws Exception { factory.create(MyBean.class); }
@Test(expected = IllegalArgumentException.class) public void doesNotAllowInvalidPropertiesByDefault() throws Exception { factory.create(MyBean.class, "fixture1", "fixture4"); }
@Test public void canReadByJavaType() throws Exception { CollectionType collectionType = CollectionType.construct(List.class, SimpleType.construct(MyBean.class)); List<MyBean> beans = factory.create(collectionType, "fixture6"); assertThat(beans).hasSize(3); assertThat(beans.get(0).getStringProperty()).isEqualTo("property1"); assertThat(beans.get(0).getIntProperty()).isEqualTo(1); assertThat(beans.get(1).getStringProperty()).isEqualTo("property2"); assertThat(beans.get(1).getIntProperty()).isEqualTo(2); assertThat(beans.get(2).getStringProperty()).isEqualTo("property3"); assertThat(beans.get(2).getIntProperty()).isEqualTo(3); }
@Test(expected = IllegalArgumentException.class) public void doesNotAllowEmptyFixtureListIfJavaTypeIsUsed() throws Exception { CollectionType collectionType = CollectionType.construct(List.class, SimpleType.construct(MyBean.class)); factory.create(collectionType); }