Skip to content

Commit

Permalink
Refactoring terminal name -> id
Browse files Browse the repository at this point in the history
  • Loading branch information
djordjeh committed Jan 22, 2025
1 parent 3a5117e commit 8188cf6
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion payment-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ afterEvaluate {
create<MavenPublication>("payment-engine") {
groupId = "de.tillhub.paymentengine"
artifactId = "payment-engine"
version = "3.0.2"
version = "3.0.3"

from(components.getByName("release"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal abstract class CardManagerImpl(
}

override fun putTerminalConfig(config: Terminal) {
configs[config.name] = config
configs[config.id] = config
}

override fun observePaymentState(): StateFlow<TerminalOperationStatus> = terminalState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class ConnectionManagerImpl(
) : CardManagerImpl(configs, terminalState), ConnectionManager {

override fun startSPOSConnect() {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startSPOSConnect(configName)
}

Expand Down Expand Up @@ -68,7 +68,7 @@ internal class ConnectionManagerImpl(
}

override fun startSPOSDisconnect() {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startSPOSDisconnect(configName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PaymentEngine private constructor() {
fun observeTerminalState(): StateFlow<TerminalOperationStatus> = terminalState

fun putTerminalConfig(config: Terminal) {
configs[config.name] = config
configs[config.id] = config
}

fun newPaymentManager(registry: ActivityResultCaller): PaymentManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class PaymentManagerImpl(
tip: BigDecimal,
currency: ISOAlphaCurrency
) {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startPaymentTransaction(transactionId, amount, tip, currency, configName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class ReconciliationManagerImpl(
) : CardManagerImpl(configs, terminalState), ReconciliationManager {

override fun startReconciliation() {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startReconciliation(configName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal class RefundManagerImpl(
amount: BigDecimal,
currency: ISOAlphaCurrency
) {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startRefundTransaction(transactionId, amount, currency, configName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal class ReversalManagerImpl(
currency: ISOAlphaCurrency,
receiptNo: String
) {
val configName = configs.values.firstOrNull()?.name.orEmpty()
val configName = configs.values.firstOrNull()?.id.orEmpty()
startReversalTransaction(
transactionId = transactionId,
amount = amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import java.util.Objects

@Parcelize
sealed class Terminal : Parcelable {
abstract val name: String
abstract val id: String

abstract val saleConfig: CardSaleConfig

class ZVT(
override val name: String = DEFAULT_NAME,
override val id: String = DEFAULT_ZVT_ID,
override val saleConfig: CardSaleConfig = CardSaleConfig(),
val ipAddress: String = DEFAULT_IP_ADDRESS,
val port: Int = DEFAULT_PORT,
val terminalPrinterAvailable: Boolean = DEFAULT_PRINTER_AVAILABLE,
val isoCurrencyNumber: String = DEFAULT_CURRENCY_CODE,
) : Terminal() {
override fun toString() = "Terminal.ZVT(" +
"name=$name, " +
"id=$id, " +
"ipAddress=$ipAddress, " +
"port=$port, " +
"saleConfig=$saleConfig, " +
Expand All @@ -28,15 +28,15 @@ sealed class Terminal : Parcelable {
")"

override fun equals(other: Any?) = other is ZVT &&
name == other.name &&
id == other.id &&
ipAddress == other.ipAddress &&
port == other.port &&
saleConfig == other.saleConfig &&
terminalPrinterAvailable == other.terminalPrinterAvailable &&
isoCurrencyNumber == other.isoCurrencyNumber

override fun hashCode() = Objects.hash(
name,
id,
ipAddress,
port,
saleConfig,
Expand All @@ -45,7 +45,7 @@ sealed class Terminal : Parcelable {
)

companion object {
private const val DEFAULT_NAME = "Default:ZVT"
private const val DEFAULT_ZVT_ID = "Default:ZVT"
const val DEFAULT_IP_ADDRESS = "127.0.0.1"
const val DEFAULT_PORT = 40007
const val DEFAULT_CURRENCY_CODE = "0978"
Expand All @@ -54,15 +54,15 @@ sealed class Terminal : Parcelable {
}

class OPI(
override val name: String = DEFAULT_NAME,
override val id: String = DEFAULT_OPI_ID,
override val saleConfig: CardSaleConfig = CardSaleConfig(),
val ipAddress: String = DEFAULT_IP_ADDRESS,
val port: Int = DEFAULT_PORT_1,
val port2: Int = DEFAULT_PORT_2,
val currencyCode: String = DEFAULT_CURRENCY_CODE,
) : Terminal() {
override fun toString() = "Terminal.OPI(" +
"name=$name, " +
"id=$id, " +
"ipAddress=$ipAddress, " +
"port=$port, " +
"saleConfig=$saleConfig, " +
Expand All @@ -71,15 +71,15 @@ sealed class Terminal : Parcelable {
")"

override fun equals(other: Any?) = other is OPI &&
name == other.name &&
id == other.id &&
ipAddress == other.ipAddress &&
port == other.port &&
saleConfig == other.saleConfig &&
port2 == other.port2 &&
currencyCode == other.currencyCode

override fun hashCode() = Objects.hash(
name,
id,
ipAddress,
port,
saleConfig,
Expand All @@ -88,7 +88,7 @@ sealed class Terminal : Parcelable {
)

companion object {
private const val DEFAULT_NAME = "Default:OPI"
private const val DEFAULT_OPI_ID = "Default:OPI"
const val DEFAULT_IP_ADDRESS = "127.0.0.1"
const val DEFAULT_PORT_1 = 20002
const val DEFAULT_PORT_2 = 20007
Expand All @@ -97,34 +97,34 @@ sealed class Terminal : Parcelable {
}

class SPOS(
override val name: String = DEFAULT_NAME,
override val id: String = DEFAULT_SPOS_ID,
override val saleConfig: CardSaleConfig = CardSaleConfig(),
val appId: String = DEFAULT_APP_ID,
val connected: Boolean = DEFAULT_CONNECTION,
val currencyCode: String = DEFAULT_CURRENCY_CODE,
) : Terminal() {
override fun toString() = "Terminal.SPOS(" +
"name=$name, " +
"id=$id, " +
"appId=$appId, " +
"saleConfig=$saleConfig, " +
"currencyCode=$currencyCode" +
")"

override fun equals(other: Any?) = other is SPOS &&
name == other.name &&
id == other.id &&
appId == other.appId &&
saleConfig == other.saleConfig &&
currencyCode == other.currencyCode

override fun hashCode() = Objects.hash(
name,
id,
appId,
saleConfig,
currencyCode
)

companion object {
private const val DEFAULT_NAME = "Default:SPOS"
private const val DEFAULT_SPOS_ID = "Default:SPOS"
private const val DEFAULT_APP_ID = "TESTCLIENT"
private const val DEFAULT_CONNECTION = false
const val DEFAULT_CURRENCY_CODE = "EUR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CardManagerTest : FunSpec({
test("putTerminalConfig should add terminal to the configs map") {
val terminal = Terminal.OPI()
target.putTerminalConfig(terminal)
verify { configs[terminal.name] = terminal }
verify { configs[terminal.id] = terminal }
}

test("observePaymentState should return the terminal state flow") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PaymentRefundContractTest : FunSpec({
"amount: 500, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.SPOS(" +
"name=s-pos, " +
"id=s-pos, " +
"appId=TESTCLIENT, " +
"saleConfig=CardSaleConfig(" +
"applicationName=Tillhub GO, " +
Expand Down Expand Up @@ -119,7 +119,7 @@ class PaymentRefundContractTest : FunSpec({
"amount: 500, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.OPI(" +
"name=opi, " +
"id=opi, " +
"ipAddress=127.0.0.1, " +
"port=20002, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -172,7 +172,7 @@ class PaymentRefundContractTest : FunSpec({
"amount: 500, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.ZVT(" +
"name=zvt, " +
"id=zvt, " +
"ipAddress=127.0.0.1, " +
"port=40007, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -266,18 +266,18 @@ class PaymentRefundContractTest : FunSpec({
}) {
companion object {
val ZVT = Terminal.ZVT(
name = "zvt",
id = "zvt",
ipAddress = "127.0.0.1",
port = 40007,
)
val OPI = Terminal.OPI(
name = "opi",
id = "opi",
ipAddress = "127.0.0.1",
port = 20002,
port2 = 20007
)
val SPOS = Terminal.SPOS(
name = "s-pos",
id = "s-pos",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PaymentResultContractTest : FunSpec({
"tip: 100, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.SPOS(" +
"name=s-pos, " +
"id=s-pos, " +
"appId=TESTCLIENT, " +
"saleConfig=CardSaleConfig(" +
"applicationName=Tillhub GO, " +
Expand Down Expand Up @@ -125,7 +125,7 @@ class PaymentResultContractTest : FunSpec({
"tip: 100, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.OPI(" +
"name=opi, " +
"id=opi, " +
"ipAddress=127.0.0.1, " +
"port=20002, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -180,7 +180,7 @@ class PaymentResultContractTest : FunSpec({
"tip: 100, " +
"currency: ISOAlphaCurrency(value=EUR))" +
"\nTerminal.ZVT(" +
"name=zvt, " +
"id=zvt, " +
"ipAddress=127.0.0.1, " +
"port=40007, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -252,18 +252,18 @@ class PaymentResultContractTest : FunSpec({
}) {
companion object {
val ZVT = Terminal.ZVT(
name = "zvt",
id = "zvt",
ipAddress = "127.0.0.1",
port = 40007,
)
val OPI = Terminal.OPI(
name = "opi",
id = "opi",
ipAddress = "127.0.0.1",
port = 20002,
port2 = 20007
)
val SPOS = Terminal.SPOS(
name = "s-pos",
id = "s-pos",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class PaymentReversalContractTest : FunSpec({
"Operation: CARD_PAYMENT_REVERSAL(" +
"stan: receiptNo)" +
"\nTerminal.SPOS(" +
"name=s-pos, " +
"id=s-pos, " +
"appId=TESTCLIENT, " +
"saleConfig=CardSaleConfig(" +
"applicationName=Tillhub GO, " +
Expand Down Expand Up @@ -113,7 +113,7 @@ class PaymentReversalContractTest : FunSpec({
"Operation: CARD_PAYMENT_REVERSAL(" +
"stan: receiptNo)" +
"\nTerminal.OPI(" +
"name=opi, " +
"id=opi, " +
"ipAddress=127.0.0.1, " +
"port=20002, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -158,7 +158,7 @@ class PaymentReversalContractTest : FunSpec({
"Operation: CARD_PAYMENT_REVERSAL(" +
"stan: receiptNo)" +
"\nTerminal.ZVT(" +
"name=zvt, " +
"id=zvt, " +
"ipAddress=127.0.0.1, " +
"port=40007, " +
"saleConfig=CardSaleConfig(" +
Expand Down Expand Up @@ -230,18 +230,18 @@ class PaymentReversalContractTest : FunSpec({
}) {
companion object {
val ZVT = Terminal.ZVT(
name = "zvt",
id = "zvt",
ipAddress = "127.0.0.1",
port = 40007,
)
val OPI = Terminal.OPI(
name = "opi",
id = "opi",
ipAddress = "127.0.0.1",
port = 20002,
port2 = 20007
)
val SPOS = Terminal.SPOS(
name = "s-pos",
id = "s-pos",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TerminalConnectContractTest : FunSpec({
analytics.logOperation(
"Operation: TERMINAL_CONNECT" +
"\nTerminal.SPOS(" +
"name=s-pos, " +
"id=s-pos, " +
"appId=TESTCLIENT, " +
"saleConfig=CardSaleConfig(" +
"applicationName=Tillhub GO, " +
Expand Down Expand Up @@ -121,13 +121,13 @@ class TerminalConnectContractTest : FunSpec({
}) {
companion object {
val OPI = Terminal.OPI(
name = "opi",
id = "opi",
ipAddress = "127.0.0.1",
port = 20002,
port2 = 20007
)
val SPOS = Terminal.SPOS(
name = "s-pos",
id = "s-pos",
)
}
}
Loading

0 comments on commit 8188cf6

Please sign in to comment.