Разработка системы контроля и управления доступом к охраняемым объектам
Принципы работы систем контроля и управления доступом, принцип их работы и оценка возможностей. Сравнительное описание методов идентификации. Разработка информационно-компьютерной системы контроля и управления доступом. Создание аппаратной подсистемы.
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 26.07.2013 |
Размер файла | 1,7 M |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Vaadin</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<description>Vaadin UI to display</description>
<param-name>UI</param-name>
<param-value>ua.com.lejastu.design.Index</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Vaadin</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!--<resource-ref>-->
<!--<res-ref-name>jdbc/DSTest</res-ref-name>-->
<!--<res-type>javax.sql.DataSource</res-type>-->
<!--<res-auth>Container</res-auth>-->
<!--<res-sharing-scope>Shareable</res-sharing-scope>-->
<!--</resource-ref>-->
</web-app>
3.2 Файл persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="skudy" transaction-type="RESOURCE_LOCAL">
<class>ua.com.lejastu.entity.User</class>
<class>ua.com.lejastu.entity.Workbench</class>
<class>ua.com.lejastu.entity.RealSalary</class>
<class>ua.com.lejastu.entity.MissByIll</class>
<class>ua.com.lejastu.entity.Calendaring</class>
<class>ua.com.lejastu.entity.User</class>
<class>ua.com.lejastu.entity.AccessLevel</class>
<class>ua.com.lejastu.entity.Buildings</class>
<class>ua.com.lejastu.entity.GroupWorker</class>
<class>ua.com.lejastu.entity.Stage</class>
<class>ua.com.lejastu.entity.Room</class>
</persistence-unit>
</persistence>
3.3 Файл applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:spring-configured />
<context:component-scan base-package="ua.com.lejastu" />
<tx:annotation-driven />
<jpa:repositories base-package="ua.com.lejastu.repository" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/skudy"/>
<property name="username" value="root"/>
<property name="password" value="111111"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<!--<property name="persistenceXmlLocation" value="META-INF/persistence.xml" />-->
<!--<property name="persistenceUnitName" value="skudy"/>-->
<property name="packagesToScan">
<list>
<value>ua.com.lejastu.entity</value>
</list>
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="true"/>
<property name="database" value="MYSQL" />
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />
</beans>
3 КЛАССЫ-ТЕСТЫ
3.1 Класс AccessLevelTest
import org.junit.Assert;
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 ua.com.lejastu.dao.AccessLevelDao;
import ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.entity.AccessLevel;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.repository.AccessRepository;
import ua.com.lejastu.repository.GroupRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class AccessLevelTest {
@Autowired
private AccessRepository accessRepository;
@Autowired
private GroupRepository groupDao;
@Test
public void testCreateLevel() throws Exception {
AccessLevel accessLevel = new AccessLevel();
accessLevel.setLevelNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupDao.save(groupWorker);
accessLevel.setGroupAccessLevel(groupWorker);
accessRepository.save(accessLevel);
Long getId = accessLevel.getId();
AccessLevel accessLevelTest = accessRepository.findOne(getId);
Long mustEquals=accessLevelTest.getLevelNumber();
Assert.assertNotNull("It was your mistake!", accessLevelTest);
Assert.assertEquals((Object) mustEquals, 123L);
accessRepository.delete(getId);
Long mD= groupWorker.getId();
groupDao.delete(mD);
AccessLevel mustNull=accessRepository.findOne(accessLevel.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateLevel() throws Exception {
AccessLevel accessLevel = new AccessLevel();
accessLevel.setLevelNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupDao.save(groupWorker);
accessLevel.setGroupAccessLevel(groupWorker);
accessRepository.save(accessLevel);
AccessLevel accessLevelTest = accessRepository.findOne(accessLevel.getId());
accessLevelTest.setLevelNumber(1234567L);
accessRepository.saveAndFlush(accessLevelTest);
Long mustEquals= accessLevelTest.getLevelNumber();
Assert.assertNotNull("It was your mistake!", accessLevelTest);
Assert.assertEquals((Object)mustEquals, 1234567L);
accessRepository.delete(accessLevel.getId());
Long mD= groupWorker.getId();
groupDao.delete(mD);
AccessLevel mustNull=accessRepository.findOne(accessLevel.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteLevel() throws Exception {
AccessLevel accessLevel = new AccessLevel();
accessLevel.setLevelNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupDao.save(groupWorker);
accessLevel.setGroupAccessLevel(groupWorker);
accessRepository.save(accessLevel);
Long getId = accessRepository.findOne(accessLevel.getId()).getId();
accessRepository.delete(getId);
Long mD= groupWorker.getId();
groupDao.delete(mD);
AccessLevel groupWorkerTest=accessRepository.findOne(getId);
Assert.assertNull("It was your mistake",groupWorkerTest);
}
@Test
public void testGetGroupById() throws Exception {
AccessLevel accessLevel = new AccessLevel();
accessLevel.setLevelNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupDao.save(groupWorker);
accessLevel.setGroupAccessLevel(groupWorker);
accessRepository.save(accessLevel);
AccessLevel accessLevelTest = accessRepository.findOne(accessLevel.getId());
Long mustEquals= accessLevelTest.getLevelNumber();
Assert.assertNotNull("It was your mistake!", accessLevelTest);
Assert.assertEquals((Object)mustEquals, 123L);
accessRepository.delete(accessLevel.getId());
Long mD= groupWorker.getId();
groupDao.delete(mD);
AccessLevel mustNull=accessRepository.findOne(accessLevel.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.2 Класс BuildingsTest
import org.junit.Assert;
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 ua.com.lejastu.dao.BuildingsDao;
import ua.com.lejastu.entity.Buildings;
import ua.com.lejastu.repository.BuildingsRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class BuildingsTest {
@Autowired
private BuildingsRepository buildingsRepository;
@Test
public void testCreateGroup() throws Exception {
Buildings buildings = new Buildings();
buildings.setPathFile("C:\\qwerty\\orange.jpg");
buildings.setAddress("KIEV IS THE CAPITAL OF UKRAINE!");
buildingsRepository.save(buildings);
Long getId = buildings.getId();
Buildings buildingsTest = buildingsRepository.findOne(getId);
String mustEquals=buildingsTest.getPathFile();
Assert.assertNotNull("It was your mistake!", buildingsTest);
Assert.assertEquals(mustEquals, "C:\\qwerty\\orange.jpg");
buildingsRepository.delete(getId);
Buildings mustNull=buildingsRepository.findOne(buildings.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Buildings buildings = new Buildings();
buildings.setPathFile("C:\\qwerty\\orange.jpg");
buildings.setAddress("KIEV IS THE CAPITAL OF UKRAINE!");
buildingsRepository.save(buildings);
Buildings buildingsTest = buildingsRepository.findOne(buildings.getId());
buildingsTest.setPathFile("C:\\qwerty\\strawberry.jpg");
buildingsRepository.saveAndFlush(buildingsTest);
String mustEquals= buildingsTest.getPathFile();
Assert.assertNotNull("It was your mistake!", buildingsTest);
Assert.assertEquals(mustEquals, "C:\\qwerty\\strawberry.jpg");
buildingsRepository.delete(buildings.getId());
Buildings mustNull=buildingsRepository.findOne(buildings.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
Buildings buildings = new Buildings();
buildings.setPathFile("C:\\qwerty\\orange.jpg");
buildings.setAddress("KIEV IS THE CAPITAL OF UKRAINE!");
buildingsRepository.save(buildings);
Long getId = buildingsRepository.findOne(buildings.getId()).getId();
buildingsRepository.delete(getId);
Buildings calendaringTest=buildingsRepository.findOne(getId);
Assert.assertNull("It was your mistake",calendaringTest);
}
@Test
public void testGetGroupById() throws Exception {
Buildings buildings = new Buildings();
buildings.setPathFile("C:\\qwerty\\orange.jpg");
buildings.setAddress("KIEV IS THE CAPITAL OF UKRAINE!");
buildingsRepository.save(buildings);
Buildings buildingsTest = buildingsRepository.findOne(buildings.getId());
String mustEquals= buildingsTest.getPathFile();
Assert.assertNotNull("It was your mistake!", buildingsTest);
Assert.assertEquals(mustEquals,"C:\\qwerty\\orange.jpg");
buildingsRepository.delete(buildings.getId());
Buildings mustNull=buildingsRepository.findOne(buildings.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.3 Класс CalendaringTest
import org.junit.Assert;
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 ua.com.lejastu.dao.CalendaringDao;
import ua.com.lejastu.entity.Calendaring;
import ua.com.lejastu.repository.CalendaringRepository;
import java.util.Date;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class CalendaringTest {
@Autowired
private CalendaringRepository calendaringRepository;
@Test
public void testCreateGroup() throws Exception {
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(100));
calendaringRepository.save(calendaring);
Long getId = calendaring.getId();
Calendaring calendaringTest = calendaringRepository.findOne(getId);
Date mustEquals=calendaringTest.getDate();
Assert.assertNotNull("It was your mistake!", calendaringTest);
Assert.assertEquals(mustEquals.toString(), "1970-01-01");
calendaringRepository.delete(getId);
Calendaring mustNull=calendaringRepository.findOne(calendaring.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(100L));
calendaringRepository.save(calendaring);
Calendaring calendaringTest = calendaringRepository.findOne(calendaring.getId());
calendaringTest.setDate(new Date(101L));
calendaringRepository.saveAndFlush(calendaringTest);
Date mustEquals= calendaringTest.getDate();
Assert.assertNotNull("It was your mistake!", calendaringTest);
Assert.assertEquals(mustEquals, new Date(101L));
calendaringRepository.delete(calendaring.getId());
Calendaring mustNull=calendaringRepository.findOne(calendaring.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(100L));
calendaringRepository.save(calendaring);
Long getId = calendaringRepository.findOne(calendaring.getId()).getId();
calendaringRepository.delete(getId);
Calendaring calendaringTest=calendaringRepository.findOne(getId);
Assert.assertNull("It was your mistake",calendaringTest);
}
@Test
public void testGetGroupById() throws Exception {
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(100L));
calendaringRepository.save(calendaring);
Calendaring calendaringTest = calendaringRepository.findOne(calendaring.getId());
Date mustEquals= calendaringTest.getDate();
Assert.assertNotNull("It was your mistake!", calendaringTest);
Assert.assertEquals(mustEquals.toString(), "1970-01-01");
calendaringRepository.delete(calendaring.getId());
Calendaring mustNull=calendaringRepository.findOne(calendaring.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.4 Класс GroupTest
import org.junit.Assert;
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 ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.repository.GroupRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class GroupTest {
@Autowired
private GroupRepository groupRepository;
@Test
public void testCreateGroup() throws Exception {
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("testGroup");
groupRepository.save(groupWorker);
Long getId = groupWorker.getId();
GroupWorker groupWorkerTest = groupRepository.findOne(getId);
String mustEquals=groupWorkerTest.getGroupName();
Assert.assertNotNull("It was your mistake!", groupWorkerTest);
Assert.assertEquals(mustEquals, "testGroup");
groupRepository.delete(getId);
GroupWorker mustNull=groupRepository.findOne(groupWorker.getId());
Assert.assertNull("It was your mistake",mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("testGroup");
groupRepository.save(groupWorker);
GroupWorker groupWorkerTest = groupRepository.findOne(groupWorker.getId());
groupWorkerTest.setGroupName("Banjo Men");
groupRepository.saveAndFlush(groupWorkerTest);
String mustEquals= groupWorkerTest.getGroupName();
Assert.assertNotNull("It was your mistake!", groupWorkerTest);
Assert.assertEquals(mustEquals, "Banjo Men");
groupRepository.delete(groupWorker.getId());
GroupWorker mustNull=groupRepository.findOne(groupWorker.getId());
Assert.assertNull("It was your mistake",mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("testGroup");
groupRepository.save(groupWorker);
Long getId = groupRepository.findOne(groupWorker.getId()).getId();
groupRepository.delete(getId);
GroupWorker groupWorkerTest=groupRepository.findOne(getId);
Assert.assertNull("It was your mistake",groupWorkerTest);
}
@Test
public void testGetGroupById() throws Exception {
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
GroupWorker groupWorkerTest = groupRepository.findOne(groupWorker.getId());
String mustEquals= groupWorkerTest.getGroupName();
Assert.assertNotNull("It was your mistake!", groupWorkerTest);
Assert.assertEquals(mustEquals, "Banjo Men");
groupRepository.delete(groupWorker.getId());
GroupWorker mustNull=groupRepository.findOne(groupWorker.getId());
Assert.assertNull("It was your mistake",mustNull);
}
}
3.5 Класс MissedByIllnessTest
import org.junit.Assert;
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 ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.dao.MissedByIllnessDao;
import ua.com.lejastu.dao.UserDao;
import ua.com.lejastu.entity.Calendaring;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.entity.MissByIll;
import ua.com.lejastu.entity.User;
import ua.com.lejastu.repository.GroupRepository;
import ua.com.lejastu.repository.MissRepository;
import ua.com.lejastu.repository.UserRepository;
import java.util.Date;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class MissedByIllnessTest {
@Autowired
private MissRepository missRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private GroupRepository groupRepository;
@Test
public void testCreateGroup() throws Exception {
MissByIll missByIll = new MissByIll();
missByIll.setFromDate(new Date(100L));
missByIll.setToDate(new Date(105L));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
missByIll.setUserMissed(user);
missRepository.save(missByIll);
Long getId = missByIll.getId();
MissByIll missByIllTest = missRepository.findOne(getId);
Date mustEquals=missByIllTest.getToDate();
Assert.assertNotNull("It was your mistake!", missByIllTest);
Assert.assertEquals(mustEquals.toString(), "1970-01-01");
missRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
MissByIll mustNull=missRepository.findOne(missByIll.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
MissByIll missByIll = new MissByIll();
missByIll.setFromDate(new Date(100L));
missByIll.setToDate(new Date(105L));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
missByIll.setUserMissed(user);
missRepository.save(missByIll);
MissByIll missByIllTest = missRepository.findOne(missByIll.getId());
missByIllTest.setToDate(new Date(111L));
missRepository.saveAndFlush(missByIllTest);
Date mustEquals= missByIllTest.getToDate();
Assert.assertNotNull("It was your mistake!", missByIllTest);
Assert.assertEquals(mustEquals, new Date(111L));
missRepository.delete(missByIll.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
MissByIll mustNull=missRepository.findOne(12345L);
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
MissByIll missByIll = new MissByIll();
missByIll.setFromDate(new Date(100L));
missByIll.setToDate(new Date(105L));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
missByIll.setUserMissed(user);
missRepository.save(missByIll);
Long getId = missRepository.findOne(missByIll.getId()).getId();
missRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
MissByIll transitionTest=missRepository.findOne(getId);
Assert.assertNull("It was your mistake",transitionTest);
}
@Test
public void testGetGroupById() throws Exception {
MissByIll missByIll = new MissByIll();
missByIll.setFromDate(new Date(100L));
missByIll.setToDate(new Date(105L));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
missByIll.setUserMissed(user);
missRepository.save(missByIll);
MissByIll transitionTest = missRepository.findOne(missByIll.getId());
Date mustEquals= transitionTest.getToDate();
Assert.assertNotNull("It was your mistake!", transitionTest);
Assert.assertEquals(mustEquals.toString(), "1970-01-01");
missRepository.delete(missByIll.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
MissByIll mustNull=missRepository.findOne(missByIll.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.6 Класс RealSalaryTest
import org.junit.Assert;
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 ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.dao.RealSalaryDao;
import ua.com.lejastu.dao.UserDao;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.entity.RealSalary;
import ua.com.lejastu.entity.User;
import ua.com.lejastu.repository.GroupRepository;
import ua.com.lejastu.repository.RealSalaryRepository;
import ua.com.lejastu.repository.UserRepository;
import java.util.Date;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class RealSalaryTest {
@Autowired
private RealSalaryRepository realSalaryRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private GroupRepository groupRepository;
@Test
public void testCreateGroup() throws Exception {
RealSalary realSalary = new RealSalary();
realSalary.setMonth(new Date(100L));
realSalary.setRealTimeWork(101L);
realSalary.setSalary(105L);
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
realSalary.setUserSalary(user);
realSalaryRepository.save(realSalary);
Long getId = realSalary.getId();
RealSalary realSalaryTest = realSalaryRepository.findOne(getId);
Long mustEquals=realSalaryTest.getSalary();
Assert.assertNotNull("It was your mistake!", realSalaryTest);
Assert.assertEquals((Object)mustEquals,105L);
realSalaryRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
RealSalary mustNull=realSalaryRepository.findOne(realSalary.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
RealSalary realSalary = new RealSalary();
realSalary.setMonth(new Date(100L));
realSalary.setRealTimeWork(101L);
realSalary.setSalary(105L);
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
realSalary.setUserSalary(user);
realSalaryRepository.save(realSalary);
RealSalary realSalaryTest = realSalaryRepository.findOne(realSalary.getId());
realSalaryTest.setSalary(111L);
realSalaryRepository.saveAndFlush(realSalaryTest);
Long mustEquals= realSalaryTest.getSalary();
Assert.assertNotNull("It was your mistake!", realSalaryTest);
Assert.assertEquals((Object)mustEquals, 111L);
realSalaryRepository.delete(realSalary.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
RealSalary mustNull=realSalaryRepository.findOne(realSalary.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
RealSalary realSalary = new RealSalary();
realSalary.setMonth(new Date(100L));
realSalary.setRealTimeWork(101L);
realSalary.setSalary(105L);
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
realSalary.setUserSalary(user);
realSalaryRepository.save(realSalary);
Long getId = realSalaryRepository.findOne(realSalary.getId()).getId();
realSalaryRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
RealSalary transitionTest=realSalaryRepository.findOne(getId);
Assert.assertNull("It was your mistake",transitionTest);
}
@Test
public void testGetGroupById() throws Exception {
RealSalary realSalary = new RealSalary();
realSalary.setMonth(new Date(100L));
realSalary.setRealTimeWork(101L);
realSalary.setSalary(105L);
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
realSalary.setUserSalary(user);
realSalaryRepository.save(realSalary);
RealSalary transitionTest = realSalaryRepository.findOne(realSalary.getId());
Long mustEquals= transitionTest.getSalary();
Assert.assertNotNull("It was your mistake!", transitionTest);
Assert.assertEquals((Object)mustEquals,105L);
realSalaryRepository.delete(realSalary.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
RealSalary mustNull=realSalaryRepository.findOne(realSalary.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.7 Класс RoomTest
import org.junit.Assert;
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 ua.com.lejastu.dao.RoomDao;
import ua.com.lejastu.entity.Room;
import ua.com.lejastu.repository.RoomRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class RoomTest {
@Autowired
private RoomRepository roomRepository;
@Test
public void testCreateGroup() throws Exception {
Room room = new Room();
room.setAccessLevel(11);
room.setNumber(33);
roomRepository.save(room);
Long getId = room.getId();
Room roomTest = roomRepository.findOne(getId);
Integer mustEquals=roomTest.getNumber();
Assert.assertNotNull("It was your mistake!", roomTest);
Assert.assertEquals((Object)mustEquals, 33);
roomRepository.delete(getId);
Room mustNull=roomRepository.findOne(room.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Room room = new Room();
room.setAccessLevel(11);
room.setNumber(33);
roomRepository.save(room);
Room roomTest = roomRepository.findOne(room.getId());
roomTest.setNumber(15);
roomRepository.saveAndFlush(roomTest);
Integer mustEquals= roomTest.getNumber();
Assert.assertNotNull("It was your mistake!", roomTest);
Assert.assertEquals((Object)mustEquals, 15);
roomRepository.delete(room.getId());
Room mustNull=roomRepository.findOne(room.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
Room room = new Room();
room.setAccessLevel(11);
room.setNumber(33);
roomRepository.save(room);
Long getId = roomRepository.findOne(room.getId()).getId();
roomRepository.delete(getId);
Room calendaringTest=roomRepository.findOne(getId);
Assert.assertNull("It was your mistake",calendaringTest);
}
@Test
public void testGetGroupById() throws Exception {
Room room = new Room();
room.setAccessLevel(11);
room.setNumber(33);
roomRepository.save(room);
Room roomTest = roomRepository.findOne(room.getId());
Integer mustEquals= roomTest.getNumber();
Assert.assertNotNull("It was your mistake!", roomTest);
Assert.assertEquals((Object)mustEquals,33);
roomRepository.delete(room.getId());
Room mustNull=roomRepository.findOne(room.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.8 Класс StageTest
import org.junit.Assert;
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 ua.com.lejastu.dao.StageDao;
import ua.com.lejastu.entity.Stage;
import ua.com.lejastu.repository.StageRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml"})
public class StageTest {
@Autowired
private StageRepository stageRepository;
@Test
public void testCreateGroup() throws Exception {
Stage stage = new Stage();
stage.setPathSvg("C:\\qwerty\\orange.jpg");
stage.setStageNumber(33);
stageRepository.save(stage);
Long getId = stage.getId();
Stage stageTest = stageRepository.findOne(getId);
String mustEquals=stageTest.getPathSvg();
Assert.assertNotNull("It was your mistake!", stageTest);
Assert.assertEquals(mustEquals, "C:\\qwerty\\orange.jpg");
stageRepository.delete(getId);
Stage mustNull=stageRepository.findOne(stage.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Stage stage = new Stage();
stage.setPathSvg("C:\\qwerty\\orange.jpg");
stage.setStageNumber(33);
stageRepository.save(stage);
Stage stageTest = stageRepository.findOne(stage.getId());
stageTest.setPathSvg("C:\\qwerty\\strawberry.jpg");
stageRepository.saveAndFlush(stageTest);
String mustEquals= stageTest.getPathSvg();
Assert.assertNotNull("It was your mistake!", stageTest);
Assert.assertEquals(mustEquals, "C:\\qwerty\\strawberry.jpg");
stageRepository.delete(stage.getId());
Stage mustNull=stageRepository.findOne(stage.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
Stage stage = new Stage();
stage.setPathSvg("C:\\qwerty\\orange.jpg");
stage.setStageNumber(33);
stageRepository.save(stage);
Long getId = stageRepository.findOne(stage.getId()).getId();
stageRepository.delete(getId);
Stage calendaringTest=stageRepository.findOne(getId);
Assert.assertNull("It was your mistake",calendaringTest);
}
@Test
public void testGetGroupById() throws Exception {
Stage stage = new Stage();
stage.setPathSvg("C:\\qwerty\\orange.jpg");
stage.setStageNumber(33);
stageRepository.save(stage);
Stage stageTest = stageRepository.findOne(stage.getId());
String mustEquals= stageTest.getPathSvg();
Assert.assertNotNull("It was your mistake!", stageTest);
Assert.assertEquals(mustEquals,"C:\\qwerty\\orange.jpg");
stageRepository.delete(stage.getId());
Stage mustNull=stageRepository.findOne(stage.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.9 Класс TransitionTest
import org.junit.Assert;
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 ua.com.lejastu.dao.*;
import ua.com.lejastu.entity.*;
import ua.com.lejastu.repository.*;
import java.util.Date;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class TransitionTest {
@Autowired
private TransitionRepository transitionRepository;
@Autowired
private UserRepository userRepository;
@Autowired
private GroupRepository groupRepository;
@Autowired
CalendaringRepository calendaringRepository;
@Autowired
RoomRepository roomRepository;
@Test
public void testCreateGroup() throws Exception {
Transition transition = new Transition();
transition.setSpendTime(123L);
transition.setFromRoom(1L);
transition.setToRoom(9L);
transition.setIsAccessPermitted(true);
transition.setReason("OK");
transition.setTimeIn(new Date(System.currentTimeMillis()));
transition.setTimeOut(new Date(System.currentTimeMillis()));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
transition.setUserTransition(user);
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(System.currentTimeMillis()));
calendaringRepository.save(calendaring);
transition.setCalendarTrans(calendaring);
Room room = new Room();
room.setNumber(99);
room.setAccessLevel(99);
roomRepository.save(room);
transition.setRoomTrans(room);
transitionRepository.save(transition);
Long getId = transition.getId();
Transition transitionTest = transitionRepository.findOne(getId);
Long mustEquals=transitionTest.getSpendTime();
Assert.assertNotNull("It was your mistake!", transitionTest);
Assert.assertEquals((Object) mustEquals, 123L);
transitionRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
Long rD=room.getId();
roomRepository.delete(rD);
Long cD=calendaring.getId();
calendaringRepository.delete(cD);
Transition mustNull=transitionRepository.findOne(transition.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Transition transition = new Transition();
transition.setSpendTime(123L);
transition.setFromRoom(1L);
transition.setToRoom(9L);
transition.setIsAccessPermitted(true);
transition.setReason("OK");
transition.setTimeIn(new Date(System.currentTimeMillis()));
transition.setTimeOut(new Date(System.currentTimeMillis()));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
transition.setUserTransition(user);
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(System.currentTimeMillis()));
calendaringRepository.save(calendaring);
transition.setCalendarTrans(calendaring);
Room room = new Room();
room.setNumber(99);
room.setAccessLevel(99);
roomRepository.save(room);
transition.setRoomTrans(room);
transitionRepository.save(transition);
Transition transitionTest = transitionRepository.findOne(transition.getId());
transitionTest.setSpendTime(1234567L);
transitionRepository.saveAndFlush(transitionTest);
Long mustEquals= transitionTest.getSpendTime();
Assert.assertNotNull("It was your mistake!", transitionTest);
Assert.assertEquals((Object)mustEquals, 1234567L);
transitionRepository.delete(transition.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
Long rD=room.getId();
roomRepository.delete(rD);
Long cD=calendaring.getId();
calendaringRepository.delete(cD);
Transition mustNull=transitionRepository.findOne(transition.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
Transition transition = new Transition();
transition.setSpendTime(123L);
transition.setFromRoom(1L);
transition.setToRoom(9L);
transition.setIsAccessPermitted(true);
transition.setReason("OK");
transition.setTimeIn(new Date(System.currentTimeMillis()));
transition.setTimeOut(new Date(System.currentTimeMillis()));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
transition.setUserTransition(user);
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(System.currentTimeMillis()));
calendaringRepository.save(calendaring);
transition.setCalendarTrans(calendaring);
Room room = new Room();
room.setNumber(99);
room.setAccessLevel(99);
roomRepository.save(room);
transition.setRoomTrans(room);
transitionRepository.save(transition);
Long getId = transitionRepository.findOne(transition.getId()).getId();
transitionRepository.delete(getId);
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
Long rD=room.getId();
roomRepository.delete(rD);
Long cD=calendaring.getId();
calendaringRepository.delete(cD);
Transition transitionTest=transitionRepository.findOne(getId);
Assert.assertNull("It was your mistake",transitionTest);
}
@Test
public void testGetGroupById() throws Exception {
Transition transition = new Transition();
transition.setSpendTime(123L);
transition.setFromRoom(1L);
transition.setToRoom(9L);
transition.setIsAccessPermitted(true);
transition.setReason("OK");
transition.setTimeIn(new Date(System.currentTimeMillis()));
transition.setTimeOut(new Date(System.currentTimeMillis()));
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker group= new GroupWorker();
group.setGroupName("Alpha-1");
groupRepository.save(group);
user.setGroupUser(group);
userRepository.save(user);
transition.setUserTransition(user);
Calendaring calendaring = new Calendaring();
calendaring.setDate(new Date(System.currentTimeMillis()));
calendaringRepository.save(calendaring);
transition.setCalendarTrans(calendaring);
Room room = new Room();
room.setNumber(99);
room.setAccessLevel(99);
roomRepository.save(room);
transition.setRoomTrans(room);
transitionRepository.save(transition);
Transition transitionTest = transitionRepository.findOne(transition.getId());
String mustEquals= transitionTest.getReason();
Assert.assertNotNull("It was your mistake!", transitionTest);
Assert.assertEquals(mustEquals, "OK");
transitionRepository.delete(transition.getId());
Long mD= user.getId();
userRepository.delete(mD);
Long gD=group.getId();
groupRepository.delete(gD);
Long rD=room.getId();
roomRepository.delete(rD);
Long cD=calendaring.getId();
calendaringRepository.delete(cD);
Transition mustNull=transitionRepository.findOne(transition.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.10 Класс UserTest
import org.junit.Assert;
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 ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.dao.UserDao;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.entity.User;
import ua.com.lejastu.repository.GroupRepository;
import ua.com.lejastu.repository.UserRepository;
import java.util.Date;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class UserTest {
@Autowired
private UserRepository userRepository;
@Autowired
private GroupRepository groupRepository;
@Test
public void testCreateGroup() throws Exception {
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
user.setGroupUser(groupWorker);
userRepository.save(user);
Long getId = user.getId();
User userTest = userRepository.findOne(getId);
String mustEquals=userTest.getFirstName();
Assert.assertNotNull("It was your mistake!", userTest);
Assert.assertEquals(mustEquals,"Maria-Jose");
userRepository.delete(getId);
Long mD= groupWorker.getId();
groupRepository.delete(mD);
User mustNull=userRepository.findOne(user.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
user.setGroupUser(groupWorker);
userRepository.save(user);
User userTest = userRepository.findOne(user.getId());
userTest.setLastName("Compuiternaia");
userRepository.saveAndFlush(userTest);
String mustEquals= userTest.getLastName();
Assert.assertNotNull("It was your mistake!", userTest);
Assert.assertEquals(mustEquals, "Compuiternaia");
userRepository.delete(user.getId());
Long mD= groupWorker.getId();
groupRepository.delete(mD);
User mustNull=userRepository.findOne(user.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testDeleteGroup() throws Exception {
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
user.setGroupUser(groupWorker);
userRepository.save(user);
Long getId = userRepository.findOne(user.getId()).getId();
userRepository.delete(getId);
Long mD= groupWorker.getId();
groupRepository.delete(mD);
User groupWorkerTest=userRepository.findOne(getId);
Assert.assertNull("It was your mistake",groupWorkerTest);
}
@Test
public void testGetGroupById() throws Exception {
User user = new User();
user.setFirstName("Maria-Jose");
user.setLastName("Ivanova");
user.setBirthDay(new Date(System.currentTimeMillis()));
user.setJob("Programmer");
user.setSalary(1234567890L);
user.setAddress("Kiev,Frunze street, 124, 12");
user.setPhone("03456789");
user.setPassportData("CM-56789");
user.setPhoto("C:\\dir\\photo\\mji.jpg");
user.setDepartmentName("Alpha-1");
user.setObligedSpendTime(123456L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
user.setGroupUser(groupWorker);
userRepository.save(user);
User userTest = userRepository.findOne(user.getId());
String mustEquals= userTest.getLastName();
Assert.assertNotNull("It was your mistake!", userTest);
Assert.assertEquals(mustEquals, "Ivanova");
userRepository.delete(user.getId());
Long mD= groupWorker.getId();
groupRepository.delete(mD);
User mustNull=userRepository.findOne(user.getId());
Assert.assertNull("It was your mistake", mustNull);
}
}
3.11 Класс WorkbenchTest
import org.junit.Assert;
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 ua.com.lejastu.dao.GroupDao;
import ua.com.lejastu.dao.WorkbenchDao;
import ua.com.lejastu.entity.GroupWorker;
import ua.com.lejastu.entity.Workbench;
import ua.com.lejastu.repository.GroupRepository;
import ua.com.lejastu.repository.WorkbenchRepository;
/**
* User: LejaStu
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public class WorkbenchTest {
@Autowired
private WorkbenchRepository workbenchRepository;
@Autowired
private GroupRepository groupRepository;
@Test
public void testCreateGroup() throws Exception {
Workbench workbench = new Workbench();
workbench.setWorkBenchNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
workbench.setGroupWorkbench(groupWorker);
workbenchRepository.save(workbench);
Long getId = workbench.getId();
Workbench workbenchTest = workbenchRepository.findOne(getId);
Long mustEquals=workbenchTest.getWorkBenchNumber();
Assert.assertNotNull("It was your mistake!", workbenchTest);
Assert.assertEquals((Object) mustEquals, 123L);
workbenchRepository.delete(getId);
Long mD= groupWorker.getId();
groupRepository.delete(mD);
Workbench mustNull=workbenchRepository.findOne(workbench.getId());
Assert.assertNull("It was your mistake", mustNull);
}
@Test
public void testUpdateGroup() throws Exception {
Workbench workbench = new Workbench();
workbench.setWorkBenchNumber(123L);
GroupWorker groupWorker = new GroupWorker();
groupWorker.setGroupName("Banjo Men");
groupRepository.save(groupWorker);
workbench.setGroupWorkbench(groupWorker);
Подобные документы
Особенности решения задачи контроля и управления посещением охраняемого объекта. Создание системы как совокупности программных и технических средств. Классификация систем контроля и управления доступом. Основные устройства системы и их характеристика.
презентация [677,7 K], добавлен 03.12.2014Организационные основы защиты информации на предприятии. Общие принципы построения систем контроля и управления доступом. Виды запирающих устройств. Аппаратура и материалы, методика и порядок выполнения работы. Базовое программное обеспечение проекта.
дипломная работа [4,7 M], добавлен 30.06.2011Анализ существующих систем контроля и управления доступом различных фирм-производителей. Анализ технических и эксплуатационных характеристик различных систем, разработка системы контроля и управления доступом. Предложение плана реализации системы.
дипломная работа [2,7 M], добавлен 07.06.2011Проведение анализа в области идентификации личности по биометрическим параметрам. Формирование массива данных из исходной информации для подсистемы контроля управления доступом с аутентификацией по речевому сигналу. Способ проверки подлинности голоса.
курсовая работа [3,1 M], добавлен 29.08.2015Назначение, классификация и состав системы контроля управления доступом. Основные характеристики биометрических средств идентификации личности. Идентификация пользователя по радужной оболочке глаз. Разработка алгоритма функционирования устройства.
дипломная работа [1,1 M], добавлен 25.11.2014Технологии управления доступом в помещение. Организационно-управленческая характеристика ООО "Новые информационные технологии". Анализ системы технического и программного обеспечения. Разработка проекта системы контроля и управления доступом "Кодос".
дипломная работа [71,6 K], добавлен 16.01.2014Организационные основы защиты информации на предприятии. Общие принципы построения систем контроля и управления доступом. Характеристика объекта, текущего оборудования и программного обеспечения. Классификация воздушных и воздушно-тепловых завес.
дипломная работа [5,7 M], добавлен 13.04.2014Автономные, сетевые и интегрированные контроллеры - интеллектуальный элемент системы контроля управления доступом. Управление локальными, централизованными и распределенными СКУД. Характеристика iSecure Pro как самостоятельной микропроцессорной системы.
реферат [2,6 M], добавлен 23.01.2011Понятие, назначение, задачи и классификация системы контроля и управления доступом, ее основные компоненты. Сравнительный анализ деятельности производителей данных систем: Legos, Parsec, PERCo. Выбор архитектуры системы, оборудование и его размещение.
дипломная работа [7,7 M], добавлен 07.06.2014Описание возможностей системы контроля и управления доступом, область ее деятельности и нормативная база использования, принципы функционирования. Обзор российского рынка, тенденции и перспективы его дальнейшего расширения. Этапы разработки и внедрения.
курсовая работа [1,8 M], добавлен 15.01.2015