001package utility;
002
003import junit.framework.Assert;
004import org.junit.Test;
005import org.kuali.ole.docstore.OleException;
006import org.kuali.ole.docstore.utility.ISBNUtil;
007import org.kuali.ole.docstore.xstream.BaseTestCase;
008import org.slf4j.Logger;
009import org.slf4j.LoggerFactory;
010
011import java.util.ArrayList;
012import java.util.List;
013
014/**
015 * Created by IntelliJ IDEA.
016 * User: Pranitha
017 * Date: 4/6/12
018 * Time: 12:20 PM
019 * To change this template use File | Settings | File Templates.
020 */
021public class ISBNUtility_UT
022        extends BaseTestCase {
023
024    private static final Logger LOG = LoggerFactory.getLogger(ISBNUtility_UT.class);
025
026    @Test
027    public void testNormalization() throws OleException {
028        ISBNUtil isbnUtil = new ISBNUtil();
029        List<String> isbnList = new ArrayList<String>();
030        isbnList.add("0304935085847");
031        isbnList.add("0714839337 (v. 3)");
032        isbnList.add("0879514663 (set)");
033        isbnList.add("087951468X (v. 2) :");
034        isbnList.add("087951468X");
035        isbnList.add("8086098044 :");
036        isbnList.add("9781433113178 (hbk. : alk. paper)");
037        isbnList.add("1433113171 (hbk. : alk. paper)");
038        isbnList.add("978143311317X");
039        for (String isbn : isbnList) {
040            String normalizedIsbn = isbnUtil.normalizeISBN(isbn);
041
042            LOG.info(normalizedIsbn);
043            LOG.info(normalizedIsbn);
044            Assert.assertEquals(13, normalizedIsbn.length());
045        }
046
047        //
048        try {
049            isbnUtil.normalizeISBN("098789678956462137123");
050        } catch (Exception e) {
051            LOG.error("Invalid input " + e.getMessage());
052        }
053
054    }
055
056
057}