Skip to content
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: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ cache:
directories:
- "$HOME/.m2/repository"

install: /bin/true
install:
- rm ~/.m2/settings.xml
- if [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_BRANCH = master ]; then GOAL=deploy; else GOAL=install; fi

script:
- mvn -q -B -U -Pstaging,javadoc,compatibility install jacoco:report
- mvn -q -B coveralls:report -DrepoToken=$COVERALLS_TOKEN
script: mvn -q -U -T 2 -Pcompatibility,snapshots,javadoc $GOAL jacoco:report

after_success: mvn -q coveralls:report -DrepoToken=$COVERALLS_TOKEN

after_success:
- echo "<settings><servers><server><id>sonatype-nexus-snapshots</id><username>\${env.SONATYPE_USER}</username><password>\${env.SONATYPE_PASS}</password></server></servers></settings>" > ~/settings.xml
- "[[ $TRAVIS_PULL_REQUEST == \"false\" && $TRAVIS_BRANCH == \"master\" ]] && mvn -q deploy --settings ~/settings.xml -DskipTests=true -Pjavadoc"
49 changes: 49 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--

Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

-->
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.seedstack.addons</groupId>
<artifactId>mongodb</artifactId>
<version>1.0.0-M1-SNAPSHOT</version>
</parent>

<artifactId>mongodb-core</artifactId>

<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>${mongodb.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-async</artifactId>
<version>${mongodb.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-testing</artifactId>
<version>${seed.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#
# Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
#
# This file is part of SeedStack, An enterprise-oriented full development stack.
# Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0"?>
<!--

Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.

This file is part of SeedStack, An enterprise-oriented full development stack.
Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#
# Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
#
# This file is part of SeedStack, An enterprise-oriented full development stack.
# Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0"?>
<!--

Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.

This file is part of SeedStack, An enterprise-oriented full development stack.
Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down
65 changes: 65 additions & 0 deletions morphia/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--

Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

-->
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.seedstack.addons</groupId>
<artifactId>mongodb</artifactId>
<version>1.0.0-M1-SNAPSHOT</version>
</parent>

<artifactId>mongodb-morphia</artifactId>

<dependencies>
<dependency>
<groupId>org.seedstack.addons</groupId>
<artifactId>mongodb-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.seedstack.business</groupId>
<artifactId>business-specs</artifactId>
<version>${business.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>${morphia.version}</version>
</dependency>
<dependency>
<groupId>org.seedstack.seed</groupId>
<artifactId>seed-testing</artifactId>
<version>${seed.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seedstack.business</groupId>
<artifactId>business-core</artifactId>
<version>${business.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-async</artifactId>
<version>${mongodb.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* Copyright (c) 2013-2015, The SeedStack authors <http://seedstack.org>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.seed.business.mongodb;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.seedstack.business.api.domain.Repository;
import org.seedstack.seed.core.api.SeedException;
import org.seedstack.seed.it.AbstractSeedIT;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy1;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy2;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy3;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy4;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy5;
import org.seedstack.seed.mongodb.domain.dummyobject.Dummy6;
import org.seedstack.seed.mongodb.domain.user.Address;
import org.seedstack.seed.mongodb.domain.user.User;
import org.seedstack.seed.persistence.mongodb.api.Morphia;
import org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes;

import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.ProvisionException;
import com.google.inject.TypeLiteral;
import com.google.inject.util.Types;

public class MongodbRepositoryIT extends AbstractSeedIT {

@Inject
@Morphia
private Repository<User, Long> userRepository;

@Inject
private Injector injector;

@Test
public void repository_injection_test_no_client_for_aggregate() {
try {

injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy1.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT).getMessage());
}
}

@Test
public void repository_injection_test_no_dbName_for_aggregate() {
try {
injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy2.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_DATABASE).getMessage());
}
}

@Test
public void repository_injection_test_no_mongoDb_client() {
try {
injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy3.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT).getMessage());
}
}

@Test
public void repository_injection_test_no_mongoDb_database() {
try {
injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy4.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATABASE_NAME).getMessage());
}
}

@Test
public void repository_injection_test_no_mongodb_for_aggregate() {
try {
injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy5.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CONFIGURATION).getMessage());
}
}

@Test
public void repository_injection_async_client() {
try {
injector.getInstance(
Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy6.class, Long.class)),
Morphia.class));
} catch (ProvisionException e) {
Assertions.assertThat(e.getCause().getMessage())
.isEqualTo(SeedException.createNew(MorphiaErrorCodes.ERROR_ASYNC_CLIENT).getMessage());
}
}


@Test
public void mongodb_repository_test() {
Assertions.assertThat(userRepository).isNotNull();
User user1 = getUser(1L, "N°", "1");
userRepository.persist(user1);
User user2 = userRepository.load(user1.getEntityId());
Assertions.assertThat(user1.getId()).isEqualTo(user2.getId());
Assertions.assertThat(user1.getEntityId()).isEqualTo(user2.getEntityId());
userRepository.delete(user1);
User user3 = userRepository.load(user1.getEntityId());
Assertions.assertThat(user3).isEqualTo(null);
User user5 = getUser(2L, "N°", "2");
userRepository.delete(user5);
userRepository.save(user5);
User user6 = userRepository.load(user5.getEntityId());
Assertions.assertThat(user6.getId()).isEqualTo(user5.getId());
userRepository.delete(user5);
user6 = userRepository.load(user5.getEntityId());
Assertions.assertThat(user6).isEqualTo(null);
userRepository.persist(user5);
Assertions.assertThat(userRepository.load(2L)).isNotEqualTo(null);
}

public User getUser(long id, String firstname, String lastName) {
return new User(id, firstname, lastName, new Address("France", "75001", "Paris", "Champ Elysee avenue", 1));
}

}
Loading