Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Commit

Permalink
first updatertests
Browse files Browse the repository at this point in the history
  • Loading branch information
Waldemar Lammert committed Jan 23, 2020
1 parent 9c4f7dd commit 3f29912
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/eu/dev089/components/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public class Updater extends TimerTask {
private OkHttpClient client;

public Updater() {
this.creator = new RequestCreator(System.getenv().get("BK_TOKEN"));
this(System.getenv().get("BK_TOKEN"));
}

Updater(String token) {
this.creator = new RequestCreator(token);
}

@Override
Expand Down Expand Up @@ -71,7 +75,7 @@ public void run() {
client.connectionPool().evictAll();
}

private void updateProducts(List<Product> updatableProducts) {
void updateProducts(List<Product> updatableProducts) {
if (!updatableProducts.isEmpty()) {
for (var product : updatableProducts) {
var request = creator.updateProductRequest(product);
Expand All @@ -91,7 +95,7 @@ private void updateProducts(List<Product> updatableProducts) {
}
}

private Optional<Product> processSku(String sku) {
Optional<Product> processSku(String sku) {
var jsonObject = readResponse(creator.getProduktDataForSku(sku));
if (jsonObject.isPresent()) {
var product = Product.builder()
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/eu/dev089/components/UpdaterTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package eu.dev089.components;

import eu.dev089.model.Product;
import java.util.Optional;
import org.junit.jupiter.api.Test;

class UpdaterTest {

private Updater updater = new Updater("MYTOKEN");

@Test
void readsResponse() {
Optional<Product> mysku = updater.processSku("mysku");
}
}

0 comments on commit 3f29912

Please sign in to comment.