taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

ContractTermsTest.kt (2963B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2020 Taler Systems S.A.
      4  *
      5  * GNU Taler is free software; you can redistribute it and/or modify it under the
      6  * terms of the GNU General Public License as published by the Free Software
      7  * Foundation; either version 3, or (at your option) any later version.
      8  *
      9  * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License along with
     14  * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 
     17 package net.taler.common
     18 
     19 import kotlinx.serialization.decodeFromString
     20 import kotlinx.serialization.json.Json
     21 import org.junit.Assert.assertEquals
     22 import org.junit.Test
     23 
     24 class ContractTermsTest {
     25 
     26     private val json = Json {
     27         ignoreUnknownKeys = true
     28     }
     29 
     30     @Test
     31     fun test() {
     32         val jsonStr = """
     33             {
     34               "amount":"TESTKUDOS:0.5",
     35               "extra":{
     36                 "article_name":"1._The_Free_Software_Definition"
     37               },
     38               "fulfillment_url":"https://shop.test.taler.net/essay/1._The_Free_Software_Definition",
     39               "summary":"Essay: 1. The Free Software Definition",
     40               "refund_deadline":{"t_s":"never"},
     41               "wire_transfer_deadline":{"t_s":1596128564},
     42               "products":[],
     43               "h_wire":"KV40K023N8EC1F5100TYNS23C4XN68Y1Z3PTJSWFGTMCNYD54KT4S791V2VQ91SZANN86VDAA369M4VEZ0KR6DN71EVRRZA71K681M0",
     44               "wire_method":"x-taler-bank",
     45               "order_id":"2020.212-01M9VKEAPF76C",
     46               "timestamp":{"t_s":1596128114},
     47               "pay_deadline":{"t_s":"never"},
     48               "max_wire_fee":"TESTKUDOS:1",
     49               "max_fee":"TESTKUDOS:1",
     50               "wire_fee_amortization":3,
     51               "merchant_base_url":"https://backend.test.taler.net/instances/blog/",
     52               "merchant":{"name":"Blog","instance":"blog"},
     53               "exchanges":[
     54                 {
     55                     "url":"https://exchange.test.taler.net/",
     56                     "master_pub":"DY95EXAHQ2BKM2WK9YHZHYG1R7PPMMJPY14FNGP662DAKE35AKQG"
     57                 },
     58                 {
     59                     "url":"https://exchange.test.taler.net/",
     60                     "master_pub":"DY95EXAHQ2BKM2WK9YHZHYG1R7PPMMJPY14FNGP662DAKE35AKQG"}
     61                 ],
     62                 "auditors":[],
     63                 "merchant_pub":"8DR9NKSZY1CXFRE47NEYXM0K85C4ZGAYH7Y7VZ22GPNF0BRFNYNG",
     64                 "nonce":"FK8ZKJRV6VX6YFAG4CDSC6W0DWD084Q09DP81ANF30GRFQYM2KPG"
     65               }
     66         """.trimIndent()
     67         val contractTerms: ContractTerms = json.decodeFromString(jsonStr)
     68         assertEquals("Essay: 1. The Free Software Definition", contractTerms.summary)
     69         assertEquals(Timestamp.never(), contractTerms.refundDeadline)
     70     }
     71 
     72 }