/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.messaging.test;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PATH;
import static org.jboss.as.messaging.CommonAttributes.HORNETQ_SERVER;
import org.jboss.as.model.test.ModelFixer;
import org.jboss.dmr.ModelNode;
/**
* Model Fixers for messaging extension.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
public class ModelFixers {
static final ModelFixer PATH_FIXER = new ModelFixer() {
@Override
public ModelNode fixModel(ModelNode modelNode) {
// Since AS7-5417, messaging's paths resources are always created.
// however for legacy version, they were only created if the path attributes were different from the defaults.
// The 'empty' hornetq-server does not set any messaging's path so we discard them to "fix" the model and
// compare the current and legacy versions
for (String serverWithDefaultPath : new String[]{"empty", "stuff"}) {
if (modelNode.get(HORNETQ_SERVER).has(serverWithDefaultPath)) {
modelNode.get(HORNETQ_SERVER, serverWithDefaultPath, PATH).set(new ModelNode());
}
}
return modelNode;
}
};
}