Commit 97839f153028215fd3f7f6d2de597f2804972115

Authored by bernard
0 parents

Initial import of nbp-exchangerate-api project.

  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5 + <modelVersion>4.0.0</modelVersion>
  6 +
  7 + <groupId>pl.labno.bernard.nbp.exchangerate</groupId>
  8 + <artifactId>nbp-exchangerate-api</artifactId>
  9 + <version>1.0</version>
  10 +
  11 + <dependencies>
  12 + <dependency>
  13 + <groupId>junit</groupId>
  14 + <artifactId>junit</artifactId>
  15 + <version>4.5</version>
  16 + <scope>test</scope>
  17 + </dependency>
  18 + <dependency>
  19 + <groupId>net.sourceforge.yarfraw</groupId>
  20 + <artifactId>yarfraw</artifactId>
  21 + <version>0.92</version>
  22 + </dependency>
  23 + <dependency>
  24 + <groupId>commons-codec</groupId>
  25 + <artifactId>commons-codec</artifactId>
  26 + <version>1.4</version>
  27 + </dependency>
  28 + <dependency>
  29 + <groupId>commons-logging</groupId>
  30 + <artifactId>commons-logging-api</artifactId>
  31 + <version>1.1</version>
  32 + </dependency>
  33 + <dependency>
  34 + <groupId>javax.xml.bind</groupId>
  35 + <artifactId>jaxb-api</artifactId>
  36 + <version>2.1</version>
  37 + </dependency>
  38 + <dependency>
  39 + <groupId>com.sun.xml.bind</groupId>
  40 + <artifactId>jaxb-impl</artifactId>
  41 + <version>2.1</version>
  42 + <scope>test</scope>
  43 + </dependency>
  44 + </dependencies>
  45 +
  46 + <profiles>
  47 + <profile>
  48 + <id>generate-jaxb-artifacts</id>
  49 + <build>
  50 + <plugins>
  51 + <plugin>
  52 + <groupId>org.codehaus.mojo</groupId>
  53 + <artifactId>jaxb2-maven-plugin</artifactId>
  54 + <executions>
  55 + <execution>
  56 + <goals>
  57 + <goal>xjc</goal>
  58 + </goals>
  59 + </execution>
  60 + </executions>
  61 + <configuration>
  62 + <packageName>pl.labno.bernard.nbp.exchangerate.rest.generated</packageName>
  63 + <outputDirectory>${build.sourceDirectory}</outputDirectory>
  64 + <clearOutputDir>false</clearOutputDir>
  65 + <extension>false</extension>
  66 + </configuration>
  67 + </plugin>
  68 + </plugins>
  69 + </build>
  70 + </profile>
  71 + </profiles>
  72 +
  73 + <build>
  74 + <plugins>
  75 + <plugin>
  76 + <groupId>org.apache.maven.plugins</groupId>
  77 + <artifactId>maven-surefire-plugin</artifactId>
  78 + <configuration>
  79 + <systemProperties>
  80 + <property>
  81 + <name>testOutputDirectory</name>
  82 + <value>${build.testOutputDirectory}</value>
  83 + </property>
  84 + </systemProperties>
  85 + </configuration>
  86 + </plugin>
  87 + <plugin>
  88 + <groupId>org.apache.maven.plugins</groupId>
  89 + <artifactId>maven-compiler-plugin</artifactId>
  90 + <configuration>
  91 + <source>1.5</source>
  92 + <target>1.5</target>
  93 + </configuration>
  94 + </plugin>
  95 + <plugin>
  96 + <groupId>org.apache.maven.plugins</groupId>
  97 + <artifactId>maven-source-plugin</artifactId>
  98 + <version>2.1.1</version>
  99 + <executions>
  100 + <execution>
  101 + <goals>
  102 + <goal>jar</goal>
  103 + </goals>
  104 + </execution>
  105 + </executions>
  106 + </plugin>
  107 + </plugins>
  108 + </build>
  109 +
  110 +</project>
  1 +package pl.labno.bernard.nbp.exchangerate;
  2 +
  3 +import org.apache.commons.httpclient.HttpURL;
  4 +import pl.labno.bernard.nbp.exchangerate.rest.ExchangeRateTableUnmarshaller;
  5 +import pl.labno.bernard.nbp.exchangerate.rest.generated.ExchangeRateTable;
  6 +import yarfraw.core.datamodel.ChannelFeed;
  7 +import yarfraw.core.datamodel.ItemEntry;
  8 +import yarfraw.core.datamodel.YarfrawException;
  9 +import yarfraw.utils.reader.FeedReaderUtils;
  10 +
  11 +import javax.xml.bind.JAXBException;
  12 +import java.io.IOException;
  13 +import java.util.List;
  14 +import java.util.concurrent.Executors;
  15 +
  16 +public class Updater {
  17 +
  18 + private String feedURL = "http://rss.nbp.pl/kursy/TabelaA.xml";
  19 +
  20 + public String getFeedURL() {
  21 + return feedURL;
  22 + }
  23 +
  24 + public void setFeedURL(String feedURL) {
  25 + this.feedURL = feedURL;
  26 + }
  27 +
  28 + public ExchangeRateTable getRecentExchangeTable() throws IOException, YarfrawException, JAXBException {
  29 + final List<ChannelFeed> feedList = FeedReaderUtils.readAll(Executors.newCachedThreadPool(), new HttpURL(feedURL));
  30 + if(feedList.size() < 1) {
  31 + throw new IllegalArgumentException("Read 0 feeds.");
  32 + }
  33 + final List<ItemEntry> entries = feedList.get(0).getItems();
  34 + if(entries.size() < 1) {
  35 + return null;
  36 + }
  37 + return ExchangeRateTableUnmarshaller.unmarshal(entries.get(0).getEnclosure().getUrl());
  38 + }
  39 +}
  1 +package pl.labno.bernard.nbp.exchangerate.rest;
  2 +
  3 +import org.apache.commons.io.IOUtils;
  4 +import org.apache.commons.logging.Log;
  5 +import org.apache.commons.logging.LogFactory;
  6 +import pl.labno.bernard.nbp.exchangerate.rest.generated.ExchangeRateTable;
  7 +
  8 +import javax.xml.bind.JAXBContext;
  9 +import javax.xml.bind.JAXBException;
  10 +import java.io.IOException;
  11 +import java.io.InputStream;
  12 +import java.io.InputStreamReader;
  13 +import java.io.Reader;
  14 +import java.io.StringReader;
  15 +import java.net.URL;
  16 +
  17 +public class ExchangeRateTableUnmarshaller {
  18 +
  19 + private static final Log LOG = LogFactory.getLog(ExchangeRateTableUnmarshaller.class);
  20 +
  21 + public static ExchangeRateTable unmarshal(String url) throws JAXBException, IOException {
  22 + return unmarshal(new URL(url).openStream());
  23 + }
  24 +
  25 + public static ExchangeRateTable unmarshal(InputStream stream) throws JAXBException, IOException {
  26 + return unmarshal(new InputStreamReader(stream));
  27 + }
  28 +
  29 + public static ExchangeRateTable unmarshal(Reader reader) throws JAXBException, IOException {
  30 + String content = IOUtils.toString(reader);
  31 + try {
  32 + JAXBContext jaxbContext = JAXBContext.newInstance(ExchangeRateTable.class.getPackage().getName());
  33 + return (ExchangeRateTable) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content));
  34 + } catch (JAXBException e) {
  35 + LOG.error("Cannot unmarshal input stream.\n" + content, e);
  36 + throw e;
  37 + }
  38 + }
  39 +
  40 +}
  1 +package pl.labno.bernard.nbp.exchangerate.rest;
  2 +
  3 +import java.math.BigDecimal;
  4 +
  5 +public class RateConverter {
  6 +
  7 + public static BigDecimal convert(String value) {
  8 + return new BigDecimal(value.replaceAll(",","."));
  9 + }
  10 +}
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2010.12.16 at 02:23:57 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.nbp.exchangerate.rest.generated;
  10 +
  11 +import java.math.BigDecimal;
  12 +import javax.xml.bind.annotation.adapters.XmlAdapter;
  13 +
  14 +public class Adapter1
  15 + extends XmlAdapter<String, BigDecimal>
  16 +{
  17 +
  18 +
  19 + public BigDecimal unmarshal(String value) {
  20 + return (pl.labno.bernard.nbp.exchangerate.rest.RateConverter.convert(value));
  21 + }
  22 +
  23 + public String marshal(BigDecimal value) {
  24 + if (value == null) {
  25 + return null;
  26 + }
  27 + return value.toString();
  28 + }
  29 +
  30 +}
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2010.12.16 at 02:23:57 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.nbp.exchangerate.rest.generated;
  10 +
  11 +import java.math.BigDecimal;
  12 +import java.math.BigInteger;
  13 +import javax.xml.bind.annotation.XmlAccessType;
  14 +import javax.xml.bind.annotation.XmlAccessorType;
  15 +import javax.xml.bind.annotation.XmlElement;
  16 +import javax.xml.bind.annotation.XmlSchemaType;
  17 +import javax.xml.bind.annotation.XmlType;
  18 +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  19 +
  20 +
  21 +/**
  22 + * <p>Java class for anonymous complex type.
  23 + *
  24 + * <p>The following schema fragment specifies the expected content contained within this class.
  25 + *
  26 + * <pre>
  27 + * &lt;complexType>
  28 + * &lt;complexContent>
  29 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  30 + * &lt;sequence>
  31 + * &lt;element name="nazwa_waluty" type="{http://www.w3.org/2001/XMLSchema}string"/>
  32 + * &lt;element name="przelicznik" type="{http://www.w3.org/2001/XMLSchema}integer"/>
  33 + * &lt;element name="kod_waluty" type="{http://www.w3.org/2001/XMLSchema}string"/>
  34 + * &lt;element name="kurs_sredni" type="{http://www.w3.org/2001/XMLSchema}float"/>
  35 + * &lt;/sequence>
  36 + * &lt;/restriction>
  37 + * &lt;/complexContent>
  38 + * &lt;/complexType>
  39 + * </pre>
  40 + *
  41 + *
  42 + */
  43 +@XmlAccessorType(XmlAccessType.FIELD)
  44 +@XmlType(name = "", propOrder = {
  45 + "currencyName",
  46 + "przelicznik",
  47 + "currencySymbol",
  48 + "value"
  49 +})
  50 +public class ExchangeRate {
  51 +
  52 + @XmlElement(name = "nazwa_waluty", required = true)
  53 + protected String currencyName;
  54 + @XmlElement(required = true)
  55 + protected BigInteger przelicznik;
  56 + @XmlElement(name = "kod_waluty", required = true)
  57 + protected String currencySymbol;
  58 + @XmlElement(name = "kurs_sredni", required = true, type = String.class)
  59 + @XmlJavaTypeAdapter(Adapter1 .class)
  60 + @XmlSchemaType(name = "float")
  61 + protected BigDecimal value;
  62 +
  63 + /**
  64 + * Gets the value of the currencyName property.
  65 + *
  66 + * @return
  67 + * possible object is
  68 + * {@link String }
  69 + *
  70 + */
  71 + public String getCurrencyName() {
  72 + return currencyName;
  73 + }
  74 +
  75 + /**
  76 + * Sets the value of the currencyName property.
  77 + *
  78 + * @param value
  79 + * allowed object is
  80 + * {@link String }
  81 + *
  82 + */
  83 + public void setCurrencyName(String value) {
  84 + this.currencyName = value;
  85 + }
  86 +
  87 + /**
  88 + * Gets the value of the przelicznik property.
  89 + *
  90 + * @return
  91 + * possible object is
  92 + * {@link BigInteger }
  93 + *
  94 + */
  95 + public BigInteger getPrzelicznik() {
  96 + return przelicznik;
  97 + }
  98 +
  99 + /**
  100 + * Sets the value of the przelicznik property.
  101 + *
  102 + * @param value
  103 + * allowed object is
  104 + * {@link BigInteger }
  105 + *
  106 + */
  107 + public void setPrzelicznik(BigInteger value) {
  108 + this.przelicznik = value;
  109 + }
  110 +
  111 + /**
  112 + * Gets the value of the currencySymbol property.
  113 + *
  114 + * @return
  115 + * possible object is
  116 + * {@link String }
  117 + *
  118 + */
  119 + public String getCurrencySymbol() {
  120 + return currencySymbol;
  121 + }
  122 +
  123 + /**
  124 + * Sets the value of the currencySymbol property.
  125 + *
  126 + * @param value
  127 + * allowed object is
  128 + * {@link String }
  129 + *
  130 + */
  131 + public void setCurrencySymbol(String value) {
  132 + this.currencySymbol = value;
  133 + }
  134 +
  135 + /**
  136 + * Gets the value of the value property.
  137 + *
  138 + * @return
  139 + * possible object is
  140 + * {@link String }
  141 + *
  142 + */
  143 + public BigDecimal getValue() {
  144 + return value;
  145 + }
  146 +
  147 + /**
  148 + * Sets the value of the value property.
  149 + *
  150 + * @param value
  151 + * allowed object is
  152 + * {@link String }
  153 + *
  154 + */
  155 + public void setValue(BigDecimal value) {
  156 + this.value = value;
  157 + }
  158 +
  159 +}
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2010.12.16 at 02:23:57 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.nbp.exchangerate.rest.generated;
  10 +
  11 +import javax.xml.bind.annotation.XmlAccessType;
  12 +import javax.xml.bind.annotation.XmlAccessorType;
  13 +import javax.xml.bind.annotation.XmlElement;
  14 +import javax.xml.bind.annotation.XmlRootElement;
  15 +import javax.xml.bind.annotation.XmlType;
  16 +import java.util.ArrayList;
  17 +import java.util.List;
  18 +
  19 +
  20 +/**
  21 + * <p>Java class for tabela_kursow element declaration.
  22 + *
  23 + * <p>The following schema fragment specifies the expected content contained within this class.
  24 + *
  25 + * <pre>
  26 + * &lt;element name="tabela_kursow">
  27 + * &lt;complexType>
  28 + * &lt;complexContent>
  29 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  30 + * &lt;sequence>
  31 + * &lt;element name="numer_tabeli" type="{http://www.w3.org/2001/XMLSchema}string"/>
  32 + * &lt;element name="data_publikacji" type="{http://www.w3.org/2001/XMLSchema}string"/>
  33 + * &lt;element name="pozycja" maxOccurs="unbounded" minOccurs="0">
  34 + * &lt;complexType>
  35 + * &lt;complexContent>
  36 + * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
  37 + * &lt;sequence>
  38 + * &lt;element name="nazwa_waluty" type="{http://www.w3.org/2001/XMLSchema}string"/>
  39 + * &lt;element name="przelicznik" type="{http://www.w3.org/2001/XMLSchema}integer"/>
  40 + * &lt;element name="kod_waluty" type="{http://www.w3.org/2001/XMLSchema}string"/>
  41 + * &lt;element name="kurs_sredni" type="{http://www.w3.org/2001/XMLSchema}float"/>
  42 + * &lt;/sequence>
  43 + * &lt;/restriction>
  44 + * &lt;/complexContent>
  45 + * &lt;/complexType>
  46 + * &lt;/element>
  47 + * &lt;/sequence>
  48 + * &lt;/restriction>
  49 + * &lt;/complexContent>
  50 + * &lt;/complexType>
  51 + * &lt;/element>
  52 + * </pre>
  53 + *
  54 + *
  55 + */
  56 +@XmlAccessorType(XmlAccessType.FIELD)
  57 +@XmlType(name = "", propOrder = {
  58 + "number",
  59 + "publicationDate",
  60 + "items"
  61 +})
  62 +@XmlRootElement(name = "tabela_kursow")
  63 +public class ExchangeRateTable {
  64 +
  65 + @XmlElement(name = "numer_tabeli", required = true)
  66 + protected String number;
  67 + @XmlElement(name = "data_publikacji", required = true)
  68 + protected String publicationDate;
  69 + @XmlElement(name = "pozycja")
  70 + protected List<ExchangeRate> items;
  71 +
  72 + /**
  73 + * Gets the value of the number property.
  74 + *
  75 + * @return
  76 + * possible object is
  77 + * {@link String }
  78 + *
  79 + */
  80 + public String getNumber() {
  81 + return number;
  82 + }
  83 +
  84 + /**
  85 + * Sets the value of the number property.
  86 + *
  87 + * @param value
  88 + * allowed object is
  89 + * {@link String }
  90 + *
  91 + */
  92 + public void setNumber(String value) {
  93 + this.number = value;
  94 + }
  95 +
  96 + /**
  97 + * Gets the value of the publicationDate property.
  98 + *
  99 + * @return
  100 + * possible object is
  101 + * {@link String }
  102 + *
  103 + */
  104 + public String getPublicationDate() {
  105 + return publicationDate;
  106 + }
  107 +
  108 + /**
  109 + * Sets the value of the publicationDate property.
  110 + *
  111 + * @param value
  112 + * allowed object is
  113 + * {@link String }
  114 + *
  115 + */
  116 + public void setPublicationDate(String value) {
  117 + this.publicationDate = value;
  118 + }
  119 +
  120 + /**
  121 + * Gets the value of the items property.
  122 + *
  123 + * <p>
  124 + * This accessor method returns a reference to the live list,
  125 + * not a snapshot. Therefore any modification you make to the
  126 + * returned list will be present inside the JAXB object.
  127 + * This is why there is not a <CODE>set</CODE> method for the items property.
  128 + *
  129 + * <p>
  130 + * For example, to add a new item, do as follows:
  131 + * <pre>
  132 + * getItems().add(newItem);
  133 + * </pre>
  134 + *
  135 + *
  136 + * <p>
  137 + * Objects of the following type(s) are allowed in the list
  138 + * {@link ExchangeRate }
  139 + *
  140 + *
  141 + */
  142 + public List<ExchangeRate> getItems() {
  143 + if (items == null) {
  144 + items = new ArrayList<ExchangeRate>();
  145 + }
  146 + return this.items;
  147 + }
  148 +
  149 +}
  1 +//
  2 +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
  3 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
  4 +// Any modifications to this file will be lost upon recompilation of the source schema.
  5 +// Generated on: 2010.12.16 at 02:23:57 PM GMT
  6 +//
  7 +
  8 +
  9 +package pl.labno.bernard.nbp.exchangerate.rest.generated;
  10 +
  11 +import javax.xml.bind.annotation.XmlRegistry;
  12 +
  13 +
  14 +/**
  15 + * This object contains factory methods for each
  16 + * Java content interface and Java element interface
  17 + * generated in the pl.labno.bernard.nbp.exchangerate.rest.generated package.
  18 + * <p>An ObjectFactory allows you to programatically
  19 + * construct new instances of the Java representation
  20 + * for XML content. The Java representation of XML
  21 + * content can consist of schema derived interfaces
  22 + * and classes representing the binding of schema
  23 + * type definitions, element declarations and model
  24 + * groups. Factory methods for each of these are
  25 + * provided in this class.
  26 + *
  27 + */
  28 +@XmlRegistry
  29 +public class ObjectFactory {
  30 +
  31 +
  32 + /**
  33 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.labno.bernard.nbp.exchangerate.rest.generated
  34 + *
  35 + */
  36 + public ObjectFactory() {
  37 + }
  38 +
  39 + /**
  40 + * Create an instance of {@link ExchangeRateTable }
  41 + *
  42 + */
  43 + public ExchangeRateTable createExchangeRateTable() {
  44 + return new ExchangeRateTable();
  45 + }
  46 +
  47 + /**
  48 + * Create an instance of {@link ExchangeRate }
  49 + *
  50 + */
  51 + public ExchangeRate createExchangeRate() {
  52 + return new ExchangeRate();
  53 + }
  54 +
  55 +}
  1 +<jxb:bindings version="1.0"
  2 + xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
  3 + xmlns:xs="http://www.w3.org/2001/XMLSchema">
  4 + <jxb:bindings schemaLocation="../xsd/response.xsd" node="/xs:schema">
  5 +
  6 + <jxb:globalBindings localScoping="toplevel"/>
  7 +
  8 + <jxb:bindings node="//xs:element[@name='tabela_kursow']">
  9 +
  10 + <jxb:class name="ExchangeRateTable"/>
  11 +
  12 + <jxb:bindings node=".//xs:element[@name='numer_tabeli']">
  13 + <jxb:property name="number"/>
  14 + </jxb:bindings>
  15 +
  16 + <jxb:bindings node=".//xs:element[@name='data_publikacji']">
  17 + <jxb:property name="publicationDate"/>
  18 + </jxb:bindings>
  19 +
  20 + <jxb:bindings node=".//xs:element[@name='pozycja']">
  21 + <jxb:property name="items"/>
  22 +
  23 + <jxb:bindings node=".//xs:element[@name='nazwa_waluty']">
  24 + <jxb:property name="currencyName"/>
  25 + </jxb:bindings>
  26 +
  27 + <jxb:bindings node=".//xs:element[@name='kod_waluty']">
  28 + <jxb:property name="currencySymbol"/>
  29 + </jxb:bindings>
  30 +
  31 + <jxb:bindings node=".//xs:element[@name='kurs_sredni']">
  32 + <jxb:property name="value">
  33 + <jxb:baseType>
  34 + <jxb:javaType name="java.math.BigDecimal"
  35 + parseMethod="pl.labno.bernard.nbp.exchangerate.rest.RateConverter.convert"/>
  36 + </jxb:baseType>
  37 + </jxb:property>
  38 + </jxb:bindings>
  39 + </jxb:bindings>
  40 +
  41 + <jxb:bindings node=".//xs:element[@name='pozycja']/xs:complexType">
  42 + <jxb:class name="ExchangeRate"/>
  43 + </jxb:bindings>
  44 +
  45 + </jxb:bindings>
  46 +
  47 + </jxb:bindings>
  48 +</jxb:bindings>
  1 +<?xml version="1.0"?>
  2 +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  3 + <xs:element name="tabela_kursow">
  4 + <xs:complexType>
  5 + <xs:sequence>
  6 + <xs:element name="numer_tabeli" type="xs:string"/>
  7 + <xs:element name="data_publikacji" type="xs:string"/>
  8 + <xs:element name="pozycja" minOccurs="0" maxOccurs="unbounded">
  9 + <xs:complexType>
  10 + <xs:sequence>
  11 + <xs:element name="nazwa_waluty" type="xs:string"/>
  12 + <xs:element name="przelicznik" type="xs:integer"/>
  13 + <xs:element name="kod_waluty" type="xs:string"/>
  14 + <xs:element name="kurs_sredni" type="xs:float"/>
  15 + </xs:sequence>
  16 + </xs:complexType>
  17 + </xs:element>
  18 + </xs:sequence>
  19 + </xs:complexType>
  20 + </xs:element>
  21 +</xs:schema>
  1 +package pl.labno.bernard.nbp.exchangerate;
  2 +
  3 +import org.junit.Assert;
  4 +import org.junit.Test;
  5 +import pl.labno.bernard.nbp.exchangerate.rest.generated.ExchangeRate;
  6 +import pl.labno.bernard.nbp.exchangerate.rest.generated.ExchangeRateTable;
  7 +import yarfraw.core.datamodel.YarfrawException;
  8 +
  9 +import javax.xml.bind.JAXBException;
  10 +import java.io.IOException;
  11 +
  12 +public class UpdaterTest {
  13 +
  14 + @Test
  15 + public void testGetRecentExchangeTable() throws YarfrawException, IOException, JAXBException {
  16 + final ExchangeRateTable recentExchangeTable = new Updater().getRecentExchangeTable();
  17 + Assert.assertNotNull(recentExchangeTable);
  18 + for (ExchangeRate exchangeRate : recentExchangeTable.getItems()) {
  19 + Assert.assertNotNull(exchangeRate.getCurrencyName());
  20 + Assert.assertNotNull(exchangeRate.getCurrencySymbol());
  21 + Assert.assertTrue(exchangeRate.getValue().doubleValue() != 0d);
  22 + }
  23 + }
  24 +}
Please register or login to post a comment