JdbcClientMetadataProvisioning implements ClientMetadataProvisioning { @Override public ClientMetadata update(ClientMetadata resource, String zoneId) { logger.debug("Updating metadata for client: " + resource.getClientId()); updateClientNameIfNotEmpty(resource, zoneId); int updated = jdbcTemplate.update(CLIENT_METADATA_UPDATE, ps -> { int pos = 1; ps.setBoolean(pos++, resource.isShowOnHomePage()); URL appLaunchUrl = resource.getAppLaunchUrl(); ps.setString(pos++, appLaunchUrl == null ? null : appLaunchUrl.toString()); String appIcon = resource.getAppIcon(); if (appIcon != null) { byte[] decodedAppIcon = Base64Utils.decode(appIcon.getBytes()); ps.setBinaryStream(pos++, new ByteArrayInputStream(decodedAppIcon), decodedAppIcon.length); } else { ps.setBinaryStream(pos++, new ByteArrayInputStream(new byte[]{}), 0); } ps.setString(pos++, resource.getClientId()); ps.setString(pos++, zoneId); }); ClientMetadata resultingClientMetadata = retrieve(resource.getClientId(), zoneId); if (updated > 1) { throw new IncorrectResultSizeDataAccessException(1); } return resultingClientMetadata; } 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 constraintViolation_WhenNoMatchingClientFound() throws Exception { ClientMetadata clientMetadata = createTestClientMetadata( randomValueStringGenerator.generate(), true, new URL("http: base64EncodedImg, createdBy); assertThrows(EmptyResultDataAccessException.class, () -> jdbcClientMetadataProvisioning.update(clientMetadata, identityZoneId)); }
@Test void update() throws Exception { jdbcTemplate.execute(insertIntoOauthClientDetails(clientId, identityZoneId)); ClientMetadata newClientMetadata = createTestClientMetadata( clientId, false, new URL("http: base64EncodedImg, createdBy); ClientMetadata updatedClientMetadata = jdbcClientMetadataProvisioning.update(newClientMetadata, identityZoneId); assertThat(updatedClientMetadata.getClientId(), is(clientId)); assertThat(updatedClientMetadata.getIdentityZoneId(), is(identityZoneId)); assertThat(updatedClientMetadata.isShowOnHomePage(), is(newClientMetadata.isShowOnHomePage())); assertThat(updatedClientMetadata.getAppLaunchUrl(), is(newClientMetadata.getAppLaunchUrl())); assertThat(updatedClientMetadata.getAppIcon(), is(newClientMetadata.getAppIcon())); }