-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3587877
commit c904b19
Showing
40 changed files
with
474 additions
and
147 deletions.
There are no files selected for viewing
22 changes: 9 additions & 13 deletions
22
FlashCards_API/src/main/java/org/robbins/flashcards/facade/FlashcardFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
|
||
package org.robbins.flashcards.facade; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.robbins.flashcards.dto.FlashCardDto; | ||
import org.robbins.flashcards.dto.TagDto; | ||
import org.robbins.flashcards.exceptions.FlashcardsException; | ||
import org.robbins.flashcards.facade.base.GenericCrudFacade; | ||
import org.springframework.data.domain.PageRequest; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public interface FlashcardFacade extends GenericCrudFacade<FlashCardDto> | ||
{ | ||
|
||
List<FlashCardDto> findByTagsIn(Set<TagDto> tags) throws FlashcardsException; | ||
|
||
List<FlashCardDto> findByTagsIn(Set<TagDto> tags, PageRequest page) | ||
List<FlashCardDto> findByTagsIn(final Set<TagDto> tags) throws FlashcardsException; | ||
List<FlashCardDto> findByTagsIn(final Set<TagDto> tags, final PageRequest page) | ||
throws FlashcardsException; | ||
|
||
List<FlashCardDto> findByQuestionLike(String question) throws FlashcardsException; | ||
|
||
List<FlashCardDto> findByQuestionLike(String question, PageRequest page) | ||
List<FlashCardDto> findByQuestionLike(final String question) throws FlashcardsException; | ||
List<FlashCardDto> findByQuestionLike(final String question, final PageRequest page) | ||
throws FlashcardsException; | ||
|
||
FlashCardDto findByQuestion(String question) throws FlashcardsException; | ||
FlashCardDto findByQuestion(final String question) throws FlashcardsException; | ||
List<FlashCardDto> findFlashcardsForTag(final Long tagId, final Set<String> fields) throws FlashcardsException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...s_Repository_Jpa/src/test/java/org/robbins/flashcards/repository/jpa/TagRepositoryIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
package org.robbins.flashcards.repository.jpa; | ||
|
||
import com.github.springtestdbunit.annotation.DatabaseSetup; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.robbins.flashcards.model.Tag; | ||
import org.robbins.flashcards.repository.TagRepository; | ||
import org.robbins.tests.BaseIntegrationTest; | ||
import org.robbins.tests.IntegrationTest; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import javax.inject.Inject; | ||
import java.util.List; | ||
|
||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.junit.Assert.assertThat; | ||
|
||
@ContextConfiguration("classpath:test-applicationContext-repository-jpa.xml") | ||
@DatabaseSetup("classpath:test-flashCardsAppRepository.xml") | ||
@Category(IntegrationTest.class) | ||
public class TagRepositoryIT extends BaseIntegrationTest { | ||
|
||
@Inject | ||
private TagRepository tagRepository; | ||
|
||
@Test | ||
public void findByName_noSuchTag() { | ||
Tag tag = tagRepository.findByName("DOES_NOT_EXIST"); | ||
assertThat(tag, is(nullValue())); | ||
} | ||
|
||
@Test | ||
public void findByName() { | ||
Tag tag = tagRepository.findByName("tag1"); | ||
assertThat(tag, is(instanceOf(Tag.class))); | ||
} | ||
|
||
@Test | ||
public void findByFlashCardsId() { | ||
List<Tag> tags = tagRepository.findByFlashcards_Id(1L); | ||
assertThat(tags.size(), is(1)); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...y/FlashCards_Repository_Jpa/src/test/resources/test-applicationContext-repository-jpa.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> | ||
|
||
<import resource="classpath:applicationContext-repository-jpa-commons.xml" /> | ||
<import resource="classpath:test-infrastructure.xml" /> | ||
|
||
<bean id="auditorAware" class="org.robbins.flashcards.auditing.AuditingAwareUser" /> | ||
|
||
<context:component-scan base-package="org.robbins.flashcards.repository" /> | ||
|
||
</beans> |
10 changes: 10 additions & 0 deletions
10
..._Repository/FlashCards_Repository_Jpa/src/test/resources/test-flashCardsAppRepository.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<dataset> | ||
<user UserId="1" EMAIL="email@test.org" LastLoginDate="2013-01-01" | ||
OPENID="my-open-id" CreatedUserId="1" /> | ||
<tag TagId="1" TagName="tag1" CreatedUserId="1" /> | ||
<tag TagId="2" TagName="tag2" CreatedUserId="1" /> | ||
<flashcard FlashCardId="1" Question="question1" Answer="answer1" | ||
CreatedUserId="1" /> | ||
<flashcard_tag FlashCardId="1" TagId="1" /> | ||
</dataset> |
36 changes: 36 additions & 0 deletions
36
FlashCards_Repository/FlashCards_Repository_Jpa/src/test/resources/test-infrastructure.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:jdbc="http://www.springframework.org/schema/jdbc" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | ||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd"> | ||
|
||
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" | ||
destroy-method="close"> | ||
<property name="driverClass" value="org.h2.Driver" /> | ||
<property name="jdbcUrl" value="jdbc:h2:mem:flashcardsDb;MVCC=true" /> | ||
</bean> | ||
|
||
<bean id="jpaVendorAdapter" | ||
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> | ||
<property name="showSql" value="true" /> | ||
<property name="generateDdl" value="true" /> | ||
<property name="database" value="H2" /> | ||
<property name="databasePlatform" value="org.hibernate.dialect.H2Dialect" /> | ||
</bean> | ||
|
||
<bean id="entityManagerFactory" | ||
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> | ||
<property name="dataSource" ref="dataSource" /> | ||
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" /> | ||
</bean> | ||
|
||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> | ||
<property name="entityManagerFactory" ref="entityManagerFactory" /> | ||
</bean> | ||
|
||
<bean | ||
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.