@@ -279,7 +279,6 @@ impl UMessageBuilder {
279279 priority : request_attributes
280280 . priority
281281 . enum_value_or ( UPriority :: UPRIORITY_CS4 ) ,
282- // [impl->dsn~up-attributes-response-ttl~1]
283282 ttl : request_attributes. ttl ,
284283 ..Default :: default ( )
285284 }
@@ -372,9 +371,6 @@ impl UMessageBuilder {
372371 pub fn with_priority ( & mut self , priority : UPriority ) -> & mut UMessageBuilder {
373372 // [impl->dsn~up-attributes-request-priority~1]
374373 if self . message_type == UMessageType :: UMESSAGE_TYPE_REQUEST
375- // up-spec erroneously uses this name to define a requirement
376- // for the response's priority class ...
377- // [impl->dsn~up-attributes-response-reqid~1]
378374 || self . message_type == UMessageType :: UMESSAGE_TYPE_RESPONSE
379375 {
380376 assert ! ( priority. value( ) >= UPriority :: UPRIORITY_CS4 . value( ) )
@@ -530,7 +526,6 @@ impl UMessageBuilder {
530526 /// # }
531527 /// ```
532528 pub fn with_comm_status ( & mut self , comm_status : UCode ) -> & mut UMessageBuilder {
533- // [impl->dsn~up-attributes-response-commstatus~1]
534529 assert ! ( self . message_type == UMessageType :: UMESSAGE_TYPE_RESPONSE ) ;
535530 self . comm_status = Some ( comm_status. into ( ) ) ;
536531 self
@@ -800,6 +795,7 @@ mod tests {
800795
801796 use super :: * ;
802797
798+ use protobuf:: Message ;
803799 use test_case:: test_case;
804800
805801 const METHOD_TO_INVOKE : & str = "//my-vehicle/4D123/2/6FA3" ;
@@ -820,7 +816,6 @@ mod tests {
820816
821817 // [utest->dsn~up-attributes-permission-level~1]
822818 #[ test_case( Some ( 5 ) , None , None ; "with permission level" ) ]
823- // [utest->dsn~up-attributes-response-commstatus~1]
824819 #[ test_case( None , Some ( UCode :: NOT_FOUND ) , None ; "with commstatus" ) ]
825820 // [utest->dsn~up-attributes-request-token~1]
826821 #[ test_case( None , None , Some ( String :: from( "my-token" ) ) ; "with token" ) ]
@@ -843,7 +838,6 @@ mod tests {
843838
844839 // [utest->dsn~up-attributes-permission-level~1]
845840 #[ test_case( Some ( 5 ) , None , None ; "with permission level" ) ]
846- // [utest->dsn~up-attributes-response-commstatus~1]
847841 #[ test_case( None , Some ( UCode :: NOT_FOUND ) , None ; "with commstatus" ) ]
848842 // [utest->dsn~up-attributes-request-token~1]
849843 #[ test_case( None , None , Some ( String :: from( "my-token" ) ) ; "with token" ) ]
@@ -870,17 +864,15 @@ mod tests {
870864 #[ test_case( Some ( 5 ) , None , None ; "with permission level" ) ]
871865 // [utest->dsn~up-attributes-request-token~1]
872866 #[ test_case( None , Some ( String :: from( "my-token" ) ) , None ; "with token" ) ]
873- // up-spec erroneously uses this name to define a requirement
874- // for the response's priority class ...
875- // [utest->dsn~up-attributes-response-reqid~1]
867+ // [utest->dsn~up-attributes-request-priority~1]
876868 #[ test_case( None , None , Some ( UPriority :: UPRIORITY_UNSPECIFIED ) ; "with priority UNSPECIFIED" ) ]
877- // [utest->dsn~up-attributes-response-reqid ~1]
869+ // [utest->dsn~up-attributes-request-priority ~1]
878870 #[ test_case( None , None , Some ( UPriority :: UPRIORITY_CS0 ) ; "with priority CS0" ) ]
879- // [utest->dsn~up-attributes-response-reqid ~1]
871+ // [utest->dsn~up-attributes-request-priority ~1]
880872 #[ test_case( None , None , Some ( UPriority :: UPRIORITY_CS1 ) ; "with priority CS1" ) ]
881- // [utest->dsn~up-attributes-response-reqid ~1]
873+ // [utest->dsn~up-attributes-request-priority ~1]
882874 #[ test_case( None , None , Some ( UPriority :: UPRIORITY_CS2 ) ; "with priority CS2" ) ]
883- // [utest->dsn~up-attributes-response-reqid ~1]
875+ // [utest->dsn~up-attributes-request-priority ~1]
884876 #[ test_case( None , None , Some ( UPriority :: UPRIORITY_CS3 ) ; "with priority CS3" ) ]
885877 #[ should_panic]
886878 fn test_response_message_builder_panics (
@@ -904,7 +896,6 @@ mod tests {
904896 }
905897 }
906898
907- // [utest->dsn~up-attributes-response-commstatus~1]
908899 #[ test_case( Some ( UCode :: NOT_FOUND ) , None ; "for comm status" ) ]
909900 // [utest->dsn~up-attributes-request-priority~1]
910901 #[ test_case( None , Some ( UPriority :: UPRIORITY_UNSPECIFIED ) ; "for priority class unspecified" ) ]
@@ -953,6 +944,8 @@ mod tests {
953944 }
954945
955946 #[ test]
947+ // [utest->req~uattributes-data-model-impl~1]
948+ // [utest->req~umessage-data-model-impl~1]
956949 fn test_build_retains_all_publish_attributes ( ) {
957950 let message_id = UUID :: build ( ) ;
958951 let traceparent = String :: from ( "traceparent" ) ;
@@ -963,9 +956,9 @@ mod tests {
963956 . with_traceparent ( & traceparent)
964957 . build_with_payload ( "locked" , UPayloadFormat :: UPAYLOAD_FORMAT_TEXT )
965958 . expect ( "should have been able to create message" ) ;
959+
966960 // [utest->dsn~up-attributes-id~1]
967961 assert_eq ! ( message. id_unchecked( ) , & message_id) ;
968- // [utest->dsn~up-attributes-priority~1]
969962 assert ! ( UAttributes :: is_default_priority(
970963 message. priority_unchecked( )
971964 ) ) ;
@@ -985,9 +978,20 @@ mod tests {
985978 message. payload_format_unchecked( ) ,
986979 UPayloadFormat :: UPAYLOAD_FORMAT_TEXT
987980 ) ;
981+
982+ // [utest->req~uattributes-data-model-proto~1]
983+ // [utest->req~umessage-data-model-proto~1]
984+ let proto = message
985+ . write_to_bytes ( )
986+ . expect ( "failed to serialize to protobuf" ) ;
987+ let deserialized_message =
988+ UMessage :: parse_from_bytes ( proto. as_slice ( ) ) . expect ( "failed to deserialize protobuf" ) ;
989+ assert_eq ! ( message, deserialized_message) ;
988990 }
989991
990992 #[ test]
993+ // [utest->req~uattributes-data-model-impl~1]
994+ // [utest->req~umessage-data-model-impl~1]
991995 fn test_build_retains_all_notification_attributes ( ) {
992996 let message_id = UUID :: build ( ) ;
993997 let traceparent = String :: from ( "traceparent" ) ;
@@ -1001,6 +1005,7 @@ mod tests {
10011005 . with_traceparent ( & traceparent)
10021006 . build_with_payload ( "locked" , UPayloadFormat :: UPAYLOAD_FORMAT_TEXT )
10031007 . expect ( "should have been able to create message" ) ;
1008+
10041009 // [utest->dsn~up-attributes-id~1]
10051010 assert_eq ! ( message. id_unchecked( ) , & message_id) ;
10061011 assert_eq ! ( message. priority_unchecked( ) , UPriority :: UPRIORITY_CS2 ) ;
@@ -1019,9 +1024,20 @@ mod tests {
10191024 message. payload_format_unchecked( ) ,
10201025 UPayloadFormat :: UPAYLOAD_FORMAT_TEXT
10211026 ) ;
1027+
1028+ // [utest->req~uattributes-data-model-proto~1]
1029+ // [utest->req~umessage-data-model-proto~1]
1030+ let proto = message
1031+ . write_to_bytes ( )
1032+ . expect ( "failed to serialize to protobuf" ) ;
1033+ let deserialized_message =
1034+ UMessage :: parse_from_bytes ( proto. as_slice ( ) ) . expect ( "failed to deserialize protobuf" ) ;
1035+ assert_eq ! ( message, deserialized_message) ;
10221036 }
10231037
10241038 #[ test]
1039+ // [utest->req~uattributes-data-model-impl~1]
1040+ // [utest->req~umessage-data-model-impl~1]
10251041 fn test_build_retains_all_request_attributes ( ) {
10261042 let message_id = UUID :: build ( ) ;
10271043 let token = String :: from ( "token" ) ;
@@ -1062,6 +1078,15 @@ mod tests {
10621078 message. payload_format_unchecked( ) ,
10631079 UPayloadFormat :: UPAYLOAD_FORMAT_TEXT
10641080 ) ;
1081+
1082+ // [utest->req~uattributes-data-model-proto~1]
1083+ // [utest->req~umessage-data-model-proto~1]
1084+ let proto = message
1085+ . write_to_bytes ( )
1086+ . expect ( "failed to serialize to protobuf" ) ;
1087+ let deserialized_message =
1088+ UMessage :: parse_from_bytes ( proto. as_slice ( ) ) . expect ( "failed to deserialize protobuf" ) ;
1089+ assert_eq ! ( message, deserialized_message) ;
10651090 }
10661091
10671092 #[ test]
@@ -1086,14 +1111,10 @@ mod tests {
10861111 // [utest->dsn~up-attributes-id~1]
10871112 assert_eq ! ( message. id_unchecked( ) , & response_message_id) ;
10881113 assert_eq ! ( message. commstatus_unchecked( ) , UCode :: DEADLINE_EXCEEDED ) ;
1089- // up-spec erroneously uses this name to define a requirement
1090- // for the response's priority class ...
1091- // [utest->dsn~up-attributes-response-reqid~1]
10921114 assert_eq ! ( message. priority_unchecked( ) , UPriority :: UPRIORITY_CS5 ) ;
10931115 assert_eq ! ( message. request_id_unchecked( ) , & request_message_id) ;
10941116 assert_eq ! ( message. sink_unchecked( ) , & reply_to_address) ;
10951117 assert_eq ! ( message. source_unchecked( ) , & method_to_invoke) ;
1096- // [utest->dsn~up-attributes-response-ttl~1]
10971118 assert_eq ! ( message. ttl_unchecked( ) , 5000 ) ;
10981119 // [utest->dsn~up-attributes-response-type~1]
10991120 assert_eq ! (
@@ -1108,6 +1129,8 @@ mod tests {
11081129 }
11091130
11101131 #[ test]
1132+ // [utest->req~uattributes-data-model-impl~1]
1133+ // [utest->req~umessage-data-model-impl~1]
11111134 fn test_build_retains_all_response_attributes ( ) {
11121135 let message_id = UUID :: build ( ) ;
11131136 let request_id = UUID :: build ( ) ;
@@ -1128,9 +1151,9 @@ mod tests {
11281151 . with_traceparent ( & traceparent)
11291152 . build ( )
11301153 . expect ( "should have been able to create message" ) ;
1154+
11311155 // [utest->dsn~up-attributes-id~1]
11321156 assert_eq ! ( message. id_unchecked( ) , & message_id) ;
1133- // [utest->dsn~up-attributes-response-commstatus~1]
11341157 assert_eq ! ( message. commstatus_unchecked( ) , UCode :: DEADLINE_EXCEEDED ) ;
11351158 assert_eq ! ( message. priority_unchecked( ) , UPriority :: UPRIORITY_CS5 ) ;
11361159 assert_eq ! ( message. request_id_unchecked( ) , & request_id) ;
@@ -1149,5 +1172,14 @@ mod tests {
11491172 UPayloadFormat :: UPAYLOAD_FORMAT_UNSPECIFIED
11501173 ) ;
11511174 assert ! ( message. payload. is_none( ) ) ;
1175+
1176+ // [utest->req~uattributes-data-model-proto~1]
1177+ // [utest->req~umessage-data-model-proto~1]
1178+ let proto = message
1179+ . write_to_bytes ( )
1180+ . expect ( "failed to serialize to protobuf" ) ;
1181+ let deserialized_message =
1182+ UMessage :: parse_from_bytes ( proto. as_slice ( ) ) . expect ( "failed to deserialize protobuf" ) ;
1183+ assert_eq ! ( message, deserialized_message) ;
11521184 }
11531185}
0 commit comments