View Javadoc

1   package com.atlassian.marketplace.client.api;
2   
3   import org.hamcrest.Matchers;
4   import org.junit.Test;
5   
6   import static com.atlassian.fugue.Option.none;
7   import static com.atlassian.fugue.Option.some;
8   import static com.atlassian.marketplace.client.api.ApplicationKey.JIRA;
9   import static com.atlassian.marketplace.client.api.Cost.ALL_PAID;
10  import static com.atlassian.marketplace.client.api.HostingType.CLOUD;
11  import static org.hamcrest.MatcherAssert.assertThat;
12  import static org.hamcrest.Matchers.equalTo;
13  
14  public class ProductQueryTest
15  {
16      @Test
17      public void defaultQueryHasNoApplication()
18      {
19          ProductQuery q = ProductQuery.builder().build();
20          assertThat(q.getApplication(), equalTo(none(ApplicationKey.class)));
21      }
22      
23      @Test
24      public void applicationCanBeSet()
25      {
26          ProductQuery q = ProductQuery.builder().application(some(JIRA)).build();
27          assertThat(q.getApplication(), equalTo(some(JIRA)));
28      }
29      
30      @Test
31      public void defaultQueryHasNoAppBuildNumber()
32      {
33          ProductQuery q = ProductQuery.builder().build();
34          assertThat(q.getAppBuildNumber(), equalTo(none(Integer.class)));
35      }
36      
37      @Test
38      public void appBuildNumberCanBeSet()
39      {
40          ProductQuery q = ProductQuery.builder().appBuildNumber(some(1000)).build();
41          assertThat(q.getAppBuildNumber(), equalTo(some(1000)));
42      }
43  
44      @Test
45      public void defaultQueryHasNoCost()
46      {
47          AddonQuery q = AddonQuery.builder().build();
48          assertThat(q.getCost(), Matchers.<Cost>emptyIterable());
49      }
50      
51      @Test
52      public void costCanBeSet()
53      {
54          AddonQuery q = AddonQuery.builder().cost(some(ALL_PAID)).build();
55          assertThat(q.getCost(), equalTo(some(ALL_PAID)));
56      }
57  
58      @Test
59      public void defaultQueryHasNoHosting()
60      {
61          ProductQuery q = ProductQuery.builder().build();
62          assertThat(q.getHosting(), equalTo(none(HostingType.class)));
63      }
64      
65      @Test
66      public void hostingCanBeSet()
67      {
68          ProductQuery q = ProductQuery.builder().hosting(some(CLOUD)).build();
69          assertThat(q.getHosting(), equalTo(some(CLOUD)));
70      }
71      
72      @Test
73      public void defaultQueryHasWithVersionFalse()
74      {
75          ProductQuery q = ProductQuery.builder().build();
76          assertThat(q.isWithVersion(), equalTo(false));
77      }
78      
79      @Test
80      public void withVersionCanBeSet()
81      {
82          ProductQuery q = ProductQuery.builder().withVersion(true).build();
83          assertThat(q.isWithVersion(), equalTo(true));
84      }
85  
86      @Test
87      public void defaultQueryHasDefaultBounds()
88      {
89          ProductQuery q = ProductQuery.builder().build();
90          assertThat(q.getBounds(), equalTo(QueryBounds.defaultBounds()));
91      }
92  
93      @Test
94      public void boundsCanBeSet()
95      {
96          QueryBounds b = QueryBounds.offset(2).withLimit(some(3));
97          ProductQuery q = ProductQuery.builder().bounds(b).build();
98          assertThat(q.getBounds(), equalTo(b));
99      }
100 }