### Question:
SimpleViewGenerator { public Map<String, DesignDocument.View> generateViewsFromPersistentType( final Class<?> persistentType) { Assert.notNull(persistentType, "persistentType may not be null"); final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); createDeclaredViews(views, persistentType); eachField(persistentType, new Predicate<Field>() { public boolean apply(Field input) { if (hasAnnotation(input, DocumentReferences.class)) { generateView(views, input); } return false; } }); return views; }  DesignDocument.View generateFindByView(String propertyName,
			String typeDiscriminator); DesignDocument.View generateFindByIterableView(String propertyName,
			String typeDiscriminator); DesignDocument.View generateDocRefsAsSetWithOrderByView(
			String backRef, String fieldName, String orderBy,
			String typeDiscriminator); DesignDocument.View generateDocRefsAsSetView(String backRef,
			String fieldName, String typeDiscriminator); Map<String, DesignDocument.View> generateViews(
			final Object repository); Map<String, DesignDocument.View> generateViewsFromPersistentType(
			final Class<?> persistentType); boolean shouldLoadFunctionFromClassPath(String function); static DesignDocument.View loadViewFromString(ObjectMapper objectMapper, String json);  }### Answer:
@Test public void views_should_be_generated_for_persistent_type() { Map<String, DesignDocument.View> result = gen.generateViewsFromPersistentType(SetRefDoc.class); String expectedViewName = "ektorp_docrefs_children"; assertTrue(result.containsKey(expectedViewName)); assertEquals(expectedSetBasedDocrefMapFunction, result.get(expectedViewName).getMap()); }
@Test public void view_should_be_generated_for_fields_with_no_orderBy_specified() { Map<String, DesignDocument.View> result = gen.generateViewsFromPersistentType(SetRefDocWNoOrderBy.class); String expectedViewName = "ektorp_docrefs_children"; assertTrue(result.containsKey(expectedViewName)); assertEquals(expectedSetBasedDocrefMapFunctionWithNoOrderBy, result.get(expectedViewName).getMap()); }
@Test public void views_should_not_be_generated_if_view_is_specified() { Map<String, DesignDocument.View> result = gen.generateViewsFromPersistentType(RefDocWithViewSpecified.class); String expectedViewName = "ektorp_docrefs_children"; assertFalse(result.containsKey(expectedViewName)); }
@Test(expected = ViewGenerationException.class) public void viewGenerationException_should_be_thrown_when_field_is_of_unsupported_type() { gen.generateViewsFromPersistentType(ListRefDoc.class); }