@Test public void given_a_discriminator_is_declared_on_iterable_field_then_views_should_filter_for_specified_property() { CouchDbConnector db = mock(CouchDbConnector.class); DiscriminatingRepo repo = new DiscriminatingRepo(db); Map<String, DesignDocument.View> result = gen.generateViews(repo); assertEquals(expectedArrayFunctionWithDiscriminator, result.get("by_domainName").getMap()); }
public Map<String, DesignDocument.View> generateViews( final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository) .getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod(repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } return views; }
SimpleViewGenerator { public Map<String, DesignDocument.View> generateViews( final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository) .getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod(repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } return views; } }
SimpleViewGenerator { public Map<String, DesignDocument.View> generateViews( final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository) .getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod(repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } return views; }  }
SimpleViewGenerator { public Map<String, DesignDocument.View> generateViews( final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository) .getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod(repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } 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); }
SimpleViewGenerator { public Map<String, DesignDocument.View> generateViews( final Object repository) { final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>(); final Class<?> repositoryClass = repository.getClass(); final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ((CouchDbRepositorySupport<?>) repository) .getHandledType() : null; createDeclaredViews(views, repositoryClass); eachMethod(repositoryClass, new Predicate<Method>() { public boolean apply(Method input) { if (hasAnnotation(input, GenerateView.class)) { generateView(views, input, handledType); } return false; } }); if (handledType != null) { views.putAll(generateViewsFromPersistentType(handledType)); } 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);  }