[VOL-3986] Correctly serializing GemPortNetworkCtpPerformanceMonitoringHistoryData ME in GetResponse

Change-Id: Id3c7528c005afa1eab8cb0b373d3adb3a9958b5d
diff --git a/internal/common/omci/get.go b/internal/common/omci/get.go
index 4b02bda..efa768f 100644
--- a/internal/common/omci/get.go
+++ b/internal/common/omci/get.go
@@ -101,7 +101,7 @@
 		omciLogger.WithFields(log.Fields{
 			"Err":  err,
 			"TxID": strconv.FormatInt(int64(omciMsg.TransactionID), 16),
-		}).Error("cannot-Serialize-Onu2gResponse")
+		}).Error("cannot-Serialize-GetResponse")
 		return nil, err
 	}
 
@@ -357,21 +357,6 @@
 		return nil
 	}
 
-	// L2 PM counters MEs exceed max allowed OMCI payload size.
-	// So the request/responses are always multipart.
-	// First identify the attributes that are not requested in the current GET request.
-	// Then filter out those attributes from the responses in the current GET response.
-	unwantedAttributeMask := ^attributeMask
-	var i uint16
-	for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
-		// We leave out 0 because that is ManagedEntity and that is a default IE in the map
-		if (1<<(16-i))&unwantedAttributeMask > 0 {
-			if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
-				omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
-			}
-		}
-	}
-
 	return &omci.GetResponse{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass:    me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID,
@@ -412,21 +397,6 @@
 		return nil
 	}
 
-	// L2 PM counters MEs exceed max allowed OMCI payload size.
-	// So the request/responses are always multipart.
-	// First identify the attributes that are not requested in the current GET request.
-	// Then filter out those attributes from the responses in the current GET response.
-	unwantedAttributeMask := ^attributeMask
-	var i uint16
-	for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
-		// We leave out 0 because that is ManagedEntity and that is a default IE in the map
-		if (1<<(16-i))&unwantedAttributeMask > 0 {
-			if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
-				omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
-			}
-		}
-	}
-
 	return &omci.GetResponse{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass:    me.EthernetFramePerformanceMonitoringHistoryDataDownstreamClassID,
@@ -467,21 +437,6 @@
 		return nil
 	}
 
-	// L2 PM counters MEs exceed max allowed OMCI payload size.
-	// So the request/responses are always multipart.
-	// First identify the attributes that are not requested in the current GET request.
-	// Then filter out those attributes from the responses in the current GET response.
-	unwantedAttributeMask := ^attributeMask
-	var i uint16
-	for i = 1; i <= 16; i++ { // 1 and 16 because they are allowed valid min and max index keys in AttributeValueMap.
-		// We leave out 0 because that is ManagedEntity and that is a default IE in the map
-		if (1<<(16-i))&unwantedAttributeMask > 0 {
-			if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
-				omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
-			}
-		}
-	}
-
 	return &omci.GetResponse{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass:    me.EthernetPerformanceMonitoringHistoryDataClassID,
@@ -547,21 +502,6 @@
 		return nil
 	}
 
-	// L2 PM counters MEs exceed max allowed OMCI payload size.
-	// So the request/responses are always multipart.
-	// First identify the attributes that are not requested in the current GET request.
-	// Then filter out those attributes from the responses in the current GET response.
-	unwantedAttributeMask := ^attributeMask
-	var i uint16
-	for i = 1; i <= 7; i++ { // 1 and 7 because they are allowed valid min and max index keys in AttributeValueMap.
-		// We leave out 0 because that is ManagedEntity and that is a default IE in the map
-		if (1<<(7-i))&unwantedAttributeMask > 0 {
-			if err := managedEntity.DeleteAttributeByIndex(uint(i)); err != nil {
-				omciLogger.Errorf("error deleting attribute at index=%v, err=%v", i, err)
-			}
-		}
-	}
-
 	return &omci.GetResponse{
 		MeBasePacket: omci.MeBasePacket{
 			EntityClass:    me.GemPortNetworkCtpPerformanceMonitoringHistoryDataClassID,
diff --git a/internal/common/omci/get_test.go b/internal/common/omci/get_test.go
index d995bba..0d9663f 100644
--- a/internal/common/omci/get_test.go
+++ b/internal/common/omci/get_test.go
@@ -92,11 +92,30 @@
 			getArgs{createOnuDataResponse(32768, 10, 129), 2},
 			getWant{2, map[string]interface{}{"MibDataSync": uint8(129)}},
 		},
+		{"getGemPortNetworkCtpPerformanceMonitoringHistoryDataResponse",
+			getArgs{createGemPortNetworkCtpPerformanceMonitoringHistoryData(32768, 10), 2},
+			getWant{2, map[string]interface{}{"ManagedEntityId": uint16(10)}},
+		},
+		{"getEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse",
+			getArgs{createEthernetFramePerformanceMonitoringHistoryDataUpstreamResponse(32768, 10), 2},
+			getWant{2, map[string]interface{}{"ManagedEntityId": uint16(10)}},
+		},
+		{"getEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse",
+			getArgs{createEthernetFramePerformanceMonitoringHistoryDataDownstreamResponse(32768, 10), 2},
+			getWant{2, map[string]interface{}{"ManagedEntityId": uint16(10)}},
+		},
+		{"getEthernetPerformanceMonitoringHistoryDataResponse",
+			getArgs{createEthernetPerformanceMonitoringHistoryDataResponse(32768, 10), 2},
+			getWant{2, map[string]interface{}{"ManagedEntityId": uint16(10)}},
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
 
-			data, _ := Serialize(omci.GetResponseType, tt.args.generatedPkt, tt.args.transactionId)
+			data, err := Serialize(omci.GetResponseType, tt.args.generatedPkt, tt.args.transactionId)
+			if err != nil {
+				t.Fatal("cannot-serial-omci-packet", err)
+			}
 
 			// emulate the openonu-go behavior:
 			// omci_cc.receiveMessage process the message (creates a gopacket and extracts the OMCI layer) and invokes a callback