Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closes #81 #213

Merged
merged 13 commits into from
Jan 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
*/
package org.robbins.flashcards.exceptions;

public class FlashcardsException extends RuntimeException
public class FlashCardsException extends RuntimeException
{
public FlashcardsException(final String message) {
public FlashCardsException(final String message) {
super(message);
}

public FlashcardsException(final String message, final Throwable cause) {
public FlashCardsException(final String message, final Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
package org.robbins.flashcards.exceptions;

public class RepositoryException extends FlashcardsException
public class RepositoryException extends FlashCardsException
{
public RepositoryException(final String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

package org.robbins.flashcards.exceptions;

public class ServiceException extends FlashcardsException {
public class ServiceException extends FlashCardsException
{

public ServiceException(final String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@

import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
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, Long>
public interface FlashCardFacade extends GenericCrudFacade<FlashCardDto, Long>
{
List<FlashCardDto> findByTagsIn(final Set<TagDto> tags) throws FlashcardsException;
List<FlashCardDto> findByTagsIn(final Set<TagDto> tags) throws FlashCardsException;
List<FlashCardDto> findByTagsIn(final Set<TagDto> tags, final PageRequest page)
throws FlashcardsException;
List<FlashCardDto> findByQuestionLike(final String question) throws FlashcardsException;
throws FlashCardsException;
List<FlashCardDto> findByQuestionLike(final String question) throws FlashCardsException;
List<FlashCardDto> findByQuestionLike(final String question, final PageRequest page)
throws FlashcardsException;
FlashCardDto findByQuestion(final String question) throws FlashcardsException;
List<FlashCardDto> findFlashcardsForTag(final Long tagId, final Set<String> fields) throws FlashcardsException;
throws FlashCardsException;
FlashCardDto findByQuestion(final String question) throws FlashCardsException;
List<FlashCardDto> findFlashCardsForTag(final Long tagId, final Set<String> fields) throws FlashCardsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
package org.robbins.flashcards.facade;

import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.exceptions.RepositoryException;
import org.robbins.flashcards.exceptions.FlashCardsException;
import org.robbins.flashcards.facade.base.GenericCrudFacade;

import java.util.List;
import java.util.Set;

public interface TagFacade extends GenericCrudFacade<TagDto, Long> {

TagDto findByName(final String name) throws FlashcardsException;
List<TagDto> findTagsForFlashcard(final Long flashcardId, final Set<String> fields) throws FlashcardsException;
TagDto findByName(final String name) throws FlashCardsException;
List<TagDto> findTagsForFlashCard(final Long flashCardId, final Set<String> fields) throws FlashCardsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
package org.robbins.flashcards.facade;

import org.robbins.flashcards.dto.UserDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.exceptions.FlashCardsException;
import org.robbins.flashcards.facade.base.GenericCrudFacade;

public interface UserFacade extends GenericCrudFacade<UserDto, Long> {

UserDto findUserByOpenid(String openid) throws FlashcardsException;
UserDto findUserByOpenid(String openid) throws FlashCardsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package org.robbins.flashcards.facade.base;

import org.robbins.flashcards.dto.BatchLoadingReceiptDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.exceptions.FlashCardsException;
import org.springframework.data.domain.Pageable;

import java.util.List;
Expand All @@ -11,14 +11,14 @@

public interface GenericCrudFacade<D, ID> {

List<D> list() throws FlashcardsException;
List<D> list(final Optional<Pageable> page) throws FlashcardsException;
List<D> list(final Optional<Pageable> page, Set<String> fields) throws FlashcardsException;
List<D> list() throws FlashCardsException;
List<D> list(final Optional<Pageable> page) throws FlashCardsException;
List<D> list(final Optional<Pageable> page, Set<String> fields) throws FlashCardsException;
Long count();
D findOne(final ID id) throws FlashcardsException;
D findOne(final ID id, Set<String> fields) throws FlashcardsException;
D save(final D entity) throws FlashcardsException;
BatchLoadingReceiptDto save(final List<D> dtos) throws FlashcardsException;
D findOne(final ID id) throws FlashCardsException;
D findOne(final ID id, Set<String> fields) throws FlashCardsException;
D save(final D entity) throws FlashCardsException;
BatchLoadingReceiptDto save(final List<D> dtos) throws FlashCardsException;
void delete(final ID id);
List<D> findByCreatedBy(final ID userId, final Set<String> fields) throws FlashcardsException;
List<D> findByCreatedBy(final ID userId, final Set<String> fields) throws FlashCardsException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import org.robbins.flashcards.dto.AbstractPersistableDto;
import org.robbins.flashcards.dto.BatchLoadingReceiptDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.exceptions.FlashCardsException;
import org.robbins.flashcards.exceptions.ServiceException;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -165,7 +165,8 @@ public E save(final E entity) throws ServiceException {
}

@Override
public BatchLoadingReceiptDto save(List<E> entities) throws FlashcardsException {
public BatchLoadingReceiptDto save(List<E> entities) throws FlashCardsException
{
// set the Authentication header
@SuppressWarnings({ "unchecked", "rawtypes" })
final HttpEntity httpEntity = new HttpEntity(entities, getAuthHeaders());
Expand Down Expand Up @@ -225,7 +226,8 @@ public void put(final E entity) {
}

@Override
public List<E> findByCreatedBy(final ID userId, final Set<String> fields) throws FlashcardsException {
public List<E> findByCreatedBy(final ID userId, final Set<String> fields) throws FlashCardsException
{
Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("userId", String.valueOf(userId));
return Arrays.asList(searchEntities(getEntityListUrl(), uriVariables, getClazzArray()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.robbins.flashcards.client;

import org.robbins.flashcards.client.util.ResourceUrls;
import org.robbins.flashcards.dto.AbstractPersistableDto;
import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.exceptions.FlashCardsException;
import org.robbins.flashcards.exceptions.ServiceException;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Component;
Expand All @@ -14,7 +13,8 @@


@Component("flashcardClient")
public class DefaultFlashcardClient extends AbstractCrudClient<FlashCardDto, Long> implements FlashcardClient {
public class DefaultFlashCardClient extends AbstractCrudClient<FlashCardDto, Long> implements FlashCardClient
{
@Override
public String getEntityListUrl() {
return getServerAddress() + ResourceUrls.flashCards;
Expand Down Expand Up @@ -122,9 +122,10 @@ public FlashCardDto findByQuestion(final String question) throws ServiceExceptio
}

@Override
public List<FlashCardDto> findFlashcardsForTag(Long tagId, Set<String> fields) throws FlashcardsException {
public List<FlashCardDto> findFlashCardsForTag(Long tagId, Set<String> fields) throws FlashCardsException
{
final Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("tagId", String.valueOf(tagId));
return Arrays.asList(searchEntities(getServerAddress() + ResourceUrls.flashcardsForTag, uriVariables, FlashCardDto[].class));
return Arrays.asList(searchEntities(getServerAddress() + ResourceUrls.flashCardsForTag, uriVariables, FlashCardDto[].class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import org.springframework.stereotype.Component;

@Component
public class DefaultFlashcardsAppClient extends AbstractClient implements FlashcardsAppClient {
public class DefaultFlashCardsAppClient extends AbstractClient implements FlashCardsAppClient
{

private String getStatusUrl() {
return getServerAddress() + ResourceUrls.status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public TagDto findByName(final String name) throws ServiceException {
}

@Override
public List<TagDto> findTagsForFlashcard(final Long flashcardId, final Set<String> fields) {
public List<TagDto> findTagsForFlashCard(final Long flashCardId, final Set<String> fields) {
Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("flashcardId", String.valueOf(flashcardId));
return Arrays.asList(searchEntities(getServerAddress() + ResourceUrls.tagsForFlashcard, uriVariables, TagDto[].class));
uriVariables.put("flashcardId", String.valueOf(flashCardId));
return Arrays.asList(searchEntities(getServerAddress() + ResourceUrls.tagsForFlashCard, uriVariables, TagDto[].class));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.robbins.flashcards.client;

import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.facade.FlashcardFacade;
import org.robbins.flashcards.facade.FlashCardFacade;

public interface FlashcardClient extends FlashcardFacade, GenericRestCrudFacade<FlashCardDto, Long> {
public interface FlashCardClient extends FlashCardFacade, GenericRestCrudFacade<FlashCardDto, Long> {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.robbins.flashcards.client;

public interface FlashcardsAppClient {
public interface FlashCardsAppClient
{
String getStatus();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ private ResourceUrls() {

public static final String status = "/v1/status/";

public static final String tagsForFlashcard = "v1/flashcards/{flashcardId}/tags";
public static final String tagsForFlashCard = "v1/flashcards/{flashcardId}/tags";

public static final String flashcardsForTag = "v1/tags/{tagId}/flashcards";
public static final String flashCardsForTag = "v1/tags/{tagId}/flashcards";

public static final String batch = "batch/";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TagDto extends AbstractAuditableDto implements Serializable {

private String name;

private Set<FlashCardDto> flashcards = new HashSet<FlashCardDto>(0);
private Set<FlashCardDto> flashCards = new HashSet<>(0);

public TagDto() {
}
Expand All @@ -44,12 +44,12 @@ public void setName(final String name) {
this.name = name;
}

public Set<FlashCardDto> getFlashcards() {
return flashcards;
public Set<FlashCardDto> getFlashCards() {
return flashCards;
}

public void setFlashcards(final Set<FlashCardDto> flashcards) {
this.flashcards = flashcards;
public void setFlashCards(final Set<FlashCardDto> flashCardId) {
this.flashCards = flashCardId;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
import org.robbins.flashcards.dto.TagDto;

public class FlashCardDtoBuilder {
private FlashCardDto flashcard = new FlashCardDto();
private FlashCardDto flashCardId = new FlashCardDto();

public FlashCardDtoBuilder() {}

public FlashCardDtoBuilder withId(final Long id) {
flashcard.setId(id);
flashCardId.setId(id);
return this;
}

public FlashCardDtoBuilder withQuestion(final String question) {
flashcard.setQuestion(question);
flashCardId.setQuestion(question);
return this;
}

public FlashCardDtoBuilder withAnswer(final String answer) {
flashcard.setAnswer(answer);
flashCardId.setAnswer(answer);
return this;
}

public FlashCardDtoBuilder withTag(final TagDto tag) {
flashcard.getTags().add(tag);
flashCardId.getTags().add(tag);
return this;
}

public FlashCardDto build() {
return flashcard;
return flashCardId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.robbins.flashcards.client.FlashcardsAppClient;
import org.robbins.flashcards.client.FlashCardsAppClient;
import org.robbins.tests.IntegrationTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -21,7 +21,7 @@
public class FlashCardsAppResourceIT {

@Inject
private FlashcardsAppClient client;
private FlashCardsAppClient client;

@Test
public void status_FoundManifestAndVerson() {
Expand Down
Loading