Updated Main demo method

This commit is contained in:
Marvin Scham
2023-06-06 02:13:43 +02:00
parent c5bfdd83ea
commit cccb466bd2

View File

@@ -5,8 +5,8 @@ import javax.naming.ConfigurationException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import de.rwu.easydrop.api.client.AmazonProductDataSource; import de.rwu.easydrop.api.client.DataSourceFactory;
import de.rwu.easydrop.api.client.EbayItemDataSource; import de.rwu.easydrop.service.retriever.ProductRetriever;
import de.rwu.easydrop.util.Config; import de.rwu.easydrop.util.Config;
/** /**
@@ -34,25 +34,12 @@ public final class Main {
*/ */
public static void main(final String[] args) throws ConfigurationException { public static void main(final String[] args) throws ConfigurationException {
Config config = Config.getInstance(); Config config = Config.getInstance();
config.loadConfig(); DataSourceFactory dataSourceFactory = new DataSourceFactory(config);
ProductRetriever retriever = new ProductRetriever(dataSourceFactory);
String amznBaseUrl = config.getProperty("AMAZON_API_URL"); String amznProduct = retriever.getProductFromAmazon("B096Y2TYKV").toString();
String amznApiKey = config.getProperty("AMAZON_API_KEY"); LOGGER.info(amznProduct);
String ebayBaseUrl = config.getProperty("EBAY_API_URL"); String ebayProduct = retriever.getProductFromEbay("Gigabyte GeForce RTX 3060").toString();
String ebayApiKey = config.getProperty("EBAY_API_KEY"); LOGGER.info(ebayProduct);
String amznTestProduct = null;
String ebayTestProduct = null;
AmazonProductDataSource amznSrc = new AmazonProductDataSource(amznBaseUrl, amznApiKey);
EbayItemDataSource ebaySrc = new EbayItemDataSource(ebayBaseUrl, ebayApiKey);
try {
amznTestProduct = amznSrc.getProductDTOById("B096Y2TYKV").toString();
LOGGER.info(amznTestProduct);
ebayTestProduct = ebaySrc.getProductDTOById("Gigabyte GeForce RTX 3060").toString();
LOGGER.info(ebayTestProduct);
} catch (IllegalArgumentException e) {
LOGGER.error("Something went wrong :(", e);
}
} }
} }