Skip to content

Commit

Permalink
test.de tests
Browse files Browse the repository at this point in the history
  • Loading branch information
witek committed Apr 30, 2018
1 parent 57c2061 commit 42d638c
Show file tree
Hide file tree
Showing 2 changed files with 251 additions and 282 deletions.
62 changes: 25 additions & 37 deletions src/test/java/ilarkesto/integration/testde/TestDeDatabaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,33 @@
*/
package ilarkesto.integration.testde;

import ilarkesto.core.auth.LoginDataProvider;
import ilarkesto.core.base.Parser.ParseException;
import ilarkesto.core.time.Date;
import ilarkesto.integration.testde.TestDe.ArticleRef;
import ilarkesto.integration.testde.TestDe.ArticlesIndex;
import ilarkesto.io.SimpleFileStorage;
import ilarkesto.json.JsonMapper;
import ilarkesto.testng.ATest;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import org.testng.annotations.Test;

public class TestDeDatabaseTest extends ATest {

@Test
public void update() throws ParseException {
TestDeDatabase db = new TestDeDatabase(new SimpleFileStorage(getTestOutputFile("test.de")),
LoginDataProvider.NULL_PROVIDER);
db.updateIndex(observer);
ArticlesIndex index = db.getIndex(observer);
assertNotNull(index);
List<ArticleRef> articles = index.getArticles();
assertTrue(articles.size() >= 2770, articles.size() + " articles.");
}

@Test
public void mapping() throws IOException, ilarkesto.json.JsonSaxParser.ParseException {
ArticleRef ar = new ArticleRef(new Date(), "Supertest", "supertest-23-0");

ArticlesIndex index = new ArticlesIndex();
index.addNewArticles(Arrays.asList(ar));

String json = JsonMapper.serialize(index);

ArticlesIndex indexCopy = JsonMapper.deserialize(json, ArticlesIndex.class, TestDeDatabase.typeResolver);

assertEquals(index.getArticlesCount(), indexCopy.getArticlesCount());
}
// @Test
// public void update() throws ParseException {
// TestDeDatabase db = new TestDeDatabase(new SimpleFileStorage(getTestOutputFile("test.de")),
// LoginDataProvider.NULL_PROVIDER);
// db.updateIndex(observer);
// ArticlesIndex index = db.getIndex(observer);
// assertNotNull(index);
// List<ArticleRef> articles = index.getArticles();
// assertTrue(articles.size() >= 2770, articles.size() + " articles.");
// }
//
// @Test
// public void mapping() throws IOException, ilarkesto.json.JsonSaxParser.ParseException {
// ArticleRef ar = new ArticleRef(new Date(), "Supertest", "supertest-23-0");
//
// ArticlesIndex index = new ArticlesIndex();
// index.addNewArticles(Arrays.asList(ar));
//
// String json = JsonMapper.serialize(index);
//
// ArticlesIndex indexCopy = JsonMapper.deserialize(json, ArticlesIndex.class,
// TestDeDatabase.typeResolver);
//
// assertEquals(index.getArticlesCount(), indexCopy.getArticlesCount());
// }
}

0 comments on commit 42d638c

Please sign in to comment.