55import org .hamcrest .collection .IsMapContaining ;
66import org .junit .Test ;
77
8- import java .util .Arrays ;
98import java .util .Collections ;
109import java .util .List ;
1110import java .util .Map ;
1514
1615public class ClientTest extends JsonTest <Client > {
1716
18- private static final String json = "{\" name\" :\" name\" ,\" client_secret\" :\" secret\" ,\" app_type\" :\" type\" ,\" logo_uri\" :\" uri\" ,\" oidc_conformant\" :true,\" callbacks\" :[\" value\" ],\" allowed_origins\" :[\" value\" ],\" client_aliases\" :[\" value\" ],\" allowed_clients\" :[\" value\" ],\" allowed_logout_urls\" :[\" value\" ],\" jwt_configuration\" :{\" lifetime_in_seconds\" :100,\" scopes\" :\" openid\" ,\" alg\" :\" alg\" },\" encryption_key\" :{\" pub\" :\" pub\" ,\" cert\" :\" cert\" },\" sso\" :true,\" sso_disabled\" :true,\" custom_login_page_on\" :true,\" custom_login_page\" :\" custom\" ,\" custom_login_page_preview\" :\" preview\" ,\" form_template\" :\" template\" ,\" addons\" :{\" rms\" :{},\" mscrm\" :{},\" slack\" :{},\" layer\" :{}},\" token_endpoint_auth_method\" :\" method\" ,\" client_metadata\" :{\" key\" :\" value\" },\" mobile\" :{\" android\" :{\" app_package_name\" :\" pkg\" ,\" sha256_cert_fingerprints\" :[\" 256\" ]},\" ios\" :{\" team_id\" :\" team\" ,\" app_bundle_identifier\" :\" id\" }}}" ;
17+ private static final String json = "{\" name\" :\" name\" ,\" description \" : \" description \" , \" client_secret\" :\" secret\" ,\" app_type\" :\" type\" ,\" logo_uri\" :\" uri\" ,\" oidc_conformant\" :true,\" callbacks\" :[\" value\" ],\" allowed_origins\" :[\" value\" ],\" client_aliases\" :[\" value\" ],\" allowed_clients\" :[\" value\" ],\" allowed_logout_urls\" :[\" value\" ],\" jwt_configuration\" :{\" lifetime_in_seconds\" :100,\" scopes\" :\" openid\" ,\" alg\" :\" alg\" },\" encryption_key\" :{\" pub\" :\" pub\" ,\" cert\" :\" cert\" },\" sso\" :true,\" sso_disabled\" :true,\" custom_login_page_on\" :true,\" custom_login_page\" :\" custom\" ,\" custom_login_page_preview\" :\" preview\" ,\" form_template\" :\" template\" ,\" addons\" :{\" rms\" :{},\" mscrm\" :{},\" slack\" :{},\" layer\" :{}},\" token_endpoint_auth_method\" :\" method\" ,\" client_metadata\" :{\" key\" :\" value\" },\" mobile\" :{\" android\" :{\" app_package_name\" :\" pkg\" ,\" sha256_cert_fingerprints\" :[\" 256\" ]},\" ios\" :{\" team_id\" :\" team\" ,\" app_bundle_identifier\" :\" id\" }}}" ;
1918 private static final String readOnlyJson = "{\" client_id\" :\" clientId\" ,\" is_first_party\" :true,\" is_heroku_app\" :true,\" signing_keys\" :[{\" cert\" :\" ce\" ,\" pkcs7\" :\" pk\" ,\" subject\" :\" su\" }]}" ;
2019
2120 @ Test
2221 public void shouldSerialize () throws Exception {
2322 Client client = new Client ("ignored" );
2423
2524 client .setName ("name" );
25+ client .setDescription ("description" );
2626 client .setClientSecret ("secret" );
2727 client .setAppType ("type" );
2828 client .setLogoUri ("uri" );
2929 client .setOIDCConformant (true );
30- List <String > stringList = Arrays . asList ("value" );
30+ List <String > stringList = Collections . singletonList ("value" );
3131 client .setCallbacks (stringList );
3232 client .setAllowedOrigins (stringList );
3333 client .setClientAliases (stringList );
@@ -46,24 +46,25 @@ public void shouldSerialize() throws Exception {
4646 Addons addons = new Addons (new Addon (), new Addon (), new Addon (), new Addon ());
4747 client .setAddons (addons );
4848 client .setTokenEndpointAuthMethod ("method" );
49- Map <String , Object > metadata = Collections .singletonMap ("key" , ( Object ) "value" );
49+ Map <String , Object > metadata = Collections .singletonMap ("key" , "value" );
5050 client .setClientMetadata (metadata );
51- Mobile mobile = new Mobile (new Android ("pkg" , Arrays . asList ("256" )), new IOS ("team" , "id" ));
51+ Mobile mobile = new Mobile (new Android ("pkg" , Collections . singletonList ("256" )), new IOS ("team" , "id" ));
5252 client .setMobile (mobile );
5353
5454 String serialized = toJSON (client );
5555 assertThat (serialized , is (notNullValue ()));
5656
5757 assertThat (serialized , JsonMatcher .hasEntry ("name" , "name" ));
58+ assertThat (serialized , JsonMatcher .hasEntry ("description" , "description" ));
5859 assertThat (serialized , JsonMatcher .hasEntry ("client_secret" , "secret" ));
5960 assertThat (serialized , JsonMatcher .hasEntry ("app_type" , "type" ));
6061 assertThat (serialized , JsonMatcher .hasEntry ("logo_uri" , "uri" ));
6162 assertThat (serialized , JsonMatcher .hasEntry ("oidc_conformant" , true ));
62- assertThat (serialized , JsonMatcher .hasEntry ("callbacks" , Arrays . asList ("value" )));
63- assertThat (serialized , JsonMatcher .hasEntry ("allowed_origins" , Arrays . asList ("value" )));
64- assertThat (serialized , JsonMatcher .hasEntry ("client_aliases" , Arrays . asList ("value" )));
65- assertThat (serialized , JsonMatcher .hasEntry ("allowed_clients" , Arrays . asList ("value" )));
66- assertThat (serialized , JsonMatcher .hasEntry ("allowed_logout_urls" , Arrays . asList ("value" )));
63+ assertThat (serialized , JsonMatcher .hasEntry ("callbacks" , Collections . singletonList ("value" )));
64+ assertThat (serialized , JsonMatcher .hasEntry ("allowed_origins" , Collections . singletonList ("value" )));
65+ assertThat (serialized , JsonMatcher .hasEntry ("client_aliases" , Collections . singletonList ("value" )));
66+ assertThat (serialized , JsonMatcher .hasEntry ("allowed_clients" , Collections . singletonList ("value" )));
67+ assertThat (serialized , JsonMatcher .hasEntry ("allowed_logout_urls" , Collections . singletonList ("value" )));
6768 assertThat (serialized , JsonMatcher .hasEntry ("jwt_configuration" , notNullValue ()));
6869 assertThat (serialized , JsonMatcher .hasEntry ("encryption_key" , notNullValue ()));
6970 assertThat (serialized , JsonMatcher .hasEntry ("sso" , true ));
@@ -84,6 +85,7 @@ public void shouldDeserialize() throws Exception {
8485 assertThat (client , is (notNullValue ()));
8586
8687 assertThat (client .getName (), is ("name" ));
88+ assertThat (client .getDescription (), is ("description" ));
8789 assertThat (client .getClientSecret (), is ("secret" ));
8890 assertThat (client .getAppType (), is ("type" ));
8991 assertThat (client .getLogoUri (), is ("uri" ));
@@ -109,7 +111,7 @@ public void shouldDeserialize() throws Exception {
109111
110112 assertThat (client .getAddons (), is (notNullValue ()));
111113 assertThat (client .getTokenEndpointAuthMethod (), is ("method" ));
112- assertThat (client .getClientMetadata (), IsMapContaining .hasEntry ("key" , ( Object ) "value" ));
114+ assertThat (client .getClientMetadata (), IsMapContaining .hasEntry ("key" , "value" ));
113115 assertThat (client .getMobile (), is (notNullValue ()));
114116 }
115117
0 commit comments