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

Feature 192 #193

Merged
merged 6 commits into from
Sep 4, 2015
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
13 changes: 0 additions & 13 deletions FlashCards_DTO/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,5 @@
</dependencies>
<build>
<finalName>FlashCards_DTO</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package org.robbins.flashcards.dto;
package org.robbins.flashcards.dto.builder;

import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.TagDto;

public class FlashCardDtoBuilder {
private FlashCardDto flashcard = new FlashCardDto();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.robbins.flashcards.dto;
package org.robbins.flashcards.dto.builder;

import org.robbins.flashcards.dto.TagDto;

/**
* Created by justinrobbins on 2/16/15.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.robbins.flashcards.dto;
package org.robbins.flashcards.dto.builder;

import org.robbins.flashcards.dto.UserDto;

/**
* Created by justinrobbins on 2/16/15.
Expand Down
161 changes: 161 additions & 0 deletions FlashCards_Feature_Tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_App</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>FlashCards_Feature_Tests</artifactId>
<name>FlashCards_Feature_Tests</name>
<properties>
<skip.coveralls>true</skip.coveralls>
<skip.cobertura>true</skip.cobertura>
<tomcat.context.path>/api</tomcat.context.path>
</properties>
<scm>
<connection>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</connection>
<url>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</url>
<developerConnection>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</developerConnection>
</scm>
<dependencies>
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Load_Tester</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
<profiles>
<!-- default profile which is activated by default -->
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<!-- Profile for running integration tests Starts up/shuts down Tomcat
Moved this into it's own profile because otherwise Tomcat was getting started
in all cases and wasting time, even when we were skipping tests 'DskipTests=true' -->
<profile>
<id>integration-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
<configuration>
<fork>true</fork>
<path>${tomcat.context.path}</path>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- would prefer a better way to start Tomcat for both profiles (integration-test
& all-test) but for now just copying the plugin into both profiles -->
<profile>
<id>all-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war</goal>
</goals>
<configuration>
<fork>true</fork>
<webapps>
<webapp>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_WebServices</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
<contextPath>${tomcat.context.path}</contextPath>
</webapp>
</webapps>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>FlashCards_Feature_Tests</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package org.robbins.flashcards.webservices;

import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
Expand All @@ -12,7 +13,6 @@
import javax.inject.Inject;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;

@Category(IntegrationTest.class)
Expand All @@ -25,9 +25,9 @@ public class FlashCardsAppResourceIT {

@Test
public void status_FoundManifestAndVerson() {
String result = client.getStatus();
final String result = client.getStatus();

assertThat(result, is(String.class));
assertThat(result.length(), greaterThan(1));
assertThat(result.length(), Matchers.greaterThan(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
package org.robbins.flashcards.webservices;

import com.google.common.collect.Sets;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.robbins.flashcards.client.FlashcardClient;
import org.robbins.flashcards.client.GenericRestCrudFacade;
import org.robbins.flashcards.client.TagClient;
import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.FlashCardDtoBuilder;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.dto.TagDtoBuilder;
import org.robbins.flashcards.dto.builder.FlashCardDtoBuilder;
import org.robbins.flashcards.dto.builder.TagDtoBuilder;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.tests.webservices.GenericEntityRestTest;
import org.robbins.tests.IntegrationTest;
Expand All @@ -21,7 +22,6 @@
import java.util.List;
import java.util.Set;

import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.*;

@Category(IntegrationTest.class)
Expand Down Expand Up @@ -56,11 +56,11 @@ public GenericRestCrudFacade<FlashCardDto, String> getClient() {
@Test
public void testSearchByTagsIn() throws FlashcardsException
{
Set<TagDto> tags = new HashSet<>();
final Set<TagDto> tags = new HashSet<>();
tags.add(new TagDto("2", "two"));
tags.add(new TagDto("20", "twenty"));

List<FlashCardDto> searchResult = client.findByTagsIn(tags);
final List<FlashCardDto> searchResult = client.findByTagsIn(tags);

assertTrue(searchResult.size() > 0);
}
Expand All @@ -83,35 +83,35 @@ public void testUpdateEntity() throws FlashcardsException {
@Test
public void createNewFlashCard_WithNewTag() throws FlashcardsException {

FlashCardDto flashCard = new FlashCardDto();
final FlashCardDto flashCard = new FlashCardDto();
flashCard.setQuestion("Question4");
flashCard.setAnswer("Answer4");

TagDto tag = new TagDto();
final TagDto tag = new TagDto();
tag.setName("tag4");
flashCard.getTags().add(tag);

FlashCardDto newFlashCard = client.save(flashCard);
final FlashCardDto newFlashCard = client.save(flashCard);

assertThat(newFlashCard.getId().length(), greaterThan(0));
assertThat(newFlashCard.getTags().size(), greaterThan(0));
assertThat(newFlashCard.getId().length(), Matchers.greaterThan(0));
assertThat(newFlashCard.getTags().size(), Matchers.greaterThan(0));

client.delete(newFlashCard.getId());
}

@Test
public void testFindFlashcardsForTag() throws FlashcardsException {
FlashCardDto flashCard = setupFlashcard();
final FlashCardDto flashCard = setupFlashcard();

List<FlashCardDto> results = client.findFlashcardsForTag(flashCard.getTags().iterator().next().getId(), null);
final List<FlashCardDto> results = client.findFlashcardsForTag(flashCard.getTags().iterator().next().getId(), null);
assertTrue(results != null);
assertTrue(results.size() == 1);

cleanupFlashcard(flashCard);
}

private FlashCardDto setupFlashcard() throws FlashcardsException {
FlashCardDto flashCardDto = new FlashCardDtoBuilder().withQuestion("question").withAnswer("answer").build();
final FlashCardDto flashCardDto = new FlashCardDtoBuilder().withQuestion("question").withAnswer("answer").build();
flashCardDto.setTags(Sets.newHashSet(new TagDtoBuilder().withName("tag_name").build()));
return client.save(flashCardDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import org.robbins.flashcards.client.GenericRestCrudFacade;
import org.robbins.flashcards.client.TagClient;
import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.FlashCardDtoBuilder;
import org.robbins.flashcards.dto.builder.FlashCardDtoBuilder;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.dto.TagDtoBuilder;
import org.robbins.flashcards.dto.builder.TagDtoBuilder;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.tests.webservices.GenericEntityRestTest;
import org.robbins.tests.IntegrationTest;
Expand Down Expand Up @@ -81,25 +81,25 @@ public void testUpdateEntity() throws FlashcardsException {
@Test
public void testFindByCreatedBy() throws FlashcardsException {
final String userId = UUID.randomUUID().toString();
List<TagDto> results = client.findByCreatedBy(userId, null);
final List<TagDto> results = client.findByCreatedBy(userId, null);

assertTrue(results != null);
assertTrue(results.size() > 0);
}

@Test
public void testFindTagsForFlashcard() throws FlashcardsException {
FlashCardDto flashCard = setupFlashcard();
final FlashCardDto flashCard = setupFlashcard();

List<TagDto> results = client.findTagsForFlashcard(flashCard.getId(), null);
final List<TagDto> results = client.findTagsForFlashcard(flashCard.getId(), null);
assertTrue(results != null);
assertTrue(results.size() == 1);

cleanupFlashcard(flashCard);
}

private FlashCardDto setupFlashcard() throws FlashcardsException {
FlashCardDto flashCardDto = new FlashCardDtoBuilder().withQuestion("question").withAnswer("answer").build();
final FlashCardDto flashCardDto = new FlashCardDtoBuilder().withQuestion("question").withAnswer("answer").build();
flashCardDto.setTags(Sets.newHashSet(new TagDtoBuilder().withName("tag_name").build()));
return flashcardClient.save(flashCardDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.robbins.flashcards.client.GenericRestCrudFacade;
import org.robbins.flashcards.client.UserClient;
import org.robbins.flashcards.dto.UserDto;
import org.robbins.flashcards.dto.UserDtoBuilder;
import org.robbins.flashcards.dto.builder.UserDtoBuilder;
import org.robbins.flashcards.exceptions.FlashcardsException;
import org.robbins.flashcards.tests.webservices.GenericEntityRestTest;
import org.robbins.tests.IntegrationTest;
Expand Down
Loading