Commits

Endy Muhardin committed a75e825

refactor struktur modul supaya lebih reusable

Comments (0)

Files changed (16)

belajar-restful-service-test/pom.xml

+<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/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>com.artivisi.belajar</groupId>
+		<artifactId>belajar-restful</artifactId>
+		<version>0.1.2-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>belajar-restful-service-test</artifactId>
+	<packaging>jar</packaging>
+	<name>Test untuk Implementasi Business Service</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>com.artivisi.belajar</groupId>
+			<artifactId>belajar-restful-service</artifactId>
+			<version>0.1.2-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.artivisi.belajar</groupId>
+			<artifactId>belajar-restful-config</artifactId>
+			<version>0.1.2-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.dbunit</groupId>
+			<artifactId>dbunit</artifactId>
+			<version>${dbunit.version}</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${org.springframework.version}</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-failsafe-plugin</artifactId>
+				<version>${maven-failsafe-plugin.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>integration-test</goal>
+							<goal>verify</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+
+</project>
+

belajar-restful-service-test/src/test/java/com/artivisi/belajar/restful/service/impl/BelajarRestfulServiceImplTestIT.java

+/**
+ * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.artivisi.belajar.restful.service.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.sql.Connection;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.dbunit.database.DatabaseConnection;
+import org.dbunit.dataset.CompositeDataSet;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
+import org.dbunit.operation.DatabaseOperation;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.artivisi.belajar.restful.domain.ApplicationConfig;
+import com.artivisi.belajar.restful.service.BelajarRestfulService;
+import org.springframework.data.domain.PageRequest;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
+public class BelajarRestfulServiceImplTestIT {
+
+    @Autowired
+    private BelajarRestfulService service;
+    @Autowired
+    private DataSource dataSource;
+
+    @Before
+    public void resetDatabase() throws Exception {
+
+        IDataSet[] daftarDataset = new IDataSet[]{
+                new FlatXmlDataSetBuilder().build(new File("src/test/resources/sample-data.xml"))
+        };
+
+        Connection conn = dataSource.getConnection();
+        DatabaseOperation.CLEAN_INSERT
+                .execute(new DatabaseConnection(conn),
+                        new CompositeDataSet(daftarDataset));
+    }
+
+    @Test
+    public void testFindById() {
+        ApplicationConfig ac = service.findApplicationConfigById("def456");
+        assertNotNull(ac);
+        assertEquals("applicationversion", ac.getName());
+        assertEquals("Application Version", ac.getLabel());
+        assertEquals("1.0", ac.getValue());
+    }
+
+    @Test
+    public void testSaveNew() {
+        ApplicationConfig ac = new ApplicationConfig();
+        ac.setName("base.path");
+        ac.setLabel("Installation Path");
+        ac.setValue("/opt");
+        Long countAll = service.countAllApplicationConfigs();
+        service.save(ac);
+        assertEquals(Long.valueOf(countAll + 1), service.countAllApplicationConfigs());
+        assertNotNull(ac.getId());
+    }
+
+    @Test
+    public void testSaveExisting() {
+        ApplicationConfig ac = service.findApplicationConfigById("abc123");
+        assertNotNull(ac);
+        ac.setLabel("Versi Aplikasi");
+        ac.setValue("2.0");
+        service.save(ac);
+        ApplicationConfig ac1 = service.findApplicationConfigById("abc123");
+        assertNotNull(ac1);
+        assertEquals("Versi Aplikasi", ac1.getLabel());
+        assertEquals("2.0", ac1.getValue());
+    }
+
+    @Test
+    public void testDeleteExisting() {
+        ApplicationConfig ac = service.findApplicationConfigById("abc123");
+        assertNotNull(ac);
+        Long countAll = service.countAllApplicationConfigs();
+        service.delete(ac);
+        assertEquals(Long.valueOf(countAll - 1), service.countAllApplicationConfigs());
+        ApplicationConfig ac1 = service.findApplicationConfigById("applicationversion");
+        assertNull(ac1);
+    }
+
+    @Test
+    public void testFindAll() {
+        List<ApplicationConfig> result =
+                service.findAllApplicationConfigs(new PageRequest(0, service.countAllApplicationConfigs().intValue())).getContent();
+        assertTrue(result.size() > 0);
+    }
+
+    @Test
+    public void testSearch() {
+        List<ApplicationConfig> result = service.findApplicationConfigs("name", new PageRequest(0, 5)).getContent();
+        assertTrue(result.size() == 1);
+    }
+
+    @Test
+    public void testCountSearch() {
+        Long result = service.countApplicationConfigs("name");
+        assertTrue(result == 1);
+    }
+}

belajar-restful-service-test/src/test/java/com/artivisi/belajar/restful/service/impl/MenuServiceTestIT.java

+/**
+ * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.artivisi.belajar.restful.service.impl;
+
+import com.artivisi.belajar.restful.domain.Menu;
+import com.artivisi.belajar.restful.domain.Role;
+import com.artivisi.belajar.restful.service.BelajarRestfulService;
+import java.util.List;
+import org.junit.Assert;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
+public class MenuServiceTestIT {
+    @Autowired
+    private BelajarRestfulService belajarRestfulService;
+    
+    @Test
+    public void testFindAll() {
+        Page<Menu> result = belajarRestfulService.findAllMenu(new PageRequest(0, 
+                belajarRestfulService.countAllMenu().intValue()));
+        assertTrue(result.getTotalElements() > 0);
+    }
+    
+    @Test
+    public void testFindTopLevelMenu(){
+        List<Menu> hasil = belajarRestfulService.findTopLevelMenu();
+        assertNotNull(hasil);
+        
+        assertTrue(hasil.size() == 4);
+        
+        Menu system = hasil.get(0);
+        assertEquals("system", system.getId());
+        assertEquals("#", system.getAction());
+        assertEquals("System", system.getLabel());
+        assertEquals(Integer.valueOf(0), system.getLevel());
+        assertNull(system.getOptions());
+        assertEquals(Integer.valueOf(0), system.getOrder());
+        assertNull(system.getParent());
+        
+        Menu laporan = hasil.get(3);
+        assertEquals("laporan", laporan.getId());
+        assertEquals("#", laporan.getAction());
+        assertEquals("Laporan", laporan.getLabel());
+        assertEquals(Integer.valueOf(0), laporan.getLevel());
+        assertNull(laporan.getOptions());
+        assertEquals(Integer.valueOf(3), laporan.getOrder());
+        assertNull(laporan.getParent());
+    }
+    
+    @Test
+    public void testFindMenuByParent(){
+        Menu m = belajarRestfulService.findMenuById("system");
+        
+        List<Menu> hasil = belajarRestfulService.findMenuByParent(m);
+        assertNotNull(hasil);
+        
+        assertTrue(hasil.size() == 8);
+        
+        Menu header = hasil.get(0);
+        assertEquals("system-header", header.getId());
+        assertNull(header.getAction());
+        assertEquals("Pengaturan Aplikasi", header.getLabel());
+        assertEquals(Integer.valueOf(1), header.getLevel());
+        assertEquals("{css-class:nav-header}", header.getOptions());
+        assertEquals(Integer.valueOf(0), header.getOrder());
+        assertNotNull(header.getParent());
+        
+        Menu permission = hasil.get(7);
+        assertEquals("system-permission", permission.getId());
+        assertEquals("#/system/permission", permission.getAction());
+        assertEquals("Permission", permission.getLabel());
+        assertEquals(Integer.valueOf(1), permission.getLevel());
+        assertNull(permission.getOptions());
+        assertEquals(Integer.valueOf(7), permission.getOrder());
+        assertNotNull(permission.getParent());
+    }
+    
+    @Test
+    public void testFindNotInRole() {
+        Role r = new Role();
+        r.setId("staff");
+        
+        List<Menu> hasil = belajarRestfulService.findMenuNotInRole(r);
+        assertEquals(new Integer(13), new Integer(hasil.size()));
+        
+        for (Menu menu : hasil) {
+            if(menu.getId().equals("master")){
+                Assert.fail("Seharusnya tidak ada menu master");
+            }
+        }
+    }
+}

belajar-restful-service-test/src/test/java/com/artivisi/belajar/restful/service/impl/PermissionServiceTestIT.java

+/**
+ * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.artivisi.belajar.restful.service.impl;
+
+import com.artivisi.belajar.restful.domain.Permission;
+import com.artivisi.belajar.restful.domain.Role;
+import com.artivisi.belajar.restful.service.BelajarRestfulService;
+import java.util.List;
+import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
+public class PermissionServiceTestIT {
+
+    @Autowired
+    private BelajarRestfulService service;
+
+    @Test
+    public void testFindById() {
+        Permission ac = service.findPermissionById("user-edit");
+        assertNotNull(ac);
+        assertEquals("Edit User", ac.getLabel());
+        assertEquals("ROLE_USER_EDIT", ac.getValue());
+        assertNull(service.findPermissionById(null));
+        assertNull(service.findPermissionById(""));
+    }
+
+    @Test
+    public void testFindAll() {
+        Page<Permission> result = service.findAllPermissions(new PageRequest(0, service.countAllPermissions().intValue()));
+        assertTrue(result.getTotalElements() > 0);
+    }
+    
+    @Test
+    public void testFindNotInRole() {
+        Role r = new Role();
+        r.setId("staff");
+        
+        List<Permission> hasil = service.findPermissionsNotInRole(r);
+        assertEquals(new Integer(5), new Integer(hasil.size()));
+        
+        for (Permission permission : hasil) {
+            if(permission.getId().equals("role-view")){
+                Assert.fail("Seharusnya tidak ada permission untuk view");
+            }
+        }
+    }
+}

belajar-restful-service-test/src/test/java/com/artivisi/belajar/restful/service/impl/RoleServiceTestIT.java

+/**
+ * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.artivisi.belajar.restful.service.impl;
+
+import com.artivisi.belajar.restful.domain.Menu;
+import com.artivisi.belajar.restful.domain.Permission;
+import com.artivisi.belajar.restful.domain.Role;
+import com.artivisi.belajar.restful.service.BelajarRestfulService;
+import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
+public class RoleServiceTestIT {
+
+    @Autowired
+    private BelajarRestfulService service;
+
+    @Test
+    public void testFindById() {
+        Role role = service.findRoleById("superuser");
+        assertNotNull(role);
+        assertEquals("Super User", role.getName());
+        assertEquals("Full Access", role.getDescription());
+        
+        assertNotNull(role.getMenuSet());
+        
+        for (Menu menu : role.getMenuSet()) {
+            assertNotNull(menu.getLabel());
+        }
+        
+        assertNotNull(role.getPermissionSet());
+        
+        for (Permission perm : role.getPermissionSet()) {
+            assertNotNull(perm.getValue());
+        }
+        
+        assertNull(service.findRoleById(null));
+        assertNull(service.findRoleById(""));
+    }
+
+    @Test
+    public void testFindAll() {
+        Page<Role> result = service.findAllRoles(new PageRequest(0, service.countAllRoles().intValue()));
+        assertTrue(result.getTotalElements() > 0);
+    }
+}

belajar-restful-service-test/src/test/java/com/artivisi/belajar/restful/service/impl/UserServiceTestIT.java

+/**
+ * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.artivisi.belajar.restful.service.impl;
+
+import com.artivisi.belajar.restful.domain.User;
+import com.artivisi.belajar.restful.service.BelajarRestfulService;
+import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
+public class UserServiceTestIT {
+
+    @Autowired
+    private BelajarRestfulService service;
+
+    @Test
+    public void testFindById() {
+        User ac = service.findUserById("endy");
+        assertNotNull(ac);
+        assertEquals("endy", ac.getUsername());
+        assertEquals("Endy Muhardin", ac.getFullname());
+        assertEquals("123", ac.getPassword());
+        assertEquals(Boolean.TRUE, ac.getActive());
+        assertEquals("Super User", ac.getRole().getName());
+        
+        assertNull(service.findUserById(null));
+        assertNull(service.findUserById(""));
+    }
+
+    @Test
+    public void testFindAll() {
+        Page<User> result = service.findAllUsers(new PageRequest(0, service.countAllUsers().intValue()));
+        assertTrue(result.getTotalElements() > 0);
+    }
+
+    @Test
+    public void testFindByUsername() {
+        assertNotNull(service.findUserByUsername("endy"));
+        assertNull(service.findUserByUsername("adi"));
+    }
+}

belajar-restful-service-test/src/test/resources/sample-data.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<dataset>
+    <c_application_config
+        id="abc123"
+        name="applicationname"
+        label="Application Name"
+        value="Belajar Restful"
+    />
+    
+    <c_application_config
+        id="def456"
+        name="applicationversion"
+        label="Application Version"
+        value="1.0"
+    />
+</dataset>

belajar-restful-service/pom.xml

 		</dependency>
 
 		<dependency>
-			<groupId>com.artivisi.belajar</groupId>
-			<artifactId>belajar-restful-config</artifactId>
-			<version>0.1.2-SNAPSHOT</version>
-		</dependency>
-
-		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-aop</artifactId>
 			<version>${org.springframework.version}</version>
 			<artifactId>spring-context</artifactId>
 			<version>${org.springframework.version}</version>
 		</dependency>
-
-		<dependency>
-			<groupId>org.dbunit</groupId>
-			<artifactId>dbunit</artifactId>
-			<version>${dbunit.version}</version>
-			<scope>test</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>org.springframework</groupId>
-			<artifactId>spring-test</artifactId>
-			<version>${org.springframework.version}</version>
-			<scope>test</scope>
-		</dependency>
-		
 	</dependencies>
 
-	<build>
-		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-failsafe-plugin</artifactId>
-				<version>${maven-failsafe-plugin.version}</version>
-				<executions>
-					<execution>
-						<goals>
-							<goal>integration-test</goal>
-							<goal>verify</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
-		</plugins>
-	</build>
-
 </project>
 

belajar-restful-service/src/test/java/com/artivisi/belajar/restful/service/impl/BelajarRestfulServiceImplTestIT.java

-/**
- * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.artivisi.belajar.restful.service.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.sql.Connection;
-import java.util.List;
-
-import javax.sql.DataSource;
-
-import org.dbunit.database.DatabaseConnection;
-import org.dbunit.dataset.CompositeDataSet;
-import org.dbunit.dataset.IDataSet;
-import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
-import org.dbunit.operation.DatabaseOperation;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import com.artivisi.belajar.restful.domain.ApplicationConfig;
-import com.artivisi.belajar.restful.service.BelajarRestfulService;
-import org.springframework.data.domain.PageRequest;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
-public class BelajarRestfulServiceImplTestIT {
-
-    @Autowired
-    private BelajarRestfulService service;
-    @Autowired
-    private DataSource dataSource;
-
-    @Before
-    public void resetDatabase() throws Exception {
-
-        IDataSet[] daftarDataset = new IDataSet[]{
-                new FlatXmlDataSetBuilder().build(new File("src/test/resources/sample-data.xml"))
-        };
-
-        Connection conn = dataSource.getConnection();
-        DatabaseOperation.CLEAN_INSERT
-                .execute(new DatabaseConnection(conn),
-                        new CompositeDataSet(daftarDataset));
-    }
-
-    @Test
-    public void testFindById() {
-        ApplicationConfig ac = service.findApplicationConfigById("def456");
-        assertNotNull(ac);
-        assertEquals("applicationversion", ac.getName());
-        assertEquals("Application Version", ac.getLabel());
-        assertEquals("1.0", ac.getValue());
-    }
-
-    @Test
-    public void testSaveNew() {
-        ApplicationConfig ac = new ApplicationConfig();
-        ac.setName("base.path");
-        ac.setLabel("Installation Path");
-        ac.setValue("/opt");
-        Long countAll = service.countAllApplicationConfigs();
-        service.save(ac);
-        assertEquals(Long.valueOf(countAll + 1), service.countAllApplicationConfigs());
-        assertNotNull(ac.getId());
-    }
-
-    @Test
-    public void testSaveExisting() {
-        ApplicationConfig ac = service.findApplicationConfigById("abc123");
-        assertNotNull(ac);
-        ac.setLabel("Versi Aplikasi");
-        ac.setValue("2.0");
-        service.save(ac);
-        ApplicationConfig ac1 = service.findApplicationConfigById("abc123");
-        assertNotNull(ac1);
-        assertEquals("Versi Aplikasi", ac1.getLabel());
-        assertEquals("2.0", ac1.getValue());
-    }
-
-    @Test
-    public void testDeleteExisting() {
-        ApplicationConfig ac = service.findApplicationConfigById("abc123");
-        assertNotNull(ac);
-        Long countAll = service.countAllApplicationConfigs();
-        service.delete(ac);
-        assertEquals(Long.valueOf(countAll - 1), service.countAllApplicationConfigs());
-        ApplicationConfig ac1 = service.findApplicationConfigById("applicationversion");
-        assertNull(ac1);
-    }
-
-    @Test
-    public void testFindAll() {
-        List<ApplicationConfig> result =
-                service.findAllApplicationConfigs(new PageRequest(0, service.countAllApplicationConfigs().intValue())).getContent();
-        assertTrue(result.size() > 0);
-    }
-
-    @Test
-    public void testSearch() {
-        List<ApplicationConfig> result = service.findApplicationConfigs("name", new PageRequest(0, 5)).getContent();
-        assertTrue(result.size() == 1);
-    }
-
-    @Test
-    public void testCountSearch() {
-        Long result = service.countApplicationConfigs("name");
-        assertTrue(result == 1);
-    }
-}

belajar-restful-service/src/test/java/com/artivisi/belajar/restful/service/impl/MenuServiceTestIT.java

-/**
- * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.artivisi.belajar.restful.service.impl;
-
-import com.artivisi.belajar.restful.domain.Menu;
-import com.artivisi.belajar.restful.domain.Role;
-import com.artivisi.belajar.restful.service.BelajarRestfulService;
-import java.util.List;
-import org.junit.Assert;
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
-public class MenuServiceTestIT {
-    @Autowired
-    private BelajarRestfulService belajarRestfulService;
-    
-    @Test
-    public void testFindAll() {
-        Page<Menu> result = belajarRestfulService.findAllMenu(new PageRequest(0, 
-                belajarRestfulService.countAllMenu().intValue()));
-        assertTrue(result.getTotalElements() > 0);
-    }
-    
-    @Test
-    public void testFindTopLevelMenu(){
-        List<Menu> hasil = belajarRestfulService.findTopLevelMenu();
-        assertNotNull(hasil);
-        
-        assertTrue(hasil.size() == 4);
-        
-        Menu system = hasil.get(0);
-        assertEquals("system", system.getId());
-        assertEquals("#", system.getAction());
-        assertEquals("System", system.getLabel());
-        assertEquals(Integer.valueOf(0), system.getLevel());
-        assertNull(system.getOptions());
-        assertEquals(Integer.valueOf(0), system.getOrder());
-        assertNull(system.getParent());
-        
-        Menu laporan = hasil.get(3);
-        assertEquals("laporan", laporan.getId());
-        assertEquals("#", laporan.getAction());
-        assertEquals("Laporan", laporan.getLabel());
-        assertEquals(Integer.valueOf(0), laporan.getLevel());
-        assertNull(laporan.getOptions());
-        assertEquals(Integer.valueOf(3), laporan.getOrder());
-        assertNull(laporan.getParent());
-    }
-    
-    @Test
-    public void testFindMenuByParent(){
-        Menu m = belajarRestfulService.findMenuById("system");
-        
-        List<Menu> hasil = belajarRestfulService.findMenuByParent(m);
-        assertNotNull(hasil);
-        
-        assertTrue(hasil.size() == 8);
-        
-        Menu header = hasil.get(0);
-        assertEquals("system-header", header.getId());
-        assertNull(header.getAction());
-        assertEquals("Pengaturan Aplikasi", header.getLabel());
-        assertEquals(Integer.valueOf(1), header.getLevel());
-        assertEquals("{css-class:nav-header}", header.getOptions());
-        assertEquals(Integer.valueOf(0), header.getOrder());
-        assertNotNull(header.getParent());
-        
-        Menu permission = hasil.get(7);
-        assertEquals("system-permission", permission.getId());
-        assertEquals("#/system/permission", permission.getAction());
-        assertEquals("Permission", permission.getLabel());
-        assertEquals(Integer.valueOf(1), permission.getLevel());
-        assertNull(permission.getOptions());
-        assertEquals(Integer.valueOf(7), permission.getOrder());
-        assertNotNull(permission.getParent());
-    }
-    
-    @Test
-    public void testFindNotInRole() {
-        Role r = new Role();
-        r.setId("staff");
-        
-        List<Menu> hasil = belajarRestfulService.findMenuNotInRole(r);
-        assertEquals(new Integer(13), new Integer(hasil.size()));
-        
-        for (Menu menu : hasil) {
-            if(menu.getId().equals("master")){
-                Assert.fail("Seharusnya tidak ada menu master");
-            }
-        }
-    }
-}

belajar-restful-service/src/test/java/com/artivisi/belajar/restful/service/impl/PermissionServiceTestIT.java

-/**
- * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.artivisi.belajar.restful.service.impl;
-
-import com.artivisi.belajar.restful.domain.Permission;
-import com.artivisi.belajar.restful.domain.Role;
-import com.artivisi.belajar.restful.service.BelajarRestfulService;
-import java.util.List;
-import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
-public class PermissionServiceTestIT {
-
-    @Autowired
-    private BelajarRestfulService service;
-
-    @Test
-    public void testFindById() {
-        Permission ac = service.findPermissionById("user-edit");
-        assertNotNull(ac);
-        assertEquals("Edit User", ac.getLabel());
-        assertEquals("ROLE_USER_EDIT", ac.getValue());
-        assertNull(service.findPermissionById(null));
-        assertNull(service.findPermissionById(""));
-    }
-
-    @Test
-    public void testFindAll() {
-        Page<Permission> result = service.findAllPermissions(new PageRequest(0, service.countAllPermissions().intValue()));
-        assertTrue(result.getTotalElements() > 0);
-    }
-    
-    @Test
-    public void testFindNotInRole() {
-        Role r = new Role();
-        r.setId("staff");
-        
-        List<Permission> hasil = service.findPermissionsNotInRole(r);
-        assertEquals(new Integer(5), new Integer(hasil.size()));
-        
-        for (Permission permission : hasil) {
-            if(permission.getId().equals("role-view")){
-                Assert.fail("Seharusnya tidak ada permission untuk view");
-            }
-        }
-    }
-}

belajar-restful-service/src/test/java/com/artivisi/belajar/restful/service/impl/RoleServiceTestIT.java

-/**
- * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.artivisi.belajar.restful.service.impl;
-
-import com.artivisi.belajar.restful.domain.Menu;
-import com.artivisi.belajar.restful.domain.Permission;
-import com.artivisi.belajar.restful.domain.Role;
-import com.artivisi.belajar.restful.service.BelajarRestfulService;
-import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
-public class RoleServiceTestIT {
-
-    @Autowired
-    private BelajarRestfulService service;
-
-    @Test
-    public void testFindById() {
-        Role role = service.findRoleById("superuser");
-        assertNotNull(role);
-        assertEquals("Super User", role.getName());
-        assertEquals("Full Access", role.getDescription());
-        
-        assertNotNull(role.getMenuSet());
-        
-        for (Menu menu : role.getMenuSet()) {
-            assertNotNull(menu.getLabel());
-        }
-        
-        assertNotNull(role.getPermissionSet());
-        
-        for (Permission perm : role.getPermissionSet()) {
-            assertNotNull(perm.getValue());
-        }
-        
-        assertNull(service.findRoleById(null));
-        assertNull(service.findRoleById(""));
-    }
-
-    @Test
-    public void testFindAll() {
-        Page<Role> result = service.findAllRoles(new PageRequest(0, service.countAllRoles().intValue()));
-        assertTrue(result.getTotalElements() > 0);
-    }
-}

belajar-restful-service/src/test/java/com/artivisi/belajar/restful/service/impl/UserServiceTestIT.java

-/**
- * Copyright (C) 2011 ArtiVisi Intermedia <info@artivisi.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.artivisi.belajar.restful.service.impl;
-
-import com.artivisi.belajar.restful.domain.User;
-import com.artivisi.belajar.restful.service.BelajarRestfulService;
-import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath*:com/artivisi/**/applicationContext.xml")
-public class UserServiceTestIT {
-
-    @Autowired
-    private BelajarRestfulService service;
-
-    @Test
-    public void testFindById() {
-        User ac = service.findUserById("endy");
-        assertNotNull(ac);
-        assertEquals("endy", ac.getUsername());
-        assertEquals("Endy Muhardin", ac.getFullname());
-        assertEquals("123", ac.getPassword());
-        assertEquals(Boolean.TRUE, ac.getActive());
-        assertEquals("Super User", ac.getRole().getName());
-        
-        assertNull(service.findUserById(null));
-        assertNull(service.findUserById(""));
-    }
-
-    @Test
-    public void testFindAll() {
-        Page<User> result = service.findAllUsers(new PageRequest(0, service.countAllUsers().intValue()));
-        assertTrue(result.getTotalElements() > 0);
-    }
-
-    @Test
-    public void testFindByUsername() {
-        assertNotNull(service.findUserByUsername("endy"));
-        assertNull(service.findUserByUsername("adi"));
-    }
-}

belajar-restful-service/src/test/resources/sample-data.xml

-<?xml version="1.0" encoding="UTF-8"?>
-<dataset>
-    <c_application_config
-        id="abc123"
-        name="applicationname"
-        label="Application Name"
-        value="Belajar Restful"
-    />
-    
-    <c_application_config
-        id="def456"
-        name="applicationversion"
-        label="Application Version"
-        value="1.0"
-    />
-</dataset>

belajar-restful-web/pom.xml

 		</dependency>
 
 		<dependency>
+			<groupId>com.artivisi.belajar</groupId>
+			<artifactId>belajar-restful-config</artifactId>
+			<version>0.1.2-SNAPSHOT</version>
+			<scope>runtime</scope>
+		</dependency>
+
+		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-webmvc</artifactId>
 			<version>${org.springframework.version}</version>
 		<module>belajar-restful-config</module>
 		<module>belajar-restful-domain</module>
 		<module>belajar-restful-service</module>
+		<module>belajar-restful-service-test</module>
 		<module>belajar-restful-web</module>
 	</modules>