1858bd4ecf589246d0af928ba5ae2ec7c3830084
[zxing.git] / core / test / src / com / google / zxing / client / result / ExpandedProductParsedResultTestCase.java
1 /*
2  * Copyright (C) 2010 ZXing authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*
18  * These authors would like to acknowledge the Spanish Ministry of Industry,
19  * Tourism and Trade, for the support in the project TSI020301-2008-2
20  * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
21  * Mobile Dynamic Environments", led by Treelogic
22  * ( http://www.treelogic.com/ ):
23  *
24  *   http://www.piramidepse.com/
25  */
26
27 package com.google.zxing.client.result;
28
29 import java.util.Hashtable;
30
31 import junit.framework.TestCase;
32
33 import com.google.zxing.BarcodeFormat;
34 import com.google.zxing.Result;
35
36 /**
37  * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
38  * @author Agustín Delgado, Servinform, S.A.
39  */
40 public final class ExpandedProductParsedResultTestCase extends TestCase {
41
42   public void test_RSSExpanded() {
43     String text = "(01)66546(13)001205(3932)4455(3102)6544(123)544654";
44     String productID = "66546";
45     String sscc = "-";
46     String lotNumber = "-";
47     String productionDate = "-";
48     String packagingDate = "001205";
49     String bestBeforeDate = "-";
50     String expirationDate = "-";
51     String weight = "6544";
52     String weightType = "KG";
53     String weightIncrement = "2";
54     String price = "5";
55     String priceIncrement = "2";
56     String priceCurrency = "445";
57     Hashtable uncommonAIs = new Hashtable();
58     uncommonAIs.put("123", "544654");
59
60     Result result = new Result(text, null, null, BarcodeFormat.RSS_EXPANDED);
61     ExpandedProductParsedResult o = ExpandedProductResultParser
62         .parse(result);
63     assertEquals(productID, o.getProductID());
64     assertEquals(sscc, o.getSscc());
65     assertEquals(lotNumber, o.getLotNumber());
66     assertEquals(productionDate, o.getProductionDate());
67     assertEquals(packagingDate, o.getPackagingDate());
68     assertEquals(bestBeforeDate, o.getBestBeforeDate());
69     assertEquals(expirationDate, o.getExpirationDate());
70     assertEquals(weight, o.getWeight());
71     assertEquals(weightType, o.getWeightType());
72     assertEquals(weightIncrement, o.getWeightIncrement());
73     assertEquals(price, o.getPrice());
74     assertEquals(priceIncrement, o.getPriceIncrement());
75     assertEquals(priceCurrency, o.getPriceCurrency());
76     assertEquals(uncommonAIs, o.getUncommonAIs());
77   }
78 }