Merge pull request #3857 from anderius/feature/KEYCLOAK-4392-component-id

KEYCLOAK-4392 Copy component id from representation to model
This commit is contained in:
Stian Thorgersen 2017-02-14 09:43:38 +01:00 committed by GitHub
commit d72b67c460
2 changed files with 21 additions and 0 deletions

View file

@ -1727,6 +1727,7 @@ public class RepresentationToModel {
public static ComponentModel toModel(KeycloakSession session, ComponentRepresentation rep) {
ComponentModel model = new ComponentModel();
model.setId(rep.getId());
model.setParentId(rep.getParentId());
model.setProviderType(rep.getProviderType());
model.setProviderId(rep.getProviderId());

View file

@ -98,6 +98,26 @@ public class ComponentsTest extends AbstractAdminTest {
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
public void testUpdate() {
ComponentRepresentation rep = createComponentRepresentation("mycomponent");