|
13 | 13 |
|
14 | 14 | package it.fattureincloud.sdk.model;
|
15 | 15 |
|
| 16 | +import com.google.gson.Gson; |
16 | 17 | import com.google.gson.TypeAdapter;
|
17 | 18 | import com.google.gson.annotations.JsonAdapter;
|
18 | 19 | import com.google.gson.annotations.SerializedName;
|
19 | 20 | import com.google.gson.stream.JsonReader;
|
20 | 21 | import com.google.gson.stream.JsonWriter;
|
| 22 | + |
| 23 | +import it.fattureincloud.sdk.JSON; |
21 | 24 | import it.fattureincloud.sdk.model.PaymentAccount;
|
22 | 25 | import it.fattureincloud.sdk.model.PaymentMethod;
|
23 | 26 | import it.fattureincloud.sdk.model.PriceList;
|
24 | 27 | import it.fattureincloud.sdk.model.VatType;
|
| 28 | + |
| 29 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 30 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 31 | + |
25 | 32 | import java.io.IOException;
|
26 | 33 | import java.math.BigDecimal;
|
27 | 34 | import java.util.ArrayList;
|
28 | 35 | import java.util.Arrays;
|
29 | 36 | import java.util.List;
|
30 | 37 | import org.openapitools.jackson.nullable.JsonNullable;
|
| 38 | +import org.junit.jupiter.api.BeforeEach; |
31 | 39 | import org.junit.jupiter.api.Disabled;
|
32 | 40 | import org.junit.jupiter.api.Test;
|
33 | 41 |
|
34 | 42 | /**
|
35 | 43 | * Model tests for EntityClientPreCreateInfo
|
36 | 44 | */
|
37 | 45 | public class EntityClientPreCreateInfoTest {
|
38 |
| - private final EntityClientPreCreateInfo model = new EntityClientPreCreateInfo(); |
| 46 | + private EntityClientPreCreateInfo model; |
| 47 | + |
| 48 | + @BeforeEach |
| 49 | + public void init() { |
| 50 | + model = |
| 51 | + new EntityClientPreCreateInfo() |
| 52 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 53 | + .paymentMethodsList( |
| 54 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 55 | + .paymentAccountsList( |
| 56 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 57 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 58 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 59 | + } |
39 | 60 |
|
40 | 61 | /**
|
41 | 62 | * Model tests for EntityClientPreCreateInfo
|
42 | 63 | */
|
43 | 64 | @Test
|
44 | 65 | public void testEntityClientPreCreateInfo() {
|
45 |
| - // TODO: test EntityClientPreCreateInfo |
| 66 | + JSON jsonManager = new JSON(); |
| 67 | + Gson gson = jsonManager.getGson(); |
| 68 | + String json = gson.toJson(model); |
| 69 | + String str = |
| 70 | + "{\"countries_list\":[\"Italia\",\"Marocco\"],\"payment_methods_list\":[{\"id\":1,\"type\":\"standard\"},{\"id\":2,\"type\":\"standard\"}],\"payment_accounts_list\":[{\"id\":1,\"type\":\"standard\"},{\"id\":2,\"type\":\"standard\"}],\"vat_types_list\":[{\"id\":1},{\"id\":2}],\"price_lists\":[{\"id\":\"12345\"}]}"; |
| 71 | + assertEquals(str, json); |
| 72 | + EntityClientPreCreateInfo generated = gson.fromJson(str, EntityClientPreCreateInfo.class); |
| 73 | + assertEquals(model, generated); |
| 74 | + |
| 75 | + Object o = model; |
| 76 | + assertEquals(model, o); |
| 77 | + assertFalse(model.equals(null)); |
| 78 | + assertFalse(model.equals(Integer.getInteger("5"))); |
46 | 79 | }
|
47 | 80 |
|
48 | 81 | /**
|
49 | 82 | * Test the property 'countriesList'
|
50 | 83 | */
|
51 | 84 | @Test
|
52 | 85 | public void countriesListTest() {
|
53 |
| - // TODO: test countriesList |
| 86 | + assertEquals(model.getCountriesList(), Arrays.asList("Italia", "Marocco")); |
| 87 | + model.setCountriesList(Arrays.asList("Italia", "Marocco", "Francia")); |
| 88 | + assertEquals(model.getCountriesList(), Arrays.asList("Italia", "Marocco", "Francia")); |
| 89 | + EntityClientPreCreateInfo a = model.countriesList(Arrays.asList("Italia", "Marocco")); |
| 90 | + EntityClientPreCreateInfo expected = |
| 91 | + new EntityClientPreCreateInfo() |
| 92 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 93 | + .paymentMethodsList( |
| 94 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 95 | + .paymentAccountsList( |
| 96 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 97 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 98 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 99 | + assertEquals(expected, a); |
54 | 100 | }
|
55 | 101 |
|
56 | 102 | /**
|
57 | 103 | * Test the property 'paymentMethodsList'
|
58 | 104 | */
|
59 | 105 | @Test
|
60 | 106 | public void paymentMethodsListTest() {
|
61 |
| - // TODO: test paymentMethodsList |
| 107 | + assertEquals(1, model.getPaymentMethodsList().get(0).getId()); |
| 108 | + assertEquals(2, model.getPaymentMethodsList().get(1).getId()); |
| 109 | + model.setPaymentMethodsList( |
| 110 | + Arrays.asList(new PaymentMethod().id(3), new PaymentMethod().id(4))); |
| 111 | + assertEquals(3, model.getPaymentMethodsList().get(0).getId()); |
| 112 | + assertEquals(4, model.getPaymentMethodsList().get(1).getId()); |
| 113 | + EntityClientPreCreateInfo a = model.paymentMethodsList( |
| 114 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))); |
| 115 | + EntityClientPreCreateInfo expected = |
| 116 | + new EntityClientPreCreateInfo() |
| 117 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 118 | + .paymentMethodsList( |
| 119 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 120 | + .paymentAccountsList( |
| 121 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 122 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 123 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 124 | + assertEquals(expected, a); |
62 | 125 | }
|
63 | 126 |
|
64 | 127 | /**
|
65 | 128 | * Test the property 'paymentAccountsList'
|
66 | 129 | */
|
67 | 130 | @Test
|
68 | 131 | public void paymentAccountsListTest() {
|
69 |
| - // TODO: test paymentAccountsList |
| 132 | + assertEquals(1, model.getPaymentAccountsList().get(0).getId()); |
| 133 | + assertEquals(2, model.getPaymentAccountsList().get(1).getId()); |
| 134 | + model.setPaymentAccountsList( |
| 135 | + Arrays.asList(new PaymentAccount().id(3), new PaymentAccount().id(4))); |
| 136 | + assertEquals(3, model.getPaymentAccountsList().get(0).getId()); |
| 137 | + assertEquals(4, model.getPaymentAccountsList().get(1).getId()); |
| 138 | + EntityClientPreCreateInfo a = model.paymentAccountsList( |
| 139 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))); |
| 140 | + EntityClientPreCreateInfo expected = |
| 141 | + new EntityClientPreCreateInfo() |
| 142 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 143 | + .paymentMethodsList( |
| 144 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 145 | + .paymentAccountsList( |
| 146 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 147 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 148 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 149 | + assertEquals(expected, a); |
70 | 150 | }
|
71 | 151 |
|
72 | 152 | /**
|
73 | 153 | * Test the property 'vatTypesList'
|
74 | 154 | */
|
75 | 155 | @Test
|
76 | 156 | public void vatTypesListTest() {
|
77 |
| - // TODO: test vatTypesList |
| 157 | + assertEquals(1, model.getVatTypesList().get(0).getId()); |
| 158 | + assertEquals(2, model.getVatTypesList().get(1).getId()); |
| 159 | + model.setVatTypesList(Arrays.asList(new VatType().id(3), new VatType().id(4))); |
| 160 | + assertEquals(3, model.getVatTypesList().get(0).getId()); |
| 161 | + assertEquals(4, model.getVatTypesList().get(1).getId()); |
| 162 | + EntityClientPreCreateInfo a = model.vatTypesList( |
| 163 | + Arrays.asList(new VatType().id(1), new VatType().id(2))); |
| 164 | + EntityClientPreCreateInfo expected = |
| 165 | + new EntityClientPreCreateInfo() |
| 166 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 167 | + .paymentMethodsList( |
| 168 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 169 | + .paymentAccountsList( |
| 170 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 171 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 172 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 173 | + assertEquals(expected, a); |
78 | 174 | }
|
79 | 175 |
|
80 | 176 | /**
|
81 | 177 | * Test the property 'priceLists'
|
82 | 178 | */
|
83 | 179 | @Test
|
84 | 180 | public void priceListsTest() {
|
85 |
| - // TODO: test priceLists |
| 181 | + assertEquals("12345", model.getPriceLists().get(0).getId()); |
| 182 | + model.setPriceLists(Arrays.asList(new PriceList().id("54321"))); |
| 183 | + assertEquals("54321", model.getPriceLists().get(0).getId()); |
| 184 | + EntityClientPreCreateInfo a = model.priceLists( |
| 185 | + Arrays.asList(new PriceList().id("12345"))); |
| 186 | + EntityClientPreCreateInfo expected = |
| 187 | + new EntityClientPreCreateInfo() |
| 188 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 189 | + .paymentMethodsList( |
| 190 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 191 | + .paymentAccountsList( |
| 192 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 193 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 194 | + .priceLists(Arrays.asList(new PriceList().id("12345"))); |
| 195 | + assertEquals(expected, a); |
86 | 196 | }
|
87 | 197 |
|
88 | 198 | /**
|
89 | 199 | * Test the property 'limit'
|
90 | 200 | */
|
91 | 201 | @Test
|
92 | 202 | public void limitTest() {
|
93 |
| - // TODO: test limit |
| 203 | + assertEquals(null, model.getLimit()); |
| 204 | + model.setLimit(new BigDecimal("1000.50")); |
| 205 | + assertEquals(new BigDecimal("1000.50"), model.getLimit()); |
| 206 | + EntityClientPreCreateInfo a = model.limit(new BigDecimal("500.25")); |
| 207 | + EntityClientPreCreateInfo expected = |
| 208 | + new EntityClientPreCreateInfo() |
| 209 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 210 | + .paymentMethodsList( |
| 211 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 212 | + .paymentAccountsList( |
| 213 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 214 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 215 | + .priceLists(Arrays.asList(new PriceList().id("12345"))) |
| 216 | + .limit(new BigDecimal("500.25")); |
| 217 | + assertEquals(expected, a); |
94 | 218 | }
|
95 | 219 |
|
96 | 220 | /**
|
97 | 221 | * Test the property 'usage'
|
98 | 222 | */
|
99 | 223 | @Test
|
100 | 224 | public void usageTest() {
|
101 |
| - // TODO: test usage |
| 225 | + assertEquals(null, model.getUsage()); |
| 226 | + model.setUsage(new BigDecimal("200.75")); |
| 227 | + assertEquals(new BigDecimal("200.75"), model.getUsage()); |
| 228 | + EntityClientPreCreateInfo a = model.usage(new BigDecimal("150.50")); |
| 229 | + EntityClientPreCreateInfo expected = |
| 230 | + new EntityClientPreCreateInfo() |
| 231 | + .countriesList(Arrays.asList("Italia", "Marocco")) |
| 232 | + .paymentMethodsList( |
| 233 | + Arrays.asList(new PaymentMethod().id(1), new PaymentMethod().id(2))) |
| 234 | + .paymentAccountsList( |
| 235 | + Arrays.asList(new PaymentAccount().id(1), new PaymentAccount().id(2))) |
| 236 | + .vatTypesList(Arrays.asList(new VatType().id(1), new VatType().id(2))) |
| 237 | + .priceLists(Arrays.asList(new PriceList().id("12345"))) |
| 238 | + .usage(new BigDecimal("150.50")); |
| 239 | + assertEquals(expected, a); |
102 | 240 | }
|
| 241 | + |
103 | 242 |
|
104 | 243 | }
|
0 commit comments