/*
 Copyright 2017 the original author or authors.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package models_test

import (
	"net"
	"testing"

	"gerrit.opencord.org/abstract-olt/internal/pkg/settings"
	"gerrit.opencord.org/abstract-olt/models"
	"gerrit.opencord.org/abstract-olt/models/abstract"
	"gerrit.opencord.org/abstract-olt/models/physical"
)

var chassisMap *map[string]*models.ChassisHolder
var clli string
var json []byte

func TestChassisSerialize_Serialize(t *testing.T) {
	//func (chassisHolder ChassisHolder) Serialize() ([]byte, error) {
	settings.SetDummy(true)
	clli = "TEST_CLLI"
	chassisMap = models.GetChassisMap()
	abstractChassis := abstract.GenerateChassis(clli, 1, 1)
	phyChassis := physical.Chassis{CLLI: clli, VCoreAddress: net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234}, Rack: 1, Shelf: 1}
	chassisHolder := &models.ChassisHolder{AbstractChassis: abstractChassis, PhysicalChassis: phyChassis}
	(*chassisMap)[clli] = chassisHolder
	sOlt := physical.SimpleOLT{CLLI: clli, Hostname: "slot1", Address: net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234}, Parent: &phyChassis}
	phyChassis.AddOLTChassis(sOlt)
	ports := sOlt.GetPorts()
	for i := 0; i < len(ports); i++ {
		absPort, _ := chassisHolder.AbstractChassis.NextPort()

		absPort.PhysPort = &ports[i]
		//AssignTraits(&ports[i], absPort)
	}
	var err error
	json, err = chassisHolder.Serialize()
	if err != nil {
		t.Fatalf("TestChassisSerialize_Serialize failed with %v\n", err)
	}
}

func TestChassisSerialize_Deserialize(t *testing.T) {
	//func (chassisHolder *ChassisHolder) Deserialize(jsonData []byte) error {
	chassisHolder := models.ChassisHolder{}
	err := chassisHolder.Deserialize(json)
	if err != nil {
		t.Fatalf("Deserialize threw an error %v\n", err)
	}
	newJSON, _ := chassisHolder.Serialize()
	if string(json) != string(newJSON) {
		t.Fatalf("Failed to de-serialize and serialize accurately")
	}
}
