Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFCORE-4388 Subsystem test framework alters order of child resources… #3716

Merged
merged 1 commit into from Apr 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,7 +32,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jboss.as.controller.ModelVersion;
Expand All @@ -44,7 +43,6 @@
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.LegacyResourceDefinition;
import org.jboss.as.controller.registry.Resource;
import org.jboss.as.model.test.ModelTestUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.junit.Assert;
Expand Down Expand Up @@ -120,39 +118,18 @@ private static Resource modelToResource(final PathAddress startAddress, final Im
}
res.writeModel(value);

Set<PathElement> childAddresses = reg.getChildAddresses(PathAddress.EMPTY_ADDRESS);

// When we have overrides those should be used for the checking. The set of child addresses however,
// may have the wildcard children before more specific ones. So we move the specific ones first
List<PathElement> sortedChildAddresses = ModelTestUtils.moveWildcardChildrenToEnd(childAddresses);
Set<PathElement> handledChildren = new HashSet<>();
for (PathElement path : sortedChildAddresses) {

ImmutableManagementResourceRegistration sub = reg.getSubModel(PathAddress.pathAddress(path));
if (path.isWildcard()) {
ModelNode subModel = model.get(path.getKey());
if (subModel.isDefined()) {
for (Property p : subModel.asPropertyList()) {
if (p.getValue().isDefined()) {
final PathElement element = PathElement.pathElement(path.getKey(), p.getName());
if (!handledChildren.contains(element)) {
res.registerChild(
element,
modelToResource(startAddress,sub, p.getValue(), includeUndefined, fullPath.append(path)));
}
}
}
}
} else {
ModelNode subModel = model.get(path.getKeyValuePair());
if (subModel.isDefined()) {
res.registerChild(path, modelToResource(startAddress,sub, subModel, includeUndefined, fullPath.append(path)));
for (String childType : reg.getChildNames(PathAddress.EMPTY_ADDRESS)) {
if (model.hasDefined(childType)) {
for (Property property : model.get(childType).asPropertyList()) {
PathElement childPath = PathElement.pathElement(childType, property.getName());
ImmutableManagementResourceRegistration subRegistration = reg.getSubModel(PathAddress.pathAddress(childPath));
Resource child = modelToResource(startAddress, subRegistration, property.getValue(), includeUndefined, fullPath.append(childPath));
res.registerChild(childPath, child);
}
}

handledChildren.add(path);
allFields.remove(path.getKey());
allFields.remove(childType);
}

if (!allFields.isEmpty()){
throw ControllerLogger.ROOT_LOGGER.modelFieldsNotKnown(allFields, startAddress.append(fullPath));
}
Expand Down