* @throws java.lang.IllegalArgumentException
*/
public COPSDecision(final Command cmdCode) {
- this(CType.DEF, cmdCode, DecisionFlag.NA, new COPSData());
+ this(CType.DEF, cmdCode, DecisionFlag.NA, null);
}
/**
* @throws java.lang.IllegalArgumentException
*/
public COPSDecision(final Command cmdCode, final DecisionFlag flags) {
- this(CType.DEF, cmdCode, flags, new COPSData());
+ this(CType.DEF, cmdCode, flags, null);
}
/**
* @throws java.lang.IllegalArgumentException
*/
public COPSDecision(final CType cType, final Command cmdCode, final DecisionFlag flags) {
- this(cType, cmdCode, flags, new COPSData());
+ this(cType, cmdCode, flags, null);
}
/**
if (hdr.getCType().equals(CType.NA)) throw new IllegalArgumentException("CType must not be " + CType.NA);
if (cmdCode == null) throw new IllegalArgumentException("Command code must not be null");
if (flags == null) throw new IllegalArgumentException("Flags must not be null");
- if (data == null) throw new IllegalArgumentException("Data object must not be null");
_cmdCode = cmdCode;
_flags = flags;
- _data = data;
+
+ if (data == null) _data = new COPSData();
+ else _data = data;
if ((_data.length() % 4) != 0) {
final int padLen = 4 - (_data.length() % 4);
new COPSDecision(CType.NA, new COPSData());
}
- @Test(expected = IllegalArgumentException.class)
- public void constructor2NullData() {
- new COPSDecision(CType.DEF, null);
- }
-
@Test(expected = IllegalArgumentException.class)
public void constructor3NullCommand() {
new COPSDecision(null, DecisionFlag.NA);
new COPSDecision(CType.CSI, Command.INSTALL, null, new COPSData());
}
- @Test(expected = IllegalArgumentException.class)
- public void constructor5NullData() {
- new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.NA, null);
- }
-
@Test(expected = IllegalArgumentException.class)
public void constructor6NullHeader() {
final COPSObjHeader hdr = null;
@Test(expected = IllegalArgumentException.class)
public void constructor6NullData() {
- new COPSDecision(new COPSObjHeader(CNum.DEC, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+ new COPSDecision(new COPSObjHeader(CNum.CSI, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+ }
+
+ @Test
+ public void cNumDECAndNullData() {
+ final COPSDecision decision = new COPSDecision(CType.DEF, null);
+ Assert.assertNotNull(decision.getData());
+ Assert.assertEquals(0, decision.getData().getData().length);
}
@Test
new COPSLPDPDecision(CType.CSI, Command.INSTALL, null, new COPSData());
}
- @Test(expected = IllegalArgumentException.class)
- public void constructor1NullData() {
- new COPSLPDPDecision(CType.CSI, Command.INSTALL, DecisionFlag.NA, null);
- }
-
@Test(expected = IllegalArgumentException.class)
public void constructor2NullHeader() {
final COPSObjHeader hdr = null;
new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI), Command.INSTALL, null, new COPSData());
}
- @Test(expected = IllegalArgumentException.class)
public void constructor2NullData() {
- new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI), Command.INSTALL, DecisionFlag.NA, null);
+ final COPSLPDPDecision decision = new COPSLPDPDecision(new COPSObjHeader(CNum.LPDP_DEC, CType.CSI),
+ Command.INSTALL, DecisionFlag.NA, null);
+ Assert.assertEquals(0, decision.getData().getData().length);
}
@Test