Skip to content

Commit

Permalink
refs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
rmpestano committed Aug 21, 2015
1 parent d6e995b commit 8de7e21
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
28 changes: 21 additions & 7 deletions core/src/test/java/com/github/dbunit/rules/DBUnitRulesIt.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.github.dbunit.rules;

import com.github.dbunit.rules.api.dataset.DataSet;
import com.github.dbunit.rules.model.Follower;
import com.github.dbunit.rules.model.User;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import com.github.dbunit.rules.api.dataset.DataSet;
import com.github.dbunit.rules.model.Follower;
import com.github.dbunit.rules.model.User;

/**
* Created by pestano on 23/07/15.
Expand Down Expand Up @@ -113,4 +114,17 @@ public void shouldLoadUsersFromXmlDataset() {
assertThat(user.getFollowers()).contains(expectedFollower);
}

@Test
@DataSet(value = "yml/user.yml, yml/tweet.yml, yml/follower.yml", executeStatementsBefore = {"DELETE FROM FOLLOWER","DELETE FROM TWEET","DELETE FROM USER"})
public void shouldLoadDataFromMultipleDataSets(){
User user = (User) emProvider.em().createQuery("select u from User u join fetch u.tweets join fetch u.followers left join fetch u.followers where u.id = 1").getSingleResult();
assertThat(user).isNotNull();
assertThat(user.getId()).isEqualTo(1);
assertThat(user.getTweets()).hasSize(1);
assertEquals("dbunit rules again",user.getTweets().get(0).getContent());
assertThat(user.getFollowers()).isNotNull().hasSize(1);
Follower expectedFollower = new Follower(2,1);
assertThat(user.getFollowers()).contains(expectedFollower);
}

}
4 changes: 4 additions & 0 deletions core/src/test/resources/datasets/yml/follower.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
follower:
- id: 1
user_id: 1
follower_id: 2
4 changes: 4 additions & 0 deletions core/src/test/resources/datasets/yml/tweet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tweet:
- id: abcdef12345
content: "dbunit rules again!"
user_id: 1
3 changes: 3 additions & 0 deletions core/src/test/resources/datasets/yml/user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
user:
- id: 99
name: "@realpestano"

0 comments on commit 8de7e21

Please sign in to comment.