KEYCLOAK-4392 Copy component id from representation to model
This commit is contained in:
parent
75909a0add
commit
3af9f2f989
2 changed files with 21 additions and 0 deletions
|
@ -1727,6 +1727,7 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
public static ComponentModel toModel(KeycloakSession session, ComponentRepresentation rep) {
|
public static ComponentModel toModel(KeycloakSession session, ComponentRepresentation rep) {
|
||||||
ComponentModel model = new ComponentModel();
|
ComponentModel model = new ComponentModel();
|
||||||
|
model.setId(rep.getId());
|
||||||
model.setParentId(rep.getParentId());
|
model.setParentId(rep.getParentId());
|
||||||
model.setProviderType(rep.getProviderType());
|
model.setProviderType(rep.getProviderType());
|
||||||
model.setProviderId(rep.getProviderId());
|
model.setProviderId(rep.getProviderId());
|
||||||
|
|
|
@ -98,6 +98,26 @@ public class ComponentsTest extends AbstractAdminTest {
|
||||||
assertTrue(returned.getConfig().containsKey("required"));
|
assertTrue(returned.getConfig().containsKey("required"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateWithoutGivenId() {
|
||||||
|
ComponentRepresentation rep = createComponentRepresentation("mycomponent");
|
||||||
|
rep.getConfig().addFirst("required", "foo");
|
||||||
|
rep.setId(null);
|
||||||
|
|
||||||
|
String id = createComponent(rep);
|
||||||
|
assertNotNull(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateWithGivenId() {
|
||||||
|
ComponentRepresentation rep = createComponentRepresentation("mycomponent");
|
||||||
|
rep.getConfig().addFirst("required", "foo");
|
||||||
|
rep.setId("fixed-id");
|
||||||
|
|
||||||
|
String id = createComponent(rep);
|
||||||
|
assertEquals("fixed-id", id);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdate() {
|
public void testUpdate() {
|
||||||
ComponentRepresentation rep = createComponentRepresentation("mycomponent");
|
ComponentRepresentation rep = createComponentRepresentation("mycomponent");
|
||||||
|
|
Loading…
Reference in a new issue