diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorage.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorage.java index dd059ffe78..5e9392e070 100644 --- a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorage.java +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorage.java @@ -111,7 +111,7 @@ public class HotRodMapStorage read(QueryParameters queryParameters) { - IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() + IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() .flashToModelCriteriaBuilder(createCriteriaBuilder()); String queryString = iqmcb.getIckleQuery(); @@ -137,7 +137,7 @@ public class HotRodMapStorage queryParameters) { - IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() + IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() .flashToModelCriteriaBuilder(createCriteriaBuilder()); String queryString = iqmcb.getIckleQuery(); @@ -153,7 +153,7 @@ public class HotRodMapStorage queryParameters) { - IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() + IckleQueryMapModelCriteriaBuilder iqmcb = queryParameters.getModelCriteriaBuilder() .flashToModelCriteriaBuilder(createCriteriaBuilder()); String queryString = "SELECT id " + iqmcb.getIckleQuery(); @@ -183,8 +183,8 @@ public class HotRodMapStorage createCriteriaBuilder() { - return new IckleQueryMapModelCriteriaBuilder<>(); + public IckleQueryMapModelCriteriaBuilder createCriteriaBuilder() { + return new IckleQueryMapModelCriteriaBuilder<>(storedEntityDescriptor.getEntityTypeClass()); } @Override diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorageProviderFactory.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorageProviderFactory.java index ede6dad3cb..83e5451cb1 100644 --- a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorageProviderFactory.java +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/HotRodMapStorageProviderFactory.java @@ -22,8 +22,10 @@ import org.keycloak.Config; import org.keycloak.common.Profile; import org.keycloak.component.AmphibianProviderFactory; import org.keycloak.models.ClientModel; +import org.keycloak.models.GroupModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; +import org.keycloak.models.map.group.MapGroupEntity; import org.keycloak.models.map.storage.hotRod.client.HotRodClientEntity; import org.keycloak.models.map.storage.hotRod.client.HotRodClientEntityDelegate; import org.keycloak.models.map.storage.hotRod.client.HotRodProtocolMapperEntityDelegate; @@ -34,6 +36,8 @@ import org.keycloak.models.map.storage.hotRod.common.HotRodEntityDescriptor; import org.keycloak.models.map.storage.hotRod.connections.HotRodConnectionProvider; import org.keycloak.models.map.storage.MapStorageProvider; import org.keycloak.models.map.storage.MapStorageProviderFactory; +import org.keycloak.models.map.storage.hotRod.group.HotRodGroupEntity; +import org.keycloak.models.map.storage.hotRod.group.HotRodGroupEntityDelegate; import org.keycloak.provider.EnvironmentDependentProviderFactory; import java.util.HashMap; @@ -45,8 +49,9 @@ public class HotRodMapStorageProviderFactory implements AmphibianProviderFactory private static final Logger LOG = Logger.getLogger(HotRodMapStorageProviderFactory.class); private final static DeepCloner CLONER = new DeepCloner.Builder() - .constructorDC(MapClientEntity.class, HotRodClientEntityDelegate::new) - .constructor(MapProtocolMapperEntity.class, HotRodProtocolMapperEntityDelegate::new) + .constructorDC(MapClientEntity.class, HotRodClientEntityDelegate::new) + .constructor(MapProtocolMapperEntity.class, HotRodProtocolMapperEntityDelegate::new) + .constructor(MapGroupEntity.class, HotRodGroupEntityDelegate::new) .build(); public static final Map, HotRodEntityDescriptor> ENTITY_DESCRIPTOR_MAP = new HashMap<>(); @@ -56,6 +61,12 @@ public class HotRodMapStorageProviderFactory implements AmphibianProviderFactory new HotRodEntityDescriptor<>(ClientModel.class, HotRodClientEntity.class, HotRodClientEntityDelegate::new)); + + // Groups descriptor + ENTITY_DESCRIPTOR_MAP.put(GroupModel.class, + new HotRodEntityDescriptor<>(GroupModel.class, + HotRodGroupEntity.class, + HotRodGroupEntityDelegate::new)); } @Override @@ -95,6 +106,6 @@ public class HotRodMapStorageProviderFactory implements AmphibianProviderFactory @Override public String getHelpText() { - return "HotRod client storage"; + return "HotRod map storage"; } } diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilder.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilder.java index 07cbc4b355..51ea1aefd5 100644 --- a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilder.java +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilder.java @@ -18,8 +18,9 @@ package org.keycloak.models.map.storage.hotRod; import org.keycloak.models.ClientModel; -import org.keycloak.models.map.common.AbstractEntity; +import org.keycloak.models.GroupModel; import org.keycloak.models.map.storage.ModelCriteriaBuilder; +import org.keycloak.models.map.storage.hotRod.common.AbstractHotRodEntity; import org.keycloak.storage.SearchableModelField; import java.util.Arrays; @@ -32,10 +33,12 @@ import java.util.stream.Collectors; import static org.keycloak.models.map.storage.hotRod.IckleQueryOperators.C; import static org.keycloak.models.map.storage.hotRod.IckleQueryOperators.findAvailableNamedParam; +import static org.keycloak.models.map.storage.hotRod.common.ProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE; -public class IckleQueryMapModelCriteriaBuilder implements ModelCriteriaBuilder> { +public class IckleQueryMapModelCriteriaBuilder implements ModelCriteriaBuilder> { private static final int INITIAL_BUILDER_CAPACITY = 250; + private final Class hotRodEntityClass; private final StringBuilder whereClauseBuilder = new StringBuilder(INITIAL_BUILDER_CAPACITY); private final Map parameters; public static final Map, String> INFINISPAN_NAME_OVERRIDES = new HashMap<>(); @@ -43,14 +46,19 @@ public class IckleQueryMapModelCriteriaBuilder i static { INFINISPAN_NAME_OVERRIDES.put(ClientModel.SearchableFields.SCOPE_MAPPING_ROLE, "scopeMappings"); INFINISPAN_NAME_OVERRIDES.put(ClientModel.SearchableFields.ATTRIBUTE, "attributes"); + + INFINISPAN_NAME_OVERRIDES.put(GroupModel.SearchableFields.PARENT_ID, "parentId"); + INFINISPAN_NAME_OVERRIDES.put(GroupModel.SearchableFields.ASSIGNED_ROLE, "grantedRoles"); } - public IckleQueryMapModelCriteriaBuilder(StringBuilder whereClauseBuilder, Map parameters) { + public IckleQueryMapModelCriteriaBuilder(Class hotRodEntityClass, StringBuilder whereClauseBuilder, Map parameters) { + this.hotRodEntityClass = hotRodEntityClass; this.whereClauseBuilder.append(whereClauseBuilder); this.parameters = parameters; } - public IckleQueryMapModelCriteriaBuilder() { + public IckleQueryMapModelCriteriaBuilder(Class hotRodEntityClass) { + this.hotRodEntityClass = hotRodEntityClass; this.parameters = new HashMap<>(); } @@ -63,7 +71,7 @@ public class IckleQueryMapModelCriteriaBuilder i } @Override - public IckleQueryMapModelCriteriaBuilder compare(SearchableModelField modelField, Operator op, Object... value) { + public IckleQueryMapModelCriteriaBuilder compare(SearchableModelField modelField, Operator op, Object... value) { StringBuilder newBuilder = new StringBuilder(INITIAL_BUILDER_CAPACITY); newBuilder.append("("); @@ -78,17 +86,17 @@ public class IckleQueryMapModelCriteriaBuilder i newBuilder.append(")"); } - return new IckleQueryMapModelCriteriaBuilder<>(newBuilder.append(")"), newParameters); + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass, newBuilder.append(")"), newParameters); } - private StringBuilder joinBuilders(IckleQueryMapModelCriteriaBuilder[] builders, String delimiter) { + private StringBuilder joinBuilders(IckleQueryMapModelCriteriaBuilder[] builders, String delimiter) { return new StringBuilder(INITIAL_BUILDER_CAPACITY).append("(").append(Arrays.stream(builders) .map(IckleQueryMapModelCriteriaBuilder::getWhereClauseBuilder) .filter(IckleQueryMapModelCriteriaBuilder::notEmpty) .collect(Collectors.joining(delimiter))).append(")"); } - private Map joinParameters(IckleQueryMapModelCriteriaBuilder[] builders) { + private Map joinParameters(IckleQueryMapModelCriteriaBuilder[] builders) { return Arrays.stream(builders) .map(IckleQueryMapModelCriteriaBuilder::getParameters) .map(Map::entrySet) @@ -97,7 +105,7 @@ public class IckleQueryMapModelCriteriaBuilder i } @SuppressWarnings("unchecked") - private IckleQueryMapModelCriteriaBuilder[] resolveNamedQueryConflicts(IckleQueryMapModelCriteriaBuilder[] builders) { + private IckleQueryMapModelCriteriaBuilder[] resolveNamedQueryConflicts(IckleQueryMapModelCriteriaBuilder[] builders) { final Set existingKeys = new HashSet<>(); return Arrays.stream(builders).map(builder -> { @@ -123,36 +131,36 @@ public class IckleQueryMapModelCriteriaBuilder i } } - return new IckleQueryMapModelCriteriaBuilder<>(new StringBuilder(newWhereClause), newParameters); + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass, new StringBuilder(newWhereClause), newParameters); }).toArray(IckleQueryMapModelCriteriaBuilder[]::new); } @Override - public IckleQueryMapModelCriteriaBuilder and(IckleQueryMapModelCriteriaBuilder... builders) { + public IckleQueryMapModelCriteriaBuilder and(IckleQueryMapModelCriteriaBuilder... builders) { if (builders.length == 0) { - return new IckleQueryMapModelCriteriaBuilder<>(); + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass); } builders = resolveNamedQueryConflicts(builders); - return new IckleQueryMapModelCriteriaBuilder<>(joinBuilders(builders, " AND "), + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass, joinBuilders(builders, " AND "), joinParameters(builders)); } @Override - public IckleQueryMapModelCriteriaBuilder or(IckleQueryMapModelCriteriaBuilder... builders) { + public IckleQueryMapModelCriteriaBuilder or(IckleQueryMapModelCriteriaBuilder... builders) { if (builders.length == 0) { - return new IckleQueryMapModelCriteriaBuilder<>(); + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass); } builders = resolveNamedQueryConflicts(builders); - return new IckleQueryMapModelCriteriaBuilder<>(joinBuilders(builders, " OR "), + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass, joinBuilders(builders, " OR "), joinParameters(builders)); } @Override - public IckleQueryMapModelCriteriaBuilder not(IckleQueryMapModelCriteriaBuilder builder) { + public IckleQueryMapModelCriteriaBuilder not(IckleQueryMapModelCriteriaBuilder builder) { StringBuilder newBuilder = new StringBuilder(INITIAL_BUILDER_CAPACITY); StringBuilder originalBuilder = builder.getWhereClauseBuilder(); @@ -160,7 +168,7 @@ public class IckleQueryMapModelCriteriaBuilder i newBuilder.append("not").append(originalBuilder); } - return new IckleQueryMapModelCriteriaBuilder<>(newBuilder, builder.getParameters()); + return new IckleQueryMapModelCriteriaBuilder<>(hotRodEntityClass, newBuilder, builder.getParameters()); } private StringBuilder getWhereClauseBuilder() { @@ -172,7 +180,7 @@ public class IckleQueryMapModelCriteriaBuilder i * @return Ickle query that represents this QueryBuilder */ public String getIckleQuery() { - return "FROM org.keycloak.models.map.storage.hotrod.HotRodClientEntity " + C + ((whereClauseBuilder.length() != 0) ? " WHERE " + whereClauseBuilder : ""); + return "FROM " + HOT_ROD_ENTITY_PACKAGE + "." + hotRodEntityClass.getSimpleName() + " " + C + ((whereClauseBuilder.length() != 0) ? " WHERE " + whereClauseBuilder : ""); } /** diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryOperators.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryOperators.java index c962c8015e..cc745979c5 100644 --- a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryOperators.java +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/IckleQueryOperators.java @@ -112,7 +112,7 @@ public class IckleQueryOperators { operands = new HashSet<>(Arrays.asList(values)); } - return C + "." + modelField + " IN (" + operands.stream() + return operands.isEmpty() ? "false" : C + "." + modelField + " IN (" + operands.stream() .map(operand -> { String namedParam = findAvailableNamedParam(parameters.keySet(), modelField); parameters.put(namedParam, operand); @@ -149,9 +149,13 @@ public class IckleQueryOperators { return (modelFieldName, values, parameters) -> { if (values.length != 1) throw new RuntimeException("Invalid arguments, expected (" + modelFieldName + "), got: " + Arrays.toString(values)); - String namedParameter = findAvailableNamedParam(parameters.keySet(), modelFieldName); + if (values[0] == null && op.equals(ModelCriteriaBuilder.Operator.EQ)) { + return C + "." + modelFieldName + " IS NULL"; + } + String namedParameter = findAvailableNamedParam(parameters.keySet(), modelFieldName); parameters.put(namedParameter, values[0]); + return C + "." + modelFieldName + " " + IckleQueryOperators.operatorToString(op) + " :" + namedParameter; }; } diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/common/ProtoSchemaInitializer.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/common/ProtoSchemaInitializer.java index 1385d15125..2fffa6bc19 100644 --- a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/common/ProtoSchemaInitializer.java +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/common/ProtoSchemaInitializer.java @@ -22,20 +22,29 @@ import org.infinispan.protostream.annotations.AutoProtoSchemaBuilder; import org.keycloak.models.map.storage.hotRod.client.HotRodAttributeEntity; import org.keycloak.models.map.storage.hotRod.client.HotRodClientEntity; import org.keycloak.models.map.storage.hotRod.client.HotRodProtocolMapperEntity; +import org.keycloak.models.map.storage.hotRod.group.HotRodGroupEntity; /** * @author Martin Kanis */ @AutoProtoSchemaBuilder( includeClasses = { - HotRodAttributeEntity.class, + // Clients HotRodClientEntity.class, + HotRodAttributeEntity.class, HotRodProtocolMapperEntity.class, + + // Groups + HotRodGroupEntity.class, + + // Common HotRodPair.class }, schemaFileName = "KeycloakHotRodMapStorage.proto", schemaFilePath = "proto/", - schemaPackageName = "org.keycloak.models.map.storage.hotrod") + schemaPackageName = ProtoSchemaInitializer.HOT_ROD_ENTITY_PACKAGE) public interface ProtoSchemaInitializer extends GeneratedSchema { + String HOT_ROD_ENTITY_PACKAGE = "kc"; + ProtoSchemaInitializer INSTANCE = new ProtoSchemaInitializerImpl(); } diff --git a/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/group/HotRodGroupEntity.java b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/group/HotRodGroupEntity.java new file mode 100644 index 0000000000..3c5b733e9f --- /dev/null +++ b/model/map-hot-rod/src/main/java/org/keycloak/models/map/storage/hotRod/group/HotRodGroupEntity.java @@ -0,0 +1,72 @@ +/* + * Copyright 2021 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.models.map.storage.hotRod.group; + +import org.infinispan.protostream.annotations.ProtoField; +import org.keycloak.models.map.annotations.GenerateHotRodEntityImplementation; +import org.keycloak.models.map.common.UpdatableEntity; +import org.keycloak.models.map.group.MapGroupEntity; +import org.keycloak.models.map.storage.hotRod.client.HotRodAttributeEntity; +import org.keycloak.models.map.storage.hotRod.common.AbstractHotRodEntity; +import org.keycloak.models.map.storage.hotRod.common.HotRodEntityDelegate; + +import java.util.Set; + +@GenerateHotRodEntityImplementation( + implementInterface = "org.keycloak.models.map.group.MapGroupEntity", + inherits = "org.keycloak.models.map.storage.hotRod.group.HotRodGroupEntity.AbstractHotRodGroupEntityDelegate" +) +public class HotRodGroupEntity implements AbstractHotRodEntity { + + public static abstract class AbstractHotRodGroupEntityDelegate extends UpdatableEntity.Impl implements HotRodEntityDelegate, MapGroupEntity { + + @Override + public String getId() { + return getHotRodEntity().id; + } + + @Override + public void setId(String id) { + HotRodGroupEntity entity = getHotRodEntity(); + if (entity.id != null) throw new IllegalStateException("Id cannot be changed"); + entity.id = id; + this.updated |= id != null; + } + } + + @ProtoField(number = 1, required = true) + public int entityVersion = 1; + + @ProtoField(number = 2, required = true) + public String id; + + @ProtoField(number = 3) + public String realmId; + + @ProtoField(number = 4) + public String name; + + @ProtoField(number = 5) + public String parentId; + + @ProtoField(number = 6) + public Set attributes; + + @ProtoField(number = 7) + public Set grantedRoles; +} diff --git a/model/map-hot-rod/src/main/resources/config/cacheConfig.xml b/model/map-hot-rod/src/main/resources/config/cacheConfig.xml index 351576ee74..a98ecd6af4 100644 --- a/model/map-hot-rod/src/main/resources/config/cacheConfig.xml +++ b/model/map-hot-rod/src/main/resources/config/cacheConfig.xml @@ -6,5 +6,8 @@ + + + \ No newline at end of file diff --git a/model/map-hot-rod/src/main/resources/config/infinispan.xml b/model/map-hot-rod/src/main/resources/config/infinispan.xml index ce1efc99cf..5fe47bc163 100644 --- a/model/map-hot-rod/src/main/resources/config/infinispan.xml +++ b/model/map-hot-rod/src/main/resources/config/infinispan.xml @@ -8,5 +8,8 @@ + + + diff --git a/model/map-hot-rod/src/test/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilderTest.java b/model/map-hot-rod/src/test/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilderTest.java index 7bf32bb628..4cb5ffe64c 100644 --- a/model/map-hot-rod/src/test/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilderTest.java +++ b/model/map-hot-rod/src/test/java/org/keycloak/models/map/storage/hotRod/IckleQueryMapModelCriteriaBuilderTest.java @@ -37,9 +37,9 @@ import static org.keycloak.models.map.storage.criteria.DefaultModelCriteria.crit public class IckleQueryMapModelCriteriaBuilderTest { @Test public void testSimpleIckleQuery() { - IckleQueryMapModelCriteriaBuilder v = new IckleQueryMapModelCriteriaBuilder<>(); - IckleQueryMapModelCriteriaBuilder mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 3); - assertThat(mcb.getIckleQuery(), is(equalTo("FROM org.keycloak.models.map.storage.hotrod.HotRodClientEntity c WHERE (c.clientId = :clientId0)"))); + IckleQueryMapModelCriteriaBuilder v = new IckleQueryMapModelCriteriaBuilder<>(HotRodClientEntity.class); + IckleQueryMapModelCriteriaBuilder mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 3); + assertThat(mcb.getIckleQuery(), is(equalTo("FROM kc.HotRodClientEntity c WHERE (c.clientId = :clientId0)"))); assertThat(mcb.getParameters().entrySet(), hasSize(1)); assertThat(mcb.getParameters(), hasEntry("clientId0", 3)); @@ -47,7 +47,7 @@ public class IckleQueryMapModelCriteriaBuilderTest { mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 4) .compare(ID, ModelCriteriaBuilder.Operator.EQ, 5); - assertThat(mcb.getIckleQuery(), is(equalTo("FROM org.keycloak.models.map.storage.hotrod.HotRodClientEntity c WHERE ((c.clientId = :clientId0) AND (c.id = :id0))"))); + assertThat(mcb.getIckleQuery(), is(equalTo("FROM kc.HotRodClientEntity c WHERE ((c.clientId = :clientId0) AND (c.id = :id0))"))); assertThat(mcb.getParameters().entrySet(), hasSize(2)); assertThat(mcb.getParameters(), allOf(hasEntry("clientId0", 4), hasEntry("id0", 5))); } @@ -56,16 +56,16 @@ public class IckleQueryMapModelCriteriaBuilderTest { @Test public void testSimpleIckleQueryFlashedFromDefault() { DefaultModelCriteria v = criteria(); - IckleQueryMapModelCriteriaBuilder mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 3).flashToModelCriteriaBuilder(new IckleQueryMapModelCriteriaBuilder<>()); - assertThat(mcb.getIckleQuery(), is(equalTo("FROM org.keycloak.models.map.storage.hotrod.HotRodClientEntity c WHERE (c.clientId = :clientId0)"))); + IckleQueryMapModelCriteriaBuilder mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 3).flashToModelCriteriaBuilder(new IckleQueryMapModelCriteriaBuilder<>(HotRodClientEntity.class)); + assertThat(mcb.getIckleQuery(), is(equalTo("FROM kc.HotRodClientEntity c WHERE (c.clientId = :clientId0)"))); assertThat(mcb.getParameters().entrySet(), hasSize(1)); assertThat(mcb.getParameters(), hasEntry("clientId0", 3)); mcb = v.compare(CLIENT_ID, ModelCriteriaBuilder.Operator.EQ, 4) - .compare(ID, ModelCriteriaBuilder.Operator.EQ, 5).flashToModelCriteriaBuilder(new IckleQueryMapModelCriteriaBuilder<>()); + .compare(ID, ModelCriteriaBuilder.Operator.EQ, 5).flashToModelCriteriaBuilder(new IckleQueryMapModelCriteriaBuilder<>(HotRodClientEntity.class)); - assertThat(mcb.getIckleQuery(), is(equalTo("FROM org.keycloak.models.map.storage.hotrod.HotRodClientEntity c WHERE ((c.clientId = :clientId0) AND (c.id = :id0))"))); + assertThat(mcb.getIckleQuery(), is(equalTo("FROM kc.HotRodClientEntity c WHERE ((c.clientId = :clientId0) AND (c.id = :id0))"))); assertThat(mcb.getParameters().entrySet(), hasSize(2)); assertThat(mcb.getParameters(), allOf(hasEntry("clientId0", 4), hasEntry("id0", 5))); } diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index ada889578e..0efd12518f 100755 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -1497,6 +1497,7 @@ hotrod + hotrod diff --git a/testsuite/model/src/main/resources/hotrod/infinispan.xml b/testsuite/model/src/main/resources/hotrod/infinispan.xml index 00a78521ec..155a3001e3 100644 --- a/testsuite/model/src/main/resources/hotrod/infinispan.xml +++ b/testsuite/model/src/main/resources/hotrod/infinispan.xml @@ -1,9 +1,11 @@ - + + +