com.zepben.evolve.services.customer.CustomerServiceComparator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of evolve-sdk Show documentation
Show all versions of evolve-sdk Show documentation
SDK for interaction with the evolve platform
/*
* Copyright 2020 Zeppelin Bend Pty Ltd
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.zepben.evolve.services.customer
import com.zepben.evolve.cim.iec61968.common.Agreement
import com.zepben.evolve.cim.iec61968.customers.Customer
import com.zepben.evolve.cim.iec61968.customers.CustomerAgreement
import com.zepben.evolve.cim.iec61968.customers.PricingStructure
import com.zepben.evolve.cim.iec61968.customers.Tariff
import com.zepben.evolve.services.common.BaseServiceComparator
import com.zepben.evolve.services.common.ObjectDifference
/**
* A class for comparing the contents of a [CustomerService].
*
* NOTE: Unused functions have been suppressed for this class as they are access by reflection rather than directly. This
* means they are always flagged as unused. By suppressing the warning it also means you might not be testing every
* function, so make sure you check the code coverage
*/
@Suppress("unused")
class CustomerServiceComparator : BaseServiceComparator() {
private fun ObjectDifference.compareAgreement(): ObjectDifference =
apply { compareDocument() }
private fun compareCustomer(source: Customer, target: Customer): ObjectDifference =
ObjectDifference(source, target).apply {
compareOrganisationRole()
compareValues(Customer::kind, Customer::numEndDevices, Customer::specialNeed)
compareIdReferenceCollections(Customer::agreements)
}
private fun compareCustomerAgreement(source: CustomerAgreement, target: CustomerAgreement): ObjectDifference =
ObjectDifference(source, target).apply {
compareAgreement()
compareIdReferences(CustomerAgreement::customer)
compareIdReferenceCollections(CustomerAgreement::pricingStructures)
}
private fun comparePricingStructure(source: PricingStructure, target: PricingStructure): ObjectDifference =
ObjectDifference(source, target).apply {
compareDocument()
compareIdReferenceCollections(PricingStructure::tariffs)
}
private fun compareTariff(source: Tariff, target: Tariff): ObjectDifference =
ObjectDifference(source, target).apply { compareDocument() }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy