/*
Copyright 2006 - 2010 Under Dusken
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.
*/
/**
* @author Erlend Hamnaberg<erlenha@underdusken.no>
* @version $Id$
*/
package no.dusken.aranea.service;
import no.dusken.aranea.model.Role;
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 org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/META-INF/integrationTest.xml"})
@TransactionConfiguration(transactionManager="transactionManager", defaultRollback=true)
@Transactional
public class TestRoleServiceImpl {
@Autowired
private RoleService roleService;
private Role role;
@Before
public void onSetup(){
Role r1 = new Role();
Role r2 = new Role();
Role r3 = new Role();
Role r4 = new Role();
Role r5 = new Role();
r1.setName("Role1");
r2.setName("Role2");
r3.setName("Role3");
r4.setName("Role4");
r5.setName("Role5");
r1.setOrdering(1);
r2.setOrdering(2);
r3.setOrdering(3);
r4.setOrdering(4);
r5.setOrdering(5);
role = roleService.saveOrUpdate(r1);
roleService.saveOrUpdate(r2);
roleService.saveOrUpdate(r3);
roleService.saveOrUpdate(r4);
roleService.saveOrUpdate(r5);
}
@Test
public void testEntity() {
Role r = roleService.getEntity(role.getID());
assertNotNull(r);
assertEquals(role, r);
assertEquals(roleService.getRoles().size(), 5);
}
}