com.ecfeed.core.model.serialization.ModelPartialSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecfeed.junit Show documentation
Show all versions of ecfeed.junit Show documentation
An open library used to connect to the ecFeed service. It can be also used as a standalone testing tool. It is integrated with Junit5 and generates a stream of test cases using a selected algorithm (e.g. Cartesian, N-Wise). There are no limitations associated with the off-line version but the user cannot access the on-line computation servers and the model database.
The newest version!
/*******************************************************************************
*
* Copyright (c) 2016 ecFeed AS.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package com.ecfeed.core.model.serialization;
import java.io.OutputStream;
import java.util.List;
import com.ecfeed.core.model.AbstractNode;
import com.ecfeed.core.model.ChoiceNode;
import com.ecfeed.core.model.IConstraint;
import com.ecfeed.core.model.IsNodeIncludedInGenerationPredicate;
import com.ecfeed.core.model.MethodNode;
import com.ecfeed.core.model.ModelHelper;
import com.ecfeed.core.model.RootNode;
public class ModelPartialSerializer {
private final OutputStream fOutputStream;
private final int fModelVersion;
public ModelPartialSerializer(
OutputStream outputStream,
int modelVersion) {
fOutputStream = outputStream;
fModelVersion = modelVersion;
}
public void serializeModelPartForGenerator(
MethodNode methodNode,
List> allowedChoiceInput,
List> allowedConstraints) throws Exception {
serializeModelPartForGenerator(
methodNode,
allowedChoiceInput,
allowedConstraints,
true,
true);
}
public void serializeModelPartForGenerator(
MethodNode methodNode,
List> allowedChoiceInput,
List> allowedConstraints,
boolean serializeProperties,
boolean serializeComments) throws Exception {
SerializerPredicate serializerPredicate =
new SerializerPredicate(methodNode, allowedChoiceInput, allowedConstraints);
SerializatorParams serializatorParams =
new SerializatorParams(serializerPredicate, serializeProperties, serializeComments);
ModelSerializer fModelSerializer =
new ModelSerializer(fOutputStream, fModelVersion, serializatorParams);
RootNode rootNode = ModelHelper.findRoot(methodNode);
fModelSerializer.serialize(rootNode);
}
private static class SerializerPredicate implements ISerializerPredicate {
private final MethodNode fMethodNode;
private final List> fAllowedChoiceInput;
private final List> fAllowedConstraints;
public SerializerPredicate(
MethodNode methodNode,
List> allowedChoiceInput,
List> allowedConstraints ) {
fMethodNode = methodNode;
fAllowedChoiceInput = allowedChoiceInput;
fAllowedConstraints = allowedConstraints;
}
@Override
public boolean shouldSerializeNode(AbstractNode abstractNode) {
IsNodeIncludedInGenerationPredicate predicate =
new IsNodeIncludedInGenerationPredicate(
fMethodNode, fAllowedChoiceInput, fAllowedConstraints);
return predicate.test(abstractNode );
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy