@Test public void testDecodeCapabilities() throws Exception { List<CapabilityType> capabilityTypes = MessageFactory.decodeCapabilities((OpenMessage) MessageFactory.decodeOpen( new byte[] {0, 0, 0, 4, 0, 0, 0, 2, 80, 6, 6, 3, 0, 2, 0, 1, 0, 80, 7, 4, 0, 120, 0, -106})); assertTrue(capabilityTypes.contains(CapabilityType.SubnetBindings)); assertTrue(capabilityTypes.contains(CapabilityType.Ipv4Unicast)); assertTrue(capabilityTypes.contains(CapabilityType.Ipv6Unicast)); try { MessageFactory.decodeCapabilities((OpenMessage) MessageFactory.decodeOpen( new byte[] {0, 0, 0, 4, 0, 0, 0, 1, 80, 5, 4, -64, -88, 0, 1, 80, 7, 4, 0, 120, 0, -106})); fail(); } catch (AttributeNotFoundException ignored) { } }
public static List<CapabilityType> decodeCapabilities(OpenMessage message) throws AttributeNotFoundException { CapabilitiesAttribute capabilitiesAttribute = (CapabilitiesAttribute) AttributeList.get(Preconditions.checkNotNull(message).getAttribute(), AttributeType.Capabilities); return capabilitiesAttribute.getCapabilitiesAttributes().getCapabilities() .stream() .map(CapabilityAttributeFields::getCode) .collect(Collectors.toList()); }
MessageFactory { public static List<CapabilityType> decodeCapabilities(OpenMessage message) throws AttributeNotFoundException { CapabilitiesAttribute capabilitiesAttribute = (CapabilitiesAttribute) AttributeList.get(Preconditions.checkNotNull(message).getAttribute(), AttributeType.Capabilities); return capabilitiesAttribute.getCapabilitiesAttributes().getCapabilities() .stream() .map(CapabilityAttributeFields::getCode) .collect(Collectors.toList()); } }
MessageFactory { public static List<CapabilityType> decodeCapabilities(OpenMessage message) throws AttributeNotFoundException { CapabilitiesAttribute capabilitiesAttribute = (CapabilitiesAttribute) AttributeList.get(Preconditions.checkNotNull(message).getAttribute(), AttributeType.Capabilities); return capabilitiesAttribute.getCapabilitiesAttributes().getCapabilities() .stream() .map(CapabilityAttributeFields::getCode) .collect(Collectors.toList()); }  }
MessageFactory { public static List<CapabilityType> decodeCapabilities(OpenMessage message) throws AttributeNotFoundException { CapabilitiesAttribute capabilitiesAttribute = (CapabilitiesAttribute) AttributeList.get(Preconditions.checkNotNull(message).getAttribute(), AttributeType.Capabilities); return capabilitiesAttribute.getCapabilitiesAttributes().getCapabilities() .stream() .map(CapabilityAttributeFields::getCode) .collect(Collectors.toList()); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message); }
MessageFactory { public static List<CapabilityType> decodeCapabilities(OpenMessage message) throws AttributeNotFoundException { CapabilitiesAttribute capabilitiesAttribute = (CapabilitiesAttribute) AttributeList.get(Preconditions.checkNotNull(message).getAttribute(), AttributeType.Capabilities); return capabilitiesAttribute.getCapabilitiesAttributes().getCapabilities() .stream() .map(CapabilityAttributeFields::getCode) .collect(Collectors.toList()); }  static ByteBuf createError(ErrorCode errorCode, ErrorSubCode errorSubCode, byte[] data); static ByteBuf createKeepalive(); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMinAcceptable); static ByteBuf createOpen(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID,
            int holdTimeMinAcceptable); static ByteBuf createOpenResp(Version version, ConnectionMode nodeMode, NodeId nodeID, int holdTimeMin,
            int holdTimeMax); static ByteBuf createPurgeAll(); static ByteBuf createUpdate(List<R> deleteBindings,
            List<T> addBindings, NodeId nodeId, List<CapabilityType> capabilities, SxpBindingFilter bindingFilter); static Notification decodeErrorMessage(byte[] payload); static Notification decodeKeepalive(byte[] payload); static Notification decodeOpen(byte[] payload); static Notification decodeOpenResp(byte[] payload); static Version extractVersion(final byte[] payload); static Notification decodePurgeAll(byte[] payload); static Notification decodeUpdate(byte[] payload); static Notification parse(Version version, ByteBuf request); static String toString(byte[] message); static String toString(ByteBuf message); static String toString(Notification message); static List<CapabilityType> decodeCapabilities(OpenMessage message);  }