JdbcClientMetadataProvisioning implements ClientMetadataProvisioning { @Override public ClientMetadata retrieve(String clientId, String zoneId) { logger.debug("Retrieving UI details for client: " + clientId); return jdbcTemplate.queryForObject(CLIENT_METADATA_QUERY, mapper, clientId, zoneId); } JdbcClientMetadataProvisioning(
            final @Qualifier("jdbcClientDetailsService") MultitenantClientServices clientDetailsService,
            final JdbcTemplate jdbcTemplate); @Override List<ClientMetadata> retrieveAll(String zoneId); @Override ClientMetadata retrieve(String clientId, String zoneId); @Override ClientMetadata update(ClientMetadata resource, String zoneId);  }
@Test void createdByPadsTo36Chars() { jdbcTemplate.execute(insertIntoOauthClientDetails(clientId, identityZoneId, "abcdef")); ClientMetadata retrievedClientMetadata = jdbcClientMetadataProvisioning.retrieve( clientId, identityZoneId); assertThat(retrievedClientMetadata.getCreatedBy().length(), is(36)); }
@Test void retrieve() throws Exception { jdbcTemplate.execute(insertIntoOauthClientDetails(clientId, identityZoneId, createdBy)); ClientMetadata clientMetadata = createTestClientMetadata( clientId, true, new URL("http: base64EncodedImg, createdBy); jdbcClientMetadataProvisioning.update(clientMetadata, identityZoneId); ClientMetadata retrievedClientMetadata = jdbcClientMetadataProvisioning.retrieve(clientId, identityZoneId); assertThat(retrievedClientMetadata.getClientId(), is(clientId)); assertThat(retrievedClientMetadata.getIdentityZoneId(), is(identityZoneId)); assertThat(retrievedClientMetadata.isShowOnHomePage(), is(true)); assertThat(retrievedClientMetadata.getAppLaunchUrl(), is(new URL("http: assertThat(retrievedClientMetadata.getAppIcon(), is(base64EncodedImg)); assertThat(retrievedClientMetadata.getCreatedBy(), containsString(createdBy)); }
@Test void retrieve_ThatDoesNotExist() { String clientId1 = randomValueStringGenerator.generate(); String clientId2 = randomValueStringGenerator.generate(); jdbcTemplate.execute(insertIntoOauthClientDetailsWithMetadata(clientId1, "zone1", "createdBy", "appLaunchUrl")); jdbcTemplate.execute(insertIntoOauthClientDetailsWithMetadata(clientId2, "zone2", "createdBy", "appLaunchUrl")); assertDoesNotThrow( () -> jdbcClientMetadataProvisioning.retrieve(clientId1, "zone1")); assertDoesNotThrow( () -> jdbcClientMetadataProvisioning.retrieve(clientId2, "zone2")); assertThrows(EmptyResultDataAccessException.class, () -> jdbcClientMetadataProvisioning.retrieve(clientId1, "zone2")); assertThrows(EmptyResultDataAccessException.class, () -> jdbcClientMetadataProvisioning.retrieve(clientId2, "zone1")); }