protected void assertStatus(CommitStatus status, int expectedNewInstances,
int expectedRecreatedInstances, int expectedReusedInstances) {
- assertEquals(expectedNewInstances, status.getNewInstances().size());
- assertEquals(expectedRecreatedInstances, status.getRecreatedInstances()
+ assertEquals("New instances mismatch in " + status, expectedNewInstances, status.getNewInstances().size());
+ assertEquals("Recreated instances mismatch in " + status, expectedRecreatedInstances, status.getRecreatedInstances()
.size());
- assertEquals(expectedReusedInstances, status.getReusedInstances()
+ assertEquals("Reused instances mismatch in " + status, expectedReusedInstances, status.getReusedInstances()
.size());
}
import org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
+import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TypedAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.VoidAttribute;
}
boolean isDependency = false;
+ boolean isListOfDependencies = false;
Dependency dependency = null;
Annotation overrideAnnotation = new Annotation("Override",
Collections.<Parameter> emptyList());
.getDependency();
annotations.add(Annotation
.createRequireIfcAnnotation(dependency.getSie()));
+ if (attributeIfc instanceof ListDependenciesAttribute) {
+ isListOfDependencies = true;
+ }
}
String varName = BindingGeneratorUtil
.parseToValidParamName(attrEntry.getKey());
moduleFields.add(new ModuleField(type, varName, attributeIfc
- .getUpperCaseCammelCase(), nullableDefaultWrapped, isDependency, dependency));
+ .getUpperCaseCammelCase(), nullableDefaultWrapped, isDependency, dependency, isListOfDependencies));
String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
.createDescriptionAnnotation(attributeIfc.getNullableDescription()));
}
+ String setterBody = "this." + varName + " = " + varName + ";";
+ if (isListOfDependencies) {
+ String nullCheck = String.format("if (%s == null) throw new IllegalArgumentException(\"Null not supported\");%n",
+ varName);
+ setterBody = nullCheck + setterBody;
+ }
MethodDefinition setter = new MethodDefinition("void",
setterName,
Lists.newArrayList(new Field(type, varName)),
- annotations, "this." + varName + " = " + varName + ";");
+ annotations, setterBody);
setter.setJavadoc(attributeIfc.getNullableDescription());
methods.add(getter);
public class ModuleField extends Field {
private final String nullableDefault, attributeName;
- private final boolean dependent;
+ private final boolean dependent, isListOfDependencies;
private final Dependency dependency;
- public ModuleField(List<String> modifiers, String type, String name,
+ private ModuleField(List<String> modifiers, String type, String name,
String attributeName, String nullableDefault, boolean isDependency,
- Dependency dependency) {
+ Dependency dependency, boolean isListOfDependencies) {
super(modifiers, type, name);
this.dependent = isDependency;
this.dependency = dependency;
nullableDefault = "new " + ArrayList.class.getName() + generics + "()";
}
this.nullableDefault = nullableDefault;
+ this.isListOfDependencies = isListOfDependencies;
}
public ModuleField(String type, String name, String attributeName,
- String nullableDefault, boolean isDependency, Dependency dependency) {
+ String nullableDefault, boolean isDependency, Dependency dependency, boolean isListOfDependencies) {
this(Collections.<String> emptyList(), type, name, attributeName,
- nullableDefault, isDependency, dependency);
+ nullableDefault, isDependency, dependency, isListOfDependencies);
}
public Dependency getDependency() {
return dependent;
}
+ public boolean isListOfDependencies() {
+ return isListOfDependencies;
+ }
+
public String getAttributeName() {
return attributeName;
}
throw new IllegalArgumentException("Parameter 'other' is null");
}
<#list moduleFields as field>
- <#if field.dependent==true>
+ <#if field.dependent==true && field.listOfDependencies == false>
if (${field.name}Dependency != other.${field.name}Dependency) { // reference to dependency must be same
return false;
}
+ <#elseif field.listOfDependencies>
+ if (${field.name}Dependency.equals(other.${field.name}Dependency) == false) {
+ return false;
+ }
+ for (int idx = 0; idx < ${field.name}Dependency.size(); idx++) {
+ if (${field.name}Dependency.get(idx) != other.${field.name}Dependency.get(idx)) {
+ return false;
+ }
+ }
<#else>
if (${field.name} == null) {
if (other.${field.name} != null) {
} catch (RuntimeException e) {
final Throwable cause = e.getCause();
assertNotNull(cause);
- assertTrue(cause instanceof IllegalStateException);
+ assertTrue(cause.toString() + " is unexpected", cause instanceof IllegalStateException);
assertThat(cause.getMessage(),
containsString("Name conflict in generated files"));
assertThat(cause.getMessage(), containsString("DtoA.java"));