@Test public void testCreateHoldTimeException0() throws Exception { exception.expect(HoldTimeMinException.class); AttributeFactory.createHoldTime(2); }
public static Attribute createHoldTime(int holdTimeMin) throws HoldTimeMinException { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setFlags(getFlags(NONTRANSITIVE_COMPACT)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); attributeBuilder.setType(AttributeType.HoldTime); byte[] value = null; int holdTimeMax; if (holdTimeMin == 0) { value = new byte[] {(byte) 0xFF, (byte) 0xFF}; holdTimeMax = 0; } else if (holdTimeMin < 0 || 65535 < holdTimeMin || holdTimeMin < 3) { throw new HoldTimeMinException(holdTimeMin); } else { value = ArraysUtil.combine(ArraysUtil.int2bytesCropp(holdTimeMin, 2)); holdTimeMax = 0; } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); HoldTimeAttributeBuilder _attributeBuilder = new HoldTimeAttributeBuilder(); HoldTimeAttributesBuilder _attributesBuilder = new HoldTimeAttributesBuilder(); _attributesBuilder.setHoldTimeMinValue(holdTimeMin); _attributesBuilder.setHoldTimeMaxValue(holdTimeMax); _attributeBuilder.setHoldTimeAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }
AttributeFactory { public static Attribute createHoldTime(int holdTimeMin) throws HoldTimeMinException { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setFlags(getFlags(NONTRANSITIVE_COMPACT)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); attributeBuilder.setType(AttributeType.HoldTime); byte[] value = null; int holdTimeMax; if (holdTimeMin == 0) { value = new byte[] {(byte) 0xFF, (byte) 0xFF}; holdTimeMax = 0; } else if (holdTimeMin < 0 || 65535 < holdTimeMin || holdTimeMin < 3) { throw new HoldTimeMinException(holdTimeMin); } else { value = ArraysUtil.combine(ArraysUtil.int2bytesCropp(holdTimeMin, 2)); holdTimeMax = 0; } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); HoldTimeAttributeBuilder _attributeBuilder = new HoldTimeAttributeBuilder(); HoldTimeAttributesBuilder _attributesBuilder = new HoldTimeAttributesBuilder(); _attributesBuilder.setHoldTimeMinValue(holdTimeMin); _attributesBuilder.setHoldTimeMaxValue(holdTimeMax); _attributeBuilder.setHoldTimeAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); } }
AttributeFactory { public static Attribute createHoldTime(int holdTimeMin) throws HoldTimeMinException { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setFlags(getFlags(NONTRANSITIVE_COMPACT)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); attributeBuilder.setType(AttributeType.HoldTime); byte[] value = null; int holdTimeMax; if (holdTimeMin == 0) { value = new byte[] {(byte) 0xFF, (byte) 0xFF}; holdTimeMax = 0; } else if (holdTimeMin < 0 || 65535 < holdTimeMin || holdTimeMin < 3) { throw new HoldTimeMinException(holdTimeMin); } else { value = ArraysUtil.combine(ArraysUtil.int2bytesCropp(holdTimeMin, 2)); holdTimeMax = 0; } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); HoldTimeAttributeBuilder _attributeBuilder = new HoldTimeAttributeBuilder(); HoldTimeAttributesBuilder _attributesBuilder = new HoldTimeAttributesBuilder(); _attributesBuilder.setHoldTimeMinValue(holdTimeMin); _attributesBuilder.setHoldTimeMaxValue(holdTimeMax); _attributeBuilder.setHoldTimeAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  }
AttributeFactory { public static Attribute createHoldTime(int holdTimeMin) throws HoldTimeMinException { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setFlags(getFlags(NONTRANSITIVE_COMPACT)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); attributeBuilder.setType(AttributeType.HoldTime); byte[] value = null; int holdTimeMax; if (holdTimeMin == 0) { value = new byte[] {(byte) 0xFF, (byte) 0xFF}; holdTimeMax = 0; } else if (holdTimeMin < 0 || 65535 < holdTimeMin || holdTimeMin < 3) { throw new HoldTimeMinException(holdTimeMin); } else { value = ArraysUtil.combine(ArraysUtil.int2bytesCropp(holdTimeMin, 2)); holdTimeMax = 0; } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); HoldTimeAttributeBuilder _attributeBuilder = new HoldTimeAttributeBuilder(); HoldTimeAttributesBuilder _attributesBuilder = new HoldTimeAttributesBuilder(); _attributesBuilder.setHoldTimeMinValue(holdTimeMin); _attributesBuilder.setHoldTimeMaxValue(holdTimeMax); _attributeBuilder.setHoldTimeAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  static Attribute createCapabilities(Version version); static Attribute createHoldTime(int holdTimeMin); static Attribute createHoldTime(int holdTimeMin, int holdTimeMax); static Attribute createIpv4AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv4DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createPeerSequence(List<NodeId> nodesIds); static Attribute createSourceGroupTag(int sgt); static Attribute createSxpNodeId(NodeId nodeId); static byte[] encodeCapability(Capabilities capability); }
AttributeFactory { public static Attribute createHoldTime(int holdTimeMin) throws HoldTimeMinException { AttributeBuilder attributeBuilder = new AttributeBuilder(); attributeBuilder.setFlags(getFlags(NONTRANSITIVE_COMPACT)); attributeBuilder.setAttributeVariant(AttributeVariant.Compact); attributeBuilder.setType(AttributeType.HoldTime); byte[] value = null; int holdTimeMax; if (holdTimeMin == 0) { value = new byte[] {(byte) 0xFF, (byte) 0xFF}; holdTimeMax = 0; } else if (holdTimeMin < 0 || 65535 < holdTimeMin || holdTimeMin < 3) { throw new HoldTimeMinException(holdTimeMin); } else { value = ArraysUtil.combine(ArraysUtil.int2bytesCropp(holdTimeMin, 2)); holdTimeMax = 0; } attributeBuilder.setLength(value.length); attributeBuilder.setValue(value); HoldTimeAttributeBuilder _attributeBuilder = new HoldTimeAttributeBuilder(); HoldTimeAttributesBuilder _attributesBuilder = new HoldTimeAttributesBuilder(); _attributesBuilder.setHoldTimeMinValue(holdTimeMin); _attributesBuilder.setHoldTimeMaxValue(holdTimeMax); _attributeBuilder.setHoldTimeAttributes(_attributesBuilder.build()); attributeBuilder.setAttributeOptionalFields(_attributeBuilder.build()); return attributeBuilder.build(); }  static Attribute createCapabilities(Version version); static Attribute createHoldTime(int holdTimeMin); static Attribute createHoldTime(int holdTimeMin, int holdTimeMax); static Attribute createIpv4AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv4DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6AddPrefix(List<IpPrefix> prefixes, byte flags); static Attribute createIpv6DeletePrefix(List<IpPrefix> prefixes, byte flags); static Attribute createPeerSequence(List<NodeId> nodesIds); static Attribute createSourceGroupTag(int sgt); static Attribute createSxpNodeId(NodeId nodeId); static byte[] encodeCapability(Capabilities capability); static final byte COMPACT; static final byte OPTIONAL_COMPACT; static final byte NONTRANSITIVE_COMPACT; }