You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2017/06/09 09:18:24 UTC

[04/11] marmotta git commit: MARMOTTA-534: found the source!

MARMOTTA-534: found the source!


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/8718475c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/8718475c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/8718475c

Branch: refs/heads/develop
Commit: 8718475c81b370232ffd6158eb076069744ac7ff
Parents: 958a79e
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 10:10:58 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 10:10:58 2017 +0200

----------------------------------------------------------------------
 .../user/services/AccountServiceTest.java       | 66 ++++++++++++++++++++
 1 file changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/8718475c/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
new file mode 100644
index 0000000..28de609
--- /dev/null
+++ b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
@@ -0,0 +1,66 @@
+package org.apache.marmotta.platform.user.services;
+
+import com.jayway.restassured.RestAssured;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.apache.marmotta.platform.user.api.AccountService;
+import org.apache.marmotta.platform.user.model.UserAccount;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.hasItems;
+
+/**
+ * AccountService Test
+ *
+ * @author Sergio Fernández
+ */
+public class AccountServiceTest {
+
+    private static Logger log = LoggerFactory.getLogger(AccountServiceTest.class);
+
+    private static JettyMarmotta marmotta;
+
+    @BeforeClass
+    public static void setUp() throws MarmottaImportException, URISyntaxException {
+        marmotta = new JettyMarmotta("/marmotta", AccountService.class);
+        RestAssured.baseURI = "http://localhost";
+        RestAssured.port = marmotta.getPort();
+        RestAssured.basePath = marmotta.getContext();
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        marmotta.shutdown();
+    }
+
+    @Test
+    public void testDefaultAccounts() {
+        final AccountService accountService = marmotta.getService(AccountService.class);
+
+        final List<UserAccount> accounts = accountService.listAccounts();
+        Assert.assertEquals(2, accounts.size());
+        Assert.assertEquals("anonymous", accounts.get(0).getLogin());
+        Assert.assertEquals("admin", accounts.get(1).getLogin());
+    }
+
+    @Test
+    public void testAdminDefaults() {
+        final AccountService accountService = marmotta.getService(AccountService.class);
+
+        final UserAccount admin = accountService.getAccount("admin");
+        final Set<String> roles = admin.getRoles();
+        Assert.assertEquals(3, roles.size());
+        Assert.assertThat(roles, hasItems("user", "editor", "manager"));
+        Assert.assertTrue(admin.checkPasswd("pass123"));
+    }
+
+}