import java.io.IOException;
import java.io.InputStream;
-import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiService;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NotificationTapiServiceBuilder;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TargetObjectNameKey;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.notification.tapi.service.TcaInfoBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
public static NotificationTapiService transformTapiNotification(PublishTapiNotificationService notification) {
- Map<AdditionalInfoKey, AdditionalInfo> addInfoMap = new HashMap<>();
- if (notification.getAdditionalInfo() != null) {
- for (org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.AdditionalInfo
- addInfo:notification.getAdditionalInfo().values()) {
- AdditionalInfo transAddInfo = new AdditionalInfoBuilder(addInfo).build();
- addInfoMap.put(transAddInfo.key(), transAddInfo);
- }
- }
- Map<ChangedAttributesKey, ChangedAttributes> changedAttMap = new HashMap<>();
- if (notification.getChangedAttributes() != null) {
- for (org.opendaylight.yang.gen.v1
- .urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes
- changedAtt:notification.getChangedAttributes().values()) {
- ChangedAttributes transChangedAtt = new ChangedAttributesBuilder(changedAtt).build();
- changedAttMap.put(transChangedAtt.key(), transChangedAtt);
- }
- }
- Map<NameKey, Name> nameMap = new HashMap<>();
- if (notification.getName() != null) {
- for (Name name:notification.getName().values()) {
- Name transName = new NameBuilder(name).build();
- nameMap.put(transName.key(), transName);
- }
- }
- Map<TargetObjectNameKey, TargetObjectName> targetObjNameMap = new HashMap<>();
- if (notification.getTargetObjectName() != null) {
- for (org.opendaylight.yang.gen.v1
- .urn.onf.otcc.yang.tapi.notification.rev181210.notification.TargetObjectName
- targetObjectName:notification.getTargetObjectName().values()) {
- TargetObjectName transTargetObjName = new TargetObjectNameBuilder(targetObjectName).build();
- targetObjNameMap.put(transTargetObjName.key(), transTargetObjName);
- }
- }
+ Map<AdditionalInfoKey, AdditionalInfo> addInfoMap = notification.nonnullAdditionalInfo().values().stream()
+ .collect(Collectors.toMap(
+ e -> new AdditionalInfoKey(e.getValueName()),
+ e -> new AdditionalInfoBuilder(e).build()));
+ Map<ChangedAttributesKey, ChangedAttributes> changedAttMap = notification.nonnullChangedAttributes().values()
+ .stream().collect(Collectors.toMap(
+ e -> new ChangedAttributesKey(e.getValueName()),
+ e -> new ChangedAttributesBuilder(e).build()));
+ Map<NameKey, Name> nameMap = notification.nonnullName().values().stream()
+ .collect(Collectors.toMap(Name::key, Function.identity()));
+ Map<TargetObjectNameKey, TargetObjectName> targetObjNameMap = notification.nonnullTargetObjectName().values()
+ .stream().collect(Collectors.toMap(
+ e -> new TargetObjectNameKey(e.getValueName()),
+ e -> new TargetObjectNameBuilder(e).build()));
LOG.info("Notification uuid = {}", notification.getUuid());
return new NotificationTapiServiceBuilder()
.setAlarmInfo(notification.getAlarmInfo() == null ? null
response['output']['service']['end-point'][0]['name'][0])
self.assertDictEqual(dict(input_dict_3, **response['output']['service']['end-point'][1]['name'][0]),
response['output']['service']['end-point'][1]['name'][0])
- # If the gate fails is because of the waiting time not being enough
- time.sleep(self.WAITING)
def test_12_get_service_Ethernet(self):
response = test_utils.get_ordm_serv_list_attr_request("services", str(self.uuid_services.eth))
response = test_utils.transportpce_api_rpc_request(
'tapi-notification', 'get-notification-list', self.cr_get_notif_list_input_data)
self.assertEqual(response['status_code'], requests.codes.ok)
- self.assertEqual(response['output']['notification'][1]['target-object-identifier'], str(self.uuid_services.eth))
- self.assertEqual(response['output']['notification'][1]['target-object-type'], 'CONNECTIVITY_SERVICE')
- self.assertEqual(response['output']['notification'][1]['changed-attributes'][0]['new-value'], 'UNLOCKED')
- self.assertEqual(response['output']['notification'][1]['changed-attributes'][1]['new-value'], 'ENABLED')
+ self.assertEqual(response['output']['notification'][0]['target-object-identifier'], str(self.uuid_services.eth))
+ self.assertEqual(response['output']['notification'][0]['target-object-type'], 'CONNECTIVITY_SERVICE')
+ self.assertEqual(response['output']['notification'][0]['changed-attributes'][0]['new-value'], 'UNLOCKED')
+ self.assertEqual(response['output']['notification'][0]['changed-attributes'][1]['new-value'], 'ENABLED')
time.sleep(2)
def test_19_delete_connectivity_service_Ethernet(self):