Skip to content

Commit

Permalink
Merge pull request #6226 from kabir/transformation-utils-fix
Browse files Browse the repository at this point in the history
[WFCORE-7036] TransformationUtils.modelToResource() should not return…
  • Loading branch information
yersan authored Oct 29, 2024
2 parents 9bbb4fd + 8744c68 commit b9bb3f7
Show file tree
Hide file tree
Showing 4 changed files with 668 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ private static Resource modelToResource(final PathAddress startAddress, final Im
}
allFields.remove(name);
}
if (!value.isDefined() && model.isDefined() && reg.getChildAddresses(PathAddress.EMPTY_ADDRESS).isEmpty()) {
value.setEmptyObject();
}
res.writeModel(value);

for (String childType : reg.getChildNames(PathAddress.EMPTY_ADDRESS)) {
if (model.hasDefined(childType)) {
Expand All @@ -113,6 +109,12 @@ private static Resource modelToResource(final PathAddress startAddress, final Im
allFields.remove(childType);
}

if (!value.isDefined() && model.isDefined() && (reg.getChildAddresses(PathAddress.EMPTY_ADDRESS).isEmpty() || res.getChildTypes().isEmpty())) {
value.setEmptyObject();
}
res.writeModel(value);


if (!allFields.isEmpty()){
throw ControllerLogger.ROOT_LOGGER.modelFieldsNotKnown(allFields, startAddress.append(fullPath));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*
*/

package org.jboss.as.subsystem.test;

import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;

/**
* For tests to call package protected methods in this package
*/
public class InternalPackageProtectedAccess {
public static Resource modelToResource(final ImmutableManagementResourceRegistration reg, final ModelNode model, boolean includeUndefined) {
return TransformationUtils.modelToResource(reg, model, includeUndefined);
}
}
Loading

0 comments on commit b9bb3f7

Please sign in to comment.