use crate::traits::{SEResource, Validate};
use sep2_common_derive::SEResource;
use yaserde::{YaDeserialize, YaSerialize};
use super::{identification::Link, primitives::String32};
#[derive(Default, PartialEq, Eq, Debug, Clone, YaSerialize, YaDeserialize, SEResource)]
#[yaserde(rename = "ConnectionPoint")]
#[yaserde(prefix = "csipaus", namespace = "csipaus: https://csipaus.org/ns")]
pub struct ConnectionPoint {
#[yaserde(rename = "connectionPointId")]
#[yaserde(prefix = "csipaus", namespace = "csipaus: https://csipaus.org/ns")]
pub connection_pointid: String32,
#[yaserde(attribute, rename = "href")]
pub href: Option<String>,
}
pub type ConnectionPointLink = Link;
impl Validate for ConnectionPoint {}
#[cfg(test)]
use {
super::edev::EndDevice,
crate::{deserialize, serialize},
};
#[test]
fn default_connectionpoint() {
let orig = ConnectionPoint::default();
let new: ConnectionPoint = deserialize(&serialize(&orig).unwrap()).unwrap();
assert_eq!(orig, new);
}
#[test]
fn example_connectionpoint() {
let orig = r#"<csipaus:ConnectionPoint xmlns:csipaus="https://csipaus.org/ns">
<csipaus:connectionPointId>1234567890</csipaus:connectionPointId>
</csipaus:ConnectionPoint>"#;
let new_de: ConnectionPoint = deserialize(orig).unwrap();
let new_se = serialize(&new_de).unwrap();
assert_eq!(orig, new_se);
}
#[test]
fn connectionpoint_edev() {
let expected = r#"<EndDevice xmlns="urn:ieee:std:2030.5:ns" xmlns:csipaus="https://csipaus.org/ns">
<changedTime>0</changedTime>
<csipaus:ConnectionPointLink href="/edev/1/cp" />
<sFDI>0</sFDI>
</EndDevice>"#;
let mut edev = EndDevice::default();
edev.connection_point_link = Some(ConnectionPointLink {
href: "/edev/1/cp".to_owned(),
});
assert_eq!(expected, serialize(&edev).unwrap())
}