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 org.junit.Test;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  import static org.junit.Assert.fail;
14  
15  public class TestSearchResults {
16  
17      @Test
18      public void testErrorsAndMatchesIsNotModifiablel() {
19          SearchResults searchResults = new SearchResults(new ArrayList<Message>());
20          List<Message> errors = searchResults.getErrors();
21          try {
22              errors.add(new DefaultMessage("stuff"));
23              fail();
24          } catch (UnsupportedOperationException e) {
25              //yay!
26          }
27          List<SearchMatch> matches = searchResults.getMatches();
28          try {
29              matches.add(new SearchMatch() {
30  
31                  public String getUrl() {
32                      return null;
33                  }
34  
35                  public String getTitle() {
36                      return null;
37                  }
38  
39                  public String getExcerpt() {
40                      return null;
41                  }
42  
43                  public ResourceType getResourceType() {
44                      return null;
45                  }
46              });
47              fail();
48          } catch (UnsupportedOperationException e) {
49              //yay!
50          }
51      }
52  
53  }