@Test
public void shouldApplyPatchChangingSubscriptionOAuthPolicyGrantType() {
Subscription subscription = subscription("group.topic", "subscription")
.withOAuthPolicy(new SubscriptionOAuthPolicy(CLIENT_CREDENTIALS, "myProvider", "repo", null, null))
.build();
PatchData oAuthPolicyPatchData = patchData()
.set("grantType", SubscriptionOAuthPolicy.GrantType.USERNAME_PASSWORD.getName())
.set("username", "user1")
.set("password", "abc123")
.build();
PatchData patch = patchData()
.set("oAuthPolicy", oAuthPolicyPatchData)
.build();
Subscription updated = Patch.apply(subscription, patch);
SubscriptionOAuthPolicy updatedPolicy = updated.getOAuthPolicy();
assertThat(updatedPolicy.getGrantType()).isEqualTo(USERNAME_PASSWORD);
assertThat(updatedPolicy.getUsername()).isEqualTo("user1");
}
}