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

add lightcouch db test

parent c943dd11
......@@ -166,11 +166,38 @@
<groupId>org.immutables</groupId>
<artifactId>value</artifactId>
<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>-->
<!--<groupId>org.immutables</groupId>-->
<!--<artifactId>value</artifactId>-->
<!--<version>2.4.1</version>-->
<!--</dependency>-->
</dependencies>
</project>
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.telephoners.krakyournet.ctf.auth.UserAuthenticator;
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.RegisterTasksCommand;
import com.telephoners.krakyournet.ctf.commands.RegisterTeamsCommand;
......@@ -69,6 +70,9 @@ public class CTFApplication extends Application<ApplicationConfiguration>
@Override
public void run(ApplicationConfiguration applicationConfiguration, Environment environment) throws Exception
{
TestBean asdf = TestBean.of("asdf");
injector = createInjector(applicationConfiguration);
registerAdmins(applicationConfiguration);
......
......@@ -9,15 +9,16 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.PACKAGE, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS) // Make it class retention for incremental compilation
@Value.Style(
get = {"is*", "get*"}, // Detect 'get' and 'is' prefixes in accessor methods
init = "set*", // Builder initialization methods will have 'set' prefix
typeAbstract = {"Abstract*"}, // 'Abstract' prefix will be detected and trimmed
typeImmutable = "*", // No prefix or suffix for generated immutable type
builder = "new", // construct builder using 'new' instead of factory method
build = "create", // rename 'build' method on builder to 'create'
visibility = Value.Style.ImplementationVisibility.PUBLIC, // Generated class will be always public
defaults = @Value.Immutable(copy = false)) // Disable copy methods by default
allParameters = true,
get = {"is*", "get*"},
init = "with*",
typeAbstract = {"Abstract*"},
typeImmutable = "*",
depluralize = true,
defaults = @Value.Immutable(
copy = false
)
)
public @interface Immutable {}
\ No newline at end of file
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
{
// 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