@@ -23,14 +23,14 @@ public class HeaderImplTest {
2323 @ Test
2424 public void shouldHaveUnmodifiableTreeWhenInstantiatedWithNonNullTree () throws Exception {
2525 exception .expect (UnsupportedOperationException .class );
26- HeaderImpl header = new HeaderImpl (new HashMap <String , JsonNode >());
26+ HeaderImpl header = new HeaderImpl (null , null , null , null , new HashMap <String , JsonNode >());
2727 header .getTree ().put ("something" , null );
2828 }
2929
3030 @ Test
3131 public void shouldHaveUnmodifiableTreeWhenInstantiatedWithNullTree () throws Exception {
3232 exception .expect (UnsupportedOperationException .class );
33- HeaderImpl header = new HeaderImpl (null );
33+ HeaderImpl header = new HeaderImpl (null , null , null , null , null );
3434 header .getTree ().put ("something" , null );
3535 }
3636
@@ -39,111 +39,32 @@ public void shouldHaveTree() throws Exception {
3939 HashMap <String , JsonNode > map = new HashMap <>();
4040 JsonNode node = NullNode .getInstance ();
4141 map .put ("key" , node );
42- HeaderImpl header = new HeaderImpl (map );
42+ HeaderImpl header = new HeaderImpl (null , null , null , null , map );
4343
4444 assertThat (header .getTree (), is (notNullValue ()));
4545 assertThat (header .getTree (), is (IsMapContaining .hasEntry ("key" , node )));
4646 }
4747
4848 @ Test
49- public void shouldGetHS256Algorithm () throws Exception {
50- JsonNode algNode = new TextNode ("HS256" );
51- HashMap <String , JsonNode > tree = new HashMap <>();
52- tree .put ("alg" , algNode );
53- HeaderImpl header = new HeaderImpl (tree );
49+ public void shouldGetAlgorithm () throws Exception {
50+ HeaderImpl header = new HeaderImpl ("HS256" , null , null , null , null );
5451
5552 assertThat (header , is (notNullValue ()));
5653 assertThat (header .getAlgorithm (), is (notNullValue ()));
5754 assertThat (header .getAlgorithm (), is ("HS256" ));
5855 }
5956
60- @ Test
61- public void shouldGetHS384Algorithm () throws Exception {
62- JsonNode algNode = new TextNode ("HS384" );
63- HashMap <String , JsonNode > tree = new HashMap <>();
64- tree .put ("alg" , algNode );
65- HeaderImpl header = new HeaderImpl (tree );
66-
67- assertThat (header , is (notNullValue ()));
68- assertThat (header .getAlgorithm (), is (notNullValue ()));
69- assertThat (header .getAlgorithm (), is ("HS384" ));
70- }
71-
72- @ Test
73- public void shouldGetHS512Algorithm () throws Exception {
74- JsonNode algNode = new TextNode ("HS512" );
75- HashMap <String , JsonNode > tree = new HashMap <>();
76- tree .put ("alg" , algNode );
77- HeaderImpl header = new HeaderImpl (tree );
78-
79- assertThat (header , is (notNullValue ()));
80- assertThat (header .getAlgorithm (), is (notNullValue ()));
81- assertThat (header .getAlgorithm (), is ("HS512" ));
82- }
83-
84- @ Test
85- public void shouldGetRS256Algorithm () throws Exception {
86- JsonNode algNode = new TextNode ("RS256" );
87- HashMap <String , JsonNode > tree = new HashMap <>();
88- tree .put ("alg" , algNode );
89- HeaderImpl header = new HeaderImpl (tree );
90-
91- assertThat (header , is (notNullValue ()));
92- assertThat (header .getAlgorithm (), is (notNullValue ()));
93- assertThat (header .getAlgorithm (), is ("RS256" ));
94- }
95-
96- @ Test
97- public void shouldGetRS384Algorithm () throws Exception {
98- JsonNode algNode = new TextNode ("RS384" );
99- HashMap <String , JsonNode > tree = new HashMap <>();
100- tree .put ("alg" , algNode );
101- HeaderImpl header = new HeaderImpl (tree );
102-
103- assertThat (header , is (notNullValue ()));
104- assertThat (header .getAlgorithm (), is (notNullValue ()));
105- assertThat (header .getAlgorithm (), is ("RS384" ));
106- }
107-
108- @ Test
109- public void shouldGetRS512Algorithm () throws Exception {
110- JsonNode algNode = new TextNode ("RS512" );
111- HashMap <String , JsonNode > tree = new HashMap <>();
112- tree .put ("alg" , algNode );
113- HeaderImpl header = new HeaderImpl (tree );
114-
115- assertThat (header , is (notNullValue ()));
116- assertThat (header .getAlgorithm (), is (notNullValue ()));
117- assertThat (header .getAlgorithm (), is ("RS512" ));
118- }
119-
120- @ Test
121- public void shouldGetNoneAlgorithm () throws Exception {
122- JsonNode algNode = new TextNode ("none" );
123- HashMap <String , JsonNode > tree = new HashMap <>();
124- tree .put ("alg" , algNode );
125- HeaderImpl header = new HeaderImpl (tree );
126-
127- assertThat (header , is (notNullValue ()));
128- assertThat (header .getAlgorithm (), is (notNullValue ()));
129- assertThat (header .getAlgorithm (), is ("none" ));
130- }
131-
13257 @ Test
13358 public void shouldGetNullAlgorithmIfMissing () throws Exception {
134- HashMap <String , JsonNode > tree = new HashMap <>();
135- HeaderImpl header = new HeaderImpl (tree );
59+ HeaderImpl header = new HeaderImpl (null , null , null , null , null );
13660
13761 assertThat (header , is (notNullValue ()));
13862 assertThat (header .getAlgorithm (), is (nullValue ()));
13963 }
14064
14165 @ Test
14266 public void shouldGetType () throws Exception {
143- JsonNode typNode = new TextNode ("jwt" );
144- HashMap <String , JsonNode > tree = new HashMap <>();
145- tree .put ("typ" , typNode );
146- HeaderImpl header = new HeaderImpl (tree );
67+ HeaderImpl header = new HeaderImpl (null , "jwt" , null , null , null );
14768
14869 assertThat (header , is (notNullValue ()));
14970 assertThat (header .getType (), is (notNullValue ()));
@@ -152,40 +73,32 @@ public void shouldGetType() throws Exception {
15273
15374 @ Test
15475 public void shouldGetNullTypeIfMissing () throws Exception {
155- HashMap <String , JsonNode > tree = new HashMap <>();
156- HeaderImpl header = new HeaderImpl (tree );
76+ HeaderImpl header = new HeaderImpl (null , null , null , null , null );
15777
15878 assertThat (header , is (notNullValue ()));
15979 assertThat (header .getType (), is (nullValue ()));
16080 }
16181
16282 @ Test
16383 public void shouldGetContentType () throws Exception {
164- JsonNode ctyNode = new TextNode ("jws" );
165- HashMap <String , JsonNode > tree = new HashMap <>();
166- tree .put ("cty" , ctyNode );
167- HeaderImpl header = new HeaderImpl (tree );
84+ HeaderImpl header = new HeaderImpl (null , null , "content" , null , null );
16885
16986 assertThat (header , is (notNullValue ()));
17087 assertThat (header .getContentType (), is (notNullValue ()));
171- assertThat (header .getContentType (), is ("jws " ));
88+ assertThat (header .getContentType (), is ("content " ));
17289 }
17390
17491 @ Test
17592 public void shouldGetNullContentTypeIfMissing () throws Exception {
176- HashMap <String , JsonNode > tree = new HashMap <>();
177- HeaderImpl header = new HeaderImpl (tree );
93+ HeaderImpl header = new HeaderImpl (null , null , null , null , null );
17894
17995 assertThat (header , is (notNullValue ()));
18096 assertThat (header .getContentType (), is (nullValue ()));
18197 }
18298
18399 @ Test
184100 public void shouldGetKeyId () throws Exception {
185- JsonNode kidNode = new TextNode ("key" );
186- HashMap <String , JsonNode > tree = new HashMap <>();
187- tree .put ("kid" , kidNode );
188- HeaderImpl header = new HeaderImpl (tree );
101+ HeaderImpl header = new HeaderImpl (null , null , null , "key" , null );
189102
190103 assertThat (header , is (notNullValue ()));
191104 assertThat (header .getKeyId (), is (notNullValue ()));
@@ -194,8 +107,7 @@ public void shouldGetKeyId() throws Exception {
194107
195108 @ Test
196109 public void shouldGetNullKeyIdIfMissing () throws Exception {
197- HashMap <String , JsonNode > tree = new HashMap <>();
198- HeaderImpl header = new HeaderImpl (tree );
110+ HeaderImpl header = new HeaderImpl (null , null , null , null , null );
199111
200112 assertThat (header , is (notNullValue ()));
201113 assertThat (header .getKeyId (), is (nullValue ()));
@@ -205,7 +117,7 @@ public void shouldGetNullKeyIdIfMissing() throws Exception {
205117 public void shouldGetExtraClaim () throws Exception {
206118 Map <String , JsonNode > tree = new HashMap <>();
207119 tree .put ("extraClaim" , new TextNode ("extraValue" ));
208- HeaderImpl header = new HeaderImpl (tree );
120+ HeaderImpl header = new HeaderImpl (null , null , null , null , tree );
209121
210122 assertThat (header , is (notNullValue ()));
211123 assertThat (header .getHeaderClaim ("extraClaim" ), is (instanceOf (ClaimImpl .class )));
@@ -215,7 +127,7 @@ public void shouldGetExtraClaim() throws Exception {
215127 @ Test
216128 public void shouldGetNotNullExtraClaimIfMissing () throws Exception {
217129 Map <String , JsonNode > tree = new HashMap <>();
218- HeaderImpl header = new HeaderImpl (tree );
130+ HeaderImpl header = new HeaderImpl (null , null , null , null , tree );
219131
220132 assertThat (header , is (notNullValue ()));
221133 assertThat (header .getHeaderClaim ("missing" ), is (notNullValue ()));
0 commit comments