String setterBody = "this." + varName + " = " + varName + ";";
if (isListOfDependencies) {
- String nullCheck = String.format("if (%s == null) throw new IllegalArgumentException(\"Null not supported\");%n",
- varName);
+ String nullCheck = String.format("if (%s == null) {\n%s = new java.util.ArrayList<>(); \n}%n",
+ varName, varName);
setterBody = nullCheck + setterBody;
}
MethodDefinition setter = new MethodDefinition("void",
package org.opendaylight.controller.config.yang.test.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import com.google.common.collect.Lists;
ObjectName on = createInstance(transaction, instanceName, 4);
NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
- try{
- proxy.setTestingDeps(null);
- fail();
- }catch(RuntimeException e) {
- Throwable cause = e.getCause();
- assertNotNull(cause);
- assertTrue("Invalid type " + cause, cause instanceof IllegalArgumentException);
- assertEquals("Null not supported", cause.getMessage());
- }
+ proxy.setTestingDeps(null);
+ assertTrue(proxy.getTestingDeps().isEmpty());
proxy.setTestingDeps(Collections.<ObjectName>emptyList());
}