Commit 6bfef99d authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

add lightcouch db test

parent c943dd11
...@@ -166,11 +166,38 @@ ...@@ -166,11 +166,38 @@
<groupId>org.immutables</groupId> <groupId>org.immutables</groupId>
<artifactId>value</artifactId> <artifactId>value</artifactId>
<version>2.4.3</version> <version>2.4.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.lightcouch</groupId>
<artifactId>lightcouch</artifactId>
<version>0.1.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>org.immutables</groupId>-->
<!--<artifactId>value</artifactId>-->
<!--<version>2.4.1</version>-->
<!--</dependency>-->
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -7,6 +7,7 @@ import com.google.inject.Guice; ...@@ -7,6 +7,7 @@ import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.telephoners.krakyournet.ctf.auth.UserAuthenticator; import com.telephoners.krakyournet.ctf.auth.UserAuthenticator;
import com.telephoners.krakyournet.ctf.beans.User; import com.telephoners.krakyournet.ctf.beans.User;
import com.telephoners.krakyournet.ctf.beans.immutables.TestBean;
import com.telephoners.krakyournet.ctf.commands.PurgeDatabaseCommand; import com.telephoners.krakyournet.ctf.commands.PurgeDatabaseCommand;
import com.telephoners.krakyournet.ctf.commands.RegisterTasksCommand; import com.telephoners.krakyournet.ctf.commands.RegisterTasksCommand;
import com.telephoners.krakyournet.ctf.commands.RegisterTeamsCommand; import com.telephoners.krakyournet.ctf.commands.RegisterTeamsCommand;
...@@ -69,6 +70,9 @@ public class CTFApplication extends Application<ApplicationConfiguration> ...@@ -69,6 +70,9 @@ public class CTFApplication extends Application<ApplicationConfiguration>
@Override @Override
public void run(ApplicationConfiguration applicationConfiguration, Environment environment) throws Exception public void run(ApplicationConfiguration applicationConfiguration, Environment environment) throws Exception
{ {
TestBean asdf = TestBean.of("asdf");
injector = createInjector(applicationConfiguration); injector = createInjector(applicationConfiguration);
registerAdmins(applicationConfiguration); registerAdmins(applicationConfiguration);
......
...@@ -9,15 +9,16 @@ import java.lang.annotation.RetentionPolicy; ...@@ -9,15 +9,16 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
@Target({ElementType.PACKAGE, ElementType.TYPE}) @Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation @Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation
@Value.Style( @Value.Style(
get = {"is*", "get*"}, // Detect 'get' and 'is' prefixes in accessor methods allParameters = true,
init = "set*", // Builder initialization methods will have 'set' prefix get = {"is*", "get*"},
typeAbstract = {"Abstract*"}, // 'Abstract' prefix will be detected and trimmed init = "with*",
typeImmutable = "*", // No prefix or suffix for generated immutable type typeAbstract = {"Abstract*"},
builder = "new", // construct builder using 'new' instead of factory method typeImmutable = "*",
build = "create", // rename 'build' method on builder to 'create' depluralize = true,
visibility = Value.Style.ImplementationVisibility.PUBLIC, // Generated class will be always public defaults = @Value.Immutable(
defaults = @Value.Immutable(copy = false)) // Disable copy methods by default copy = false
)
)
public @interface Immutable {} public @interface Immutable {}
\ No newline at end of file
package com.telephoners.krakyournet.ctf; package com.telephoners.krakyournet.ctf;
import com.telephoners.krakyournet.ctf.beans.immutables.TestBean;
import org.junit.Test;
import org.lightcouch.CouchDbClient;
import java.util.List;
import java.util.stream.Stream;
public class LightCouchTest public class LightCouchTest
{ {
// CouchDbClient dbClient = new CouchDbClient(); @Test
public void test()
{
CouchDbClient dbClient = new CouchDbClient("testdb", true, "http", "127.0.0.1", 5984, "admin", "password");
Stream.of("1","2","3","4","5")
.map(TestBean::of)
.forEach(dbClient::save);
List<TestBean> all_docs = dbClient.view("_all_docs").query(TestBean.class);
int size = all_docs.size();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment