Changeset 4516


Ignore:
Timestamp:
02/14/14 08:58:35 (10 years ago)
Author:
twagoo
Message:

Created unit test for SolrQueryFactory? implementation, and added an extra null check to class itself
Also added cobertura plugin

Location:
vlo/branches/vlo-3.0/vlo-web-app
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/pom.xml

    r4505 r4516  
    223223        </plugins>
    224224    </build>
    225 
     225   
     226    <reporting>
     227        <plugins>
     228            <plugin>
     229                <groupId>org.codehaus.mojo</groupId>
     230                <artifactId>cobertura-maven-plugin</artifactId>
     231                <version>2.6</version>
     232            </plugin>
     233        </plugins>
     234    </reporting>
     235   
    226236    <repositories>
    227237        <repository>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SolrQueryFactoryImpl.java

    r4513 r4516  
    2222import eu.clarin.cmdi.vlo.pojo.FacetSelection;
    2323import java.util.ArrayList;
     24import java.util.Collection;
    2425import java.util.List;
    2526import org.apache.solr.client.solrj.SolrQuery;
     
    3839    public SolrQueryFactoryImpl(VloConfig config) {
    3940        this.config = config;
    40        
     41
    4142        // create the query used to count facets (will never change)
    4243        countQuery = getDefaultFacetQuery();
    4344        countQuery.setRows(0);
    4445    }
    45    
     46
    4647    @Override
    4748    public SolrQuery createFacetQuery(List<FacetSelection> selections, String queryString) {
     
    5758            final List<String> encodedQueries = new ArrayList(selections.size());
    5859            for (FacetSelection selection : selections) {
    59                 String facet = selection.getFacet().getName();
    60                 for (String value : selection.getValue()) {
    61                     encodedQueries.add(String.format("%s:%s", facet, ClientUtils.escapeQueryChars(value)));
     60                final String facetName = selection.getFacet().getName();
     61                final Collection<String> values = selection.getValue();
     62                if (values != null) {
     63                    for (String value : values) {
     64                        encodedQueries.add(String.format("%s:%s", facetName, ClientUtils.escapeQueryChars(value)));
     65                    }
    6266                }
    6367            }
Note: See TracChangeset for help on using the changeset viewer.