View Javadoc

1   package com.atlassian.sal.core.search;
2   
3   import com.atlassian.sal.api.message.Message;
4   import com.atlassian.sal.api.search.ResourceType;
5   import com.atlassian.sal.api.search.SearchMatch;
6   import com.atlassian.sal.api.search.SearchResults;
7   import com.atlassian.sal.core.message.DefaultMessage;
8   import junit.framework.TestCase;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  /**
14   */
15  public class TestSearchResults extends TestCase {
16  
17      public void testErrorsAndMatchesIsNotModifiablel() {
18          SearchResults searchResults = new SearchResults(new ArrayList<Message>());
19          List<Message> errors = searchResults.getErrors();
20          try {
21              errors.add(new DefaultMessage("stuff"));
22              fail();
23          } catch (UnsupportedOperationException e) {
24              //yay!
25          }
26          List<SearchMatch> matches = searchResults.getMatches();
27          try {
28              matches.add(new SearchMatch() {
29  
30                  public String getUrl() {
31                      return null;
32                  }
33  
34                  public String getTitle() {
35                      return null;
36                  }
37  
38                  public String getExcerpt() {
39                      return null;
40                  }
41  
42                  public ResourceType getResourceType() {
43                      return null;
44                  }
45              });
46              fail();
47          } catch (UnsupportedOperationException e) {
48              //yay!
49          }
50      }
51  
52  }