Revert "[SECIOTSRK-409] Tests coverage, some classes have been refactored"
authorYevhen Zozulia <y.zozulia@surc.local>
Mon, 21 Aug 2017 16:32:06 +0000 (19:32 +0300)
committerYevhen Zozulia <y.zozulia@surc.local>
Mon, 21 Aug 2017 16:32:06 +0000 (19:32 +0300)
This reverts commit c538aa4a3d8511711ad8cd6b041577bbce74e287.

127 files changed:
servermq/logs/server_mq.log [deleted file]
servermq/src/test/resources/spring-database.xml
servers/commons/src/main/java/com/samsung/commons/domain/IotCloudUser.java
servers/commons/src/main/java/com/samsung/commons/domain/Policy.java
servers/commons/src/main/java/com/samsung/commons/domain/Role.java
servers/commons/src/main/java/com/samsung/commons/domain/User.java
servers/commons/src/main/java/com/samsung/commons/model/Notification.java
servers/commons/src/main/java/com/samsung/commons/repository/ReportRepository.java
servers/commons/src/main/java/com/samsung/commons/repository/UserRepository.java
servers/commons/src/main/java/com/samsung/commons/service/AgentService.java
servers/commons/src/main/java/com/samsung/commons/service/CommonCrudService.java [deleted file]
servers/commons/src/main/java/com/samsung/commons/service/DeviceService.java
servers/commons/src/main/java/com/samsung/commons/service/IotCloudService.java
servers/commons/src/main/java/com/samsung/commons/service/PolicyService.java
servers/commons/src/main/java/com/samsung/commons/service/ReportService.java
servers/commons/src/main/java/com/samsung/commons/service/ReportTypeService.java
servers/commons/src/main/java/com/samsung/commons/service/RoleService.java
servers/commons/src/main/java/com/samsung/commons/service/UserSelfRemoveException.java [deleted file]
servers/commons/src/main/java/com/samsung/commons/service/UserService.java
servers/commons/src/main/java/com/samsung/commons/service/impl/AgentServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/DeviceServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/IotCloudServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/PolicyServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/ReportServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/ReportTypeServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/RoleServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/UserDetailsServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/service/impl/UserServiceImpl.java
servers/commons/src/main/java/com/samsung/commons/utils/UrlBuilder.java [deleted file]
servers/commons/src/main/java/com/samsung/commons/utils/Utils.java
servers/commons/src/main/resources/sql/init.sql [new file with mode: 0644]
servers/commons/src/test/java/com/samsung/commons/UtilsTest.java
servers/commons/src/test/java/com/samsung/commons/domain/user/UserTest.java
servers/commons/src/test/java/com/samsung/commons/model/NotificationTest.java [deleted file]
servers/commons/src/test/java/com/samsung/commons/repository/AgentRepositoryTest.java
servers/commons/src/test/java/com/samsung/commons/repository/DeviceRepositoryTest.java
servers/commons/src/test/java/com/samsung/commons/repository/RoleRepositoryTest.java
servers/commons/src/test/java/com/samsung/commons/repository/UserRepositoryTest.java
servers/commons/src/test/java/com/samsung/commons/service/AgentServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/CommonCrudServiceTest.java [deleted file]
servers/commons/src/test/java/com/samsung/commons/service/DeviceServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/IoTCloudServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/PolicyServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/ReportServiceTest.java [deleted file]
servers/commons/src/test/java/com/samsung/commons/service/ReportTypeServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/RoleServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/UserDetailsServiceTest.java
servers/commons/src/test/java/com/samsung/commons/service/UserServiceTest.java
servers/commons/src/test/java/com/samsung/commons/utils/UrlBuilderTest.java [deleted file]
servers/commons/src/test/resources/spring-database.xml
servers/configuration/amazon/commons/serverMQService.sh
servers/configuration/srk/commons/serverMQService.sh
servers/dsm/configuration/amazon/log4j.properties
servers/dsm/configuration/develop/log4j.properties
servers/dsm/configuration/srk/log4j.properties
servers/dsm/src/main/java/com/samsung/dsm/controller/AccountController.java
servers/dsm/src/main/java/com/samsung/dsm/controller/AdminController.java
servers/dsm/src/main/java/com/samsung/dsm/controller/DashboardController.java
servers/dsm/src/main/java/com/samsung/dsm/controller/DashboardDevicesController.java
servers/dsm/src/main/java/com/samsung/dsm/controller/HomeController.java
servers/dsm/src/main/java/com/samsung/dsm/domain/oauth/OAuthCode.java
servers/dsm/src/main/java/com/samsung/dsm/exception/PolicyException.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/jdbc/JdbcDriverUnregisteringListener.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/model/request/ResetPassword.java
servers/dsm/src/main/java/com/samsung/dsm/model/restapi/converter/DomainToRestConverter.java
servers/dsm/src/main/java/com/samsung/dsm/policy/parser/PolicyParserFactory.java
servers/dsm/src/main/java/com/samsung/dsm/report/analyzer/ReportAnalyzerKeys.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/report/analyzer/impl/MACReportAnalyzer.java
servers/dsm/src/main/java/com/samsung/dsm/rest/accesstoken/AccessTokenApi.java
servers/dsm/src/main/java/com/samsung/dsm/rest/device/AgentIsNull.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesNotFound.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesOwnerNotFound.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/rest/device/UserNotFound.java [new file with mode: 0644]
servers/dsm/src/main/java/com/samsung/dsm/rest/iotcloud/IotCloudAssociatedUserNotExists.java
servers/dsm/src/main/java/com/samsung/dsm/rest/mq/MQSenderImpl.java
servers/dsm/src/main/java/com/samsung/dsm/rest/policy/PolicyApi.java
servers/dsm/src/main/java/com/samsung/dsm/rest/report/ReportApi.java
servers/dsm/src/main/java/com/samsung/dsm/service/GrantedApplicationService.java
servers/dsm/src/main/java/com/samsung/dsm/service/impl/AccessTokenServiceImpl.java
servers/dsm/src/main/java/com/samsung/dsm/service/impl/GrantedApplicationServiceImpl.java
servers/dsm/src/main/java/com/samsung/dsm/service/impl/OAuth2AuthorizationServiceImpl.java
servers/dsm/src/main/resources/root-context.xml
servers/dsm/src/main/resources/spring-database.xml
servers/dsm/src/main/resources/spring-security.xml
servers/dsm/src/main/webapp/WEB-INF/web.xml
servers/dsm/src/test/java/com/samsung/dsm/controller/AccountControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/controller/AdminControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/controller/DashboardControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/controller/DashboardDevicesControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/controller/HomeControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/controller/UserControllerTest.java
servers/dsm/src/test/java/com/samsung/dsm/domain/oauth/OAuthCodeTest.java
servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestAgentTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestDeviceTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/AgentConverterTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DeviceConverterTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DomainToRestConverterTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/policy/parser/PolicyParserFactoryTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/report/ReportConfigTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/rest/AccessTokenApiTest.java
servers/dsm/src/test/java/com/samsung/dsm/rest/DeviceApiTest.java
servers/dsm/src/test/java/com/samsung/dsm/rest/IotCloudApiTest.java
servers/dsm/src/test/java/com/samsung/dsm/rest/PolicyApiTest.java
servers/dsm/src/test/java/com/samsung/dsm/rest/ReportApiTest.java
servers/dsm/src/test/java/com/samsung/dsm/rest/mq/MQSenderImplMock.java
servers/dsm/src/test/java/com/samsung/dsm/rest/mq/MQSenderTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/service/AccessTokenServiceTest.java
servers/dsm/src/test/java/com/samsung/dsm/service/GrantedApplicationServiceTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/service/impl/AccessTokenServiceImplTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/service/impl/GrantedApplicationServiceImplTest.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/service/impl/OAuth2AuthorizationServiceTest.java
servers/dsm/src/test/java/com/samsung/dsm/utils/CloudUserBuilder.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/utils/UserBuilder.java [deleted file]
servers/dsm/src/test/java/com/samsung/dsm/utils/UtilsTest.java [deleted file]
servers/dsm/src/test/resources/root-context.xml
servers/dsm/src/test/resources/spring-database.xml
servers/dsm/src/test/resources/spring-security.xml
servers/mq/src/main/java/com/samsung/servermq/iotivity/extractor/impl/DeviceRegistrationPostDataExtractor.java
servers/mq/src/main/java/com/samsung/servermq/iotivity/extractor/impl/DeviceUnRegistrationPostDataExtractor.java
servers/mq/src/main/java/com/samsung/servermq/iotivity/extractor/impl/ReportPostDataExtractor.java
servers/mq/src/main/java/com/samsung/servermq/utils/Utils.java [moved from servers/dsm/src/main/java/com/samsung/dsm/utils/Utils.java with 59% similarity]
servers/mq/src/test/java/com/samsung/servermq/iotivity/extractor/impl/DeviceRegistrationPostDataExtractorTest.java
servers/mq/src/test/java/com/samsung/servermq/iotivity/extractor/impl/DeviceUnRegistrationPostDataExtractorTest.java
servers/mq/src/test/java/com/samsung/servermq/iotivity/extractor/impl/PolicyPostDataExtractorTest.java
servers/mq/src/test/java/com/samsung/servermq/iotivity/extractor/impl/ReportPostDataExtractorTest.java
servers/mq/src/test/java/com/samsung/servermq/rest/DSMRestControllerTest.java
servers/mq/src/test/resources/spring-database.xml

diff --git a/servermq/logs/server_mq.log b/servermq/logs/server_mq.log
deleted file mode 100644 (file)
index 4c4273e..0000000
+++ /dev/null
@@ -1,1673 +0,0 @@
-2017-08-15 13:26:01.800  INFO 11658 --- [main] com.samsung.servermq.ServerMQ            : Starting ServerMQ on a with PID 11658 (/home/a-motchanyi/work/projects/2017/iotswsec/servermq/target/classes started by a-motchanyi in /home/a-motchanyi/work/projects/2017/iotswsec/servermq)
-2017-08-15 13:26:01.803 DEBUG 11658 --- [main] com.samsung.servermq.ServerMQ            : Running with Spring Boot v1.5.4.RELEASE, Spring v4.3.8.RELEASE
-2017-08-15 13:26:01.803  INFO 11658 --- [main] com.samsung.servermq.ServerMQ            : No active profile set, falling back to default profiles: default
-2017-08-15 13:26:01.852  INFO 11658 --- [main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@192d43ce: startup date [Tue Aug 15 13:26:01 EEST 2017]; root of context hierarchy
-2017-08-15 13:26:02.346  INFO 11658 --- [main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [root-context.xml]
-2017-08-15 13:26:02.483  INFO 11658 --- [main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [iotivity.xml]
-2017-08-15 13:26:02.525  INFO 11658 --- [main] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [spring-database.xml]
-2017-08-15 13:26:02.810  INFO 11658 --- [main] o.s.i.config.IntegrationRegistrar        : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
-2017-08-15 13:26:02.824  INFO 11658 --- [main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'org.springframework.transaction.config.internalTransactionAdvisor' with a different definition: replacing [Root bean: class [org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration; factoryMethodName=transactionAdvisor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class]]
-2017-08-15 13:26:02.825  INFO 11658 --- [main] a.ConfigurationClassBeanDefinitionReader : Skipping bean definition for [BeanMethod:name=transactionalEventListenerFactory,declaringClass=org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration]: a definition for bean 'org.springframework.transaction.config.internalTransactionalEventListenerFactory' already exists. This top-level bean definition is considered as an override.
-2017-08-15 13:26:03.115  INFO 11658 --- [main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
-2017-08-15 13:26:03.118  INFO 11658 --- [main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
-2017-08-15 13:26:03.322  INFO 11658 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8637b590] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
-2017-08-15 13:26:03.390  INFO 11658 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [org.springframework.beans.factory.config.PropertiesFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
-2017-08-15 13:26:03.392  INFO 11658 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [java.util.Properties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
-2017-08-15 13:26:03.750  INFO 11658 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8888 (http)
-2017-08-15 13:26:03.769  INFO 11658 --- [main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
-2017-08-15 13:26:03.770  INFO 11658 --- [main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
-2017-08-15 13:26:03.896  INFO 11658 --- [localhost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
-2017-08-15 13:26:03.897  INFO 11658 --- [localhost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2046 ms
-2017-08-15 13:26:04.026  INFO 11658 --- [localhost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
-2017-08-15 13:26:04.030  INFO 11658 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
-2017-08-15 13:26:04.031  INFO 11658 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
-2017-08-15 13:26:04.031  INFO 11658 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
-2017-08-15 13:26:04.032  INFO 11658 --- [localhost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
-2017-08-15 13:26:04.087  INFO 11658 --- [MLog-Init-Reporter] com.mchange.v2.log.MLog                  : MLog clients using slf4j logging.
-2017-08-15 13:26:04.113  INFO 11658 --- [main] com.mchange.v2.c3p0.C3P0Registry         : Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
-2017-08-15 13:26:04.234  INFO 11658 --- [main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
-2017-08-15 13:26:04.249  INFO 11658 --- [main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
-       name: default
-       ...]
-2017-08-15 13:26:04.321  INFO 11658 --- [main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.10.Final}
-2017-08-15 13:26:04.323  INFO 11658 --- [main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
-2017-08-15 13:26:04.458  INFO 11658 --- [main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
-2017-08-15 13:26:04.564  INFO 11658 --- [main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL82Dialect
-2017-08-15 13:26:04.576  INFO 11658 --- [main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000422: Disabling contextual LOB creation as connection was null
-2017-08-15 13:26:04.577  INFO 11658 --- [main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@2819c460
-2017-08-15 13:26:05.103  INFO 11658 --- [main] c.m.v.c.i.AbstractPoolBackedDataSource   : Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kfsx9p1rnp8ln50dr9y|3fa76c61, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> z8kfsx9p1rnp8ln50dr9y|3fa76c61, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:postgresql://127.0.0.1:5432/secDB, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 5, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 2, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
-2017-08-15 13:26:07.528  INFO 11658 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
-2017-08-15 13:26:07.546 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueuePublisher     : Create Message Queue Publisher
-2017-08-15 13:26:07.808  INFO 11658 --- [main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
-2017-08-15 13:26:08.053 DEBUG 11658 --- [main] c.s.s.utils.rest.ServerSenderImpl        : Server host: http://127.0.0.1:8080
-2017-08-15 13:26:08.066 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Created Report Listener
-2017-08-15 13:26:08.075  INFO 11658 --- [ZkClient-EventThread-22-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.081  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
-2017-08-15 13:26:08.081  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:host.name=a.motchanyi-pc
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.version=1.8.0_111
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.vendor=Oracle Corporation
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.class.path=/home/a-motchanyi/work/projects/2017/iotswsec/servermq/target/classes:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot/1.5.4.RELEASE/spring-boot-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.4.RELEASE/spring-boot-autoconfigure-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/a-motchanyi/.m2/repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/home/a-motchanyi/.m2/repository/org/springframework/security/spring-security-taglibs/3.2.10.RELEASE/spring-security-taglibs-3.2.10.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/security/spring-security-acl/4.2.3.RELEASE/spring-security-acl-4.2.3.RELEASE.jar:/home/a-motchanyi/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/a-motchanyi/.m2/repository/org/springframework/security/spring-security-core/4.2.3.RELEASE/spring-security-core-4.2.3.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/security/spring-security-web/4.2.3.RELEASE/spring-security-web-4.2.3.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-aop/4.3.9.RELEASE/spring-aop-4.3.9.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-beans/4.3.9.RELEASE/spring-beans-4.3.9.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.4.RELEASE/spring-boot-starter-web-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.4.RELEASE/spring-boot-starter-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.4.RELEASE/spring-boot-starter-logging-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/home/a-motchanyi/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/home/a-motchanyi/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/home/a-motchanyi/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.25/log4j-over-slf4j-1.7.25.jar:/home/a-motchanyi/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/home/a-motchanyi/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.4.RELEASE/spring-boot-starter-tomcat-1.5.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.15/tomcat-embed-core-8.5.15.jar:/home/a-motchanyi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.15/tomcat-embed-el-8.5.15.jar:/home/a-motchanyi/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.15/tomcat-embed-websocket-8.5.15.jar:/home/a-motchanyi/.m2/repository/org/hibernate/hibernate-validator/5.3.5.Final/hibernate-validator-5.3.5.Final.jar:/home/a-motchanyi/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/home/a-motchanyi/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.8/jackson-databind-2.8.8.jar:/home/a-motchanyi/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/home/a-motchanyi/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.8/jackson-core-2.8.8.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-webmvc/4.3.9.RELEASE/spring-webmvc-4.3.9.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-core/4.3.8.RELEASE/spring-core-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-context/4.3.8.RELEASE/spring-context-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/integration/spring-integration-jmx/4.3.8.RELEASE/spring-integration-jmx-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/integration/spring-integration-core/4.3.10.RELEASE/spring-integration-core-4.3.10.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-messaging/4.3.9.RELEASE/spring-messaging-4.3.9.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/retry/spring-retry/1.2.0.RELEASE/spring-retry-1.2.0.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-web/4.3.8.RELEASE/spring-web-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-tx/4.3.8.RELEASE/spring-tx-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/data/spring-data-jpa/1.11.4.RELEASE/spring-data-jpa-1.11.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/aspectj/aspectjrt/1.8.10/aspectjrt-1.8.10.jar:/home/a-motchanyi/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/home/a-motchanyi/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-expression/4.3.8.RELEASE/spring-expression-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-orm/4.3.8.RELEASE/spring-orm-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-jdbc/4.3.9.RELEASE/spring-jdbc-4.3.9.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar:/home/a-motchanyi/.m2/repository/org/hibernate/hibernate-core/5.2.10.Final/hibernate-core-5.2.10.Final.jar:/home/a-motchanyi/.m2/repository/org/jboss/logging/jboss-logging/3.3.1.Final/jboss-logging-3.3.1.Final.jar:/home/a-motchanyi/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/home/a-motchanyi/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/home/a-motchanyi/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/home/a-motchanyi/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.1.Final/jboss-transaction-api_1.2_spec-1.0.1.Final.jar:/home/a-motchanyi/.m2/repository/org/jboss/jandex/2.0.3.Final/jandex-2.0.3.Final.jar:/home/a-motchanyi/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/home/a-motchanyi/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/a-motchanyi/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/home/a-motchanyi/.m2/repository/org/hibernate/hibernate-entitymanager/5.2.10.Final/hibernate-entitymanager-5.2.10.Final.jar:/home/a-motchanyi/.m2/repository/net/bytebuddy/byte-buddy/1.6.6/byte-buddy-1.6.6.jar:/home/a-motchanyi/.m2/repository/org/hibernate/hibernate-c3p0/5.2.10.Final/hibernate-c3p0-5.2.10.Final.jar:/home/a-motchanyi/.m2/repository/com/mchange/c3p0/0.9.5.2/c3p0-0.9.5.2.jar:/home/a-motchanyi/.m2/repository/com/mchange/mchange-commons-java/0.2.11/mchange-commons-java-0.2.11.jar:/home/a-motchanyi/.m2/repository/org/hibernate/hibernate-jpamodelgen/1.2.0.Final/hibernate-jpamodelgen-1.2.0.Final.jar:/home/a-motchanyi/.m2/repository/org/springframework/data/spring-data-commons/1.13.4.RELEASE/spring-data-commons-1.13.4.RELEASE.jar:/home/a-motchanyi/.m2/repository/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar:/home/a-motchanyi/.m2/repository/org/iotivity/cloud/CloudMessageQueue/0.0.1-SNAPSHOT/CloudMessageQueue-0.0.1-SNAPSHOT.jar:/home/a-motchanyi/.m2/repository/org/iotivity/cloud/CloudStack/0.0.1-SNAPSHOT/CloudStack-0.0.1-SNAPSHOT.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.4.3/maven-resources-plugin-2.4.3.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-profile/2.0.6/maven-profile-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-artifact-manager/2.0.6/maven-artifact-manager-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-plugin-registry/2.0.6/maven-plugin-registry-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-core/2.0.6/maven-core-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-file/1.0-beta-2/wagon-file-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-plugin-parameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/1.0-beta-2/wagon-http-lightweight-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-http-shared/1.0-beta-2/wagon-http-shared-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar:/home/a-motchanyi/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-provider-api/1.0-beta-2/wagon-provider-api-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-repository-metadata/2.0.6/maven-repository-metadata-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-error-diagnostics/2.0.6/maven-error-diagnostics-2.0.6.jar:/home/a-motchanyi/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-ssh-external/1.0-beta-2/wagon-ssh-external-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-ssh-common/1.0-beta-2/wagon-ssh-common-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-plugin-descriptor/2.0.6/maven-plugin-descriptor-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/wagon/wagon-ssh/1.0-beta-2/wagon-ssh-1.0-beta-2.jar:/home/a-motchanyi/.m2/repository/com/jcraft/jsch/0.1.27/jsch-0.1.27.jar:/home/a-motchanyi/.m2/repository/classworlds/classworlds/1.1/classworlds-1.1.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-artifact/2.0.6/maven-artifact-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-settings/2.0.6/maven-settings-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-model/2.0.6/maven-model-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-monitor/2.0.6/maven-monitor-2.0.6.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/shared/maven-filtering/1.0-beta-4/maven-filtering-1.0-beta-4.jar:/home/a-motchanyi/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/plexus-build-api-0.0.4.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.13/plexus-interpolation-1.13.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/maven-toolchain/1.0/maven-toolchain-1.0.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.1/maven-shared-utils-0.1.jar:/home/a-motchanyi/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar:/home/a-motchanyi/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.2/plexus-compiler-api-2.2.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.2/plexus-compiler-manager-2.2.jar:/home/a-motchanyi/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar:/home/a-motchanyi/.m2/repository/io/netty/netty-all/4.1.1.Final/netty-all-4.1.1.Final.jar:/home/a-motchanyi/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/a-motchanyi/.m2/repository/org/json/json/20140107/json-20140107.jar:/home/a-motchanyi/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.8.8/jackson-dataformat-cbor-2.8.8.jar:/home/a-motchanyi/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/home/a-motchanyi/.m2/repository/javax/websocket/javax.websocket-client-api/1.0/javax.websocket-client-api-1.0.jar:/home/a-motchanyi/.m2/repository/org/glassfish/tyrus/tyrus-client/1.1/tyrus-client-1.1.jar:/home/a-motchanyi/.m2/repository/org/glassfish/tyrus/tyrus-core/1.1/tyrus-core-1.1.jar:/home/a-motchanyi/.m2/repository/org/glassfish/tyrus/tyrus-spi/1.1/tyrus-spi-1.1.jar:/home/a-motchanyi/.m2/repository/javax/websocket/javax.websocket-api/1.0/javax.websocket-api-1.0.jar:/home/a-motchanyi/.m2/repository/org/glassfish/tyrus/tyrus-websocket-core/1.1/tyrus-websocket-core-1.1.jar:/home/a-motchanyi/.m2/repository/org/glassfish/tyrus/tyrus-container-grizzly/1.1/tyrus-container-grizzly-1.1.jar:/home/a-motchanyi/.m2/repository/org/glassfish/grizzly/grizzly-framework/2.3.3/grizzly-framework-2.3.3.jar:/home/a-motchanyi/.m2/repository/org/glassfish/grizzly/grizzly-http-server/2.3.3/grizzly-http-server-2.3.3.jar:/home/a-motchanyi/.m2/repository/org/glassfish/grizzly/grizzly-http/2.3.3/grizzly-http-2.3.3.jar:/home/a-motchanyi/.m2/repository/org/glassfish/grizzly/grizzly-rcm/2.3.3/grizzly-rcm-2.3.3.jar:/home/a-motchanyi/.m2/repository/javax/json/javax.json-api/1.0/javax.json-api-1.0.jar:/home/a-motchanyi/.m2/repository/org/glassfish/javax.json/1.0.1/javax.json-1.0.1.jar:/home/a-motchanyi/.m2/repository/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar:/home/a-motchanyi/.m2/repository/org/apache/kafka/kafka_2.11/0.9.0.0/kafka_2.11-0.9.0.0.jar:/home/a-motchanyi/.m2/repository/com/101tec/zkclient/0.7/zkclient-0.7.jar:/home/a-motchanyi/.m2/repository/com/yammer/metrics/metrics-core/2.2.0/metrics-core-2.2.0.jar:/home/a-motchanyi/.m2/repository/org/scala-lang/modules/scala-xml_2.11/1.0.4/scala-xml_2.11-1.0.4.jar:/home/a-motchanyi/.m2/repository/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar:/home/a-motchanyi/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar:/home/a-motchanyi/.m2/repository/org/apache/kafka/kafka-clients/0.9.0.0/kafka-clients-0.9.0.0.jar:/home/a-motchanyi/.m2/repository/org/xerial/snappy/snappy-java/1.1.1.7/snappy-java-1.1.1.7.jar:/home/a-motchanyi/.m2/repository/net/jpountz/lz4/lz4/1.2.0/lz4-1.2.0.jar:/home/a-motchanyi/.m2/repository/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar:/home/a-motchanyi/.m2/repository/org/apache/zookeeper/zookeeper/3.4.6/zookeeper-3.4.6.jar:/home/a-motchanyi/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar:/home/a-motchanyi/.m2/repository/io/netty/netty/3.7.0.Final/netty-3.7.0.Final.jar:/home/a-motchanyi/.m2/repository/com/jayway/awaitility/awaitility/1.7.0/awaitility-1.7.0.jar:/home/a-motchanyi/.m2/repository/cglib/cglib-nodep/3.1/cglib-nodep-3.1.jar:/home/a-motchanyi/.m2/repository/org/springframework/spring-test/4.3.8.RELEASE/spring-test-4.3.8.RELEASE.jar:/home/a-motchanyi/.m2/repository/com/h2database/h2/1.4.187/h2-1.4.187.jar
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
-2017-08-15 13:26:08.082  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.io.tmpdir=/tmp
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:java.compiler=<NA>
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:os.name=Linux
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:os.arch=amd64
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:os.version=3.13.0-128-generic
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:user.name=a-motchanyi
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:user.home=/home/a-motchanyi
-2017-08-15 13:26:08.083  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Client environment:user.dir=/home/a-motchanyi/work/projects/2017/iotswsec/servermq
-2017-08-15 13:26:08.084  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@5d66ae3a
-2017-08-15 13:26:08.111  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.130  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.142  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.149  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f1, negotiated timeout = 10000
-2017-08-15 13:26:08.151  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.331  INFO 11658 --- [main] o.a.k.clients.producer.ProducerConfig    : ProducerConfig values: 
-       compression.type = none
-       metric.reporters = []
-       metadata.max.age.ms = 300000
-       metadata.fetch.timeout.ms = 60000
-       reconnect.backoff.ms = 50
-       sasl.kerberos.ticket.renew.window.factor = 0.8
-       bootstrap.servers = [106.125.46.44:9092]
-       retry.backoff.ms = 100
-       sasl.kerberos.kinit.cmd = /usr/bin/kinit
-       buffer.memory = 33554432
-       timeout.ms = 30000
-       key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       sasl.kerberos.service.name = null
-       sasl.kerberos.ticket.renew.jitter = 0.05
-       ssl.keystore.type = JKS
-       ssl.trustmanager.algorithm = PKIX
-       block.on.buffer.full = false
-       ssl.key.password = null
-       max.block.ms = 60000
-       sasl.kerberos.min.time.before.relogin = 60000
-       connections.max.idle.ms = 540000
-       ssl.truststore.password = null
-       max.in.flight.requests.per.connection = 5
-       metrics.num.samples = 2
-       client.id = 
-       ssl.endpoint.identification.algorithm = null
-       ssl.protocol = TLS
-       request.timeout.ms = 30000
-       ssl.provider = null
-       ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
-       acks = all
-       batch.size = 16384
-       ssl.keystore.location = null
-       receive.buffer.bytes = 32768
-       ssl.cipher.suites = null
-       ssl.truststore.type = JKS
-       security.protocol = PLAINTEXT
-       retries = 0
-       max.request.size = 1048576
-       value.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       ssl.truststore.location = null
-       ssl.keystore.password = null
-       ssl.keymanager.algorithm = SunX509
-       metrics.sample.window.ms = 30000
-       partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
-       send.buffer.bytes = 131072
-       linger.ms = 1
-
-2017-08-15 13:26:08.377  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 0.9.0.0
-2017-08-15 13:26:08.377  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : fc7243c2af4b2b4a
-2017-08-15 13:26:08.379  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@7afbf2a0
-2017-08-15 13:26:08.379  INFO 11658 --- [ZkClient-EventThread-26-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.379  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.379  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.380  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.383  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f2, negotiated timeout = 10000
-2017-08-15 13:26:08.384  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.401  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@3b57f915
-2017-08-15 13:26:08.401  INFO 11658 --- [ZkClient-EventThread-29-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.402  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.403  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.402  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.406  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f3, negotiated timeout = 10000
-2017-08-15 13:26:08.406  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.515  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:08.517  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property auto.commit.interval.ms is overridden to 6000
-2017-08-15 13:26:08.518  WARN 11658 --- [main] kafka.utils.VerifiableProperties         : Property enable.auto.commit is not valid
-2017-08-15 13:26:08.518  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property group.id is overridden to .oic.ps.srv.report
-2017-08-15 13:26:08.518  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property zookeeper.connect is overridden to 106.125.46.44:2181
-2017-08-15 13:26:08.549  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Connecting to zookeeper instance at 106.125.46.44:2181
-2017-08-15 13:26:08.551  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@473847fb
-2017-08-15 13:26:08.551  INFO 11658 --- [ZkClient-EventThread-35-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.551  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.554  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.554  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.558  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f4, negotiated timeout = 6000
-2017-08-15 13:26:08.558  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.565  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], starting auto committer every 6000 ms
-2017-08-15 13:26:08.586  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], begin registering consumer .oic.ps.srv.report_a-1502792768548-dac48c09 in ZK
-2017-08-15 13:26:08.614  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Creating /consumers/.oic.ps.srv.report/ids/.oic.ps.srv.report_a-1502792768548-dac48c09 (is it secure? false)
-2017-08-15 13:26:08.621  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Result of znode creation is: OK
-2017-08-15 13:26:08.622  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], end registering consumer .oic.ps.srv.report_a-1502792768548-dac48c09 in ZK
-2017-08-15 13:26:08.626  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09_watcher_executor] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], starting watcher executor thread for consumer .oic.ps.srv.report_a-1502792768548-dac48c09
-2017-08-15 13:26:08.641  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], begin rebalancing consumer .oic.ps.srv.report_a-1502792768548-dac48c09 try #0
-2017-08-15 13:26:08.753  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768562] Stopping leader finder thread
-2017-08-15 13:26:08.753  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768562] Stopping all fetchers
-2017-08-15 13:26:08.754  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768562] All connections stopped
-2017-08-15 13:26:08.755  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:08.756  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:08.757  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:08.758  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Releasing partition ownership
-2017-08-15 13:26:08.794  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : Consumer .oic.ps.srv.report_a-1502792768548-dac48c09 rebalancing the following partitions: ArrayBuffer(0) for topic .oic.ps.srv.report with consumers: List(.oic.ps.srv.report_a-1502792768548-dac48c09-0, .oic.ps.srv.report_sdas0088-1502785507542-3b0ee870-0)
-2017-08-15 13:26:08.797  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : .oic.ps.srv.report_a-1502792768548-dac48c09-0 attempting to claim partition 0
-2017-08-15 13:26:08.799  WARN 11658 --- [main] kafka.consumer.RangeAssignor             : No broker partitions consumed by consumer thread .oic.ps.srv.report_sdas0088-1502785507542-3b0ee870-0 for topic .oic.ps.srv.report
-2017-08-15 13:26:08.830  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], .oic.ps.srv.report_a-1502792768548-dac48c09-0 successfully owned partition 0 for topic .oic.ps.srv.report
-2017-08-15 13:26:08.851  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], Consumer .oic.ps.srv.report_a-1502792768548-dac48c09 selected partitions : .oic.ps.srv.report:0: fetched offset = 1: consumed offset = 1
-2017-08-15 13:26:08.855  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.report_a-1502792768548-dac48c09], end rebalancing consumer .oic.ps.srv.report_a-1502792768548-dac48c09 try #0
-2017-08-15 13:26:08.856  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] onsumerFetcherManager$LeaderFinderThread : [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread], Starting 
-2017-08-15 13:26:08.859 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribe complete
-2017-08-15 13:26:08.860 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribeTopic - .oic.ps.srv.report
-2017-08-15 13:26:08.860 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Report Listener waiting messages.......................
-2017-08-15 13:26:08.871 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Created Policy Listener
-2017-08-15 13:26:08.871  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@2976ca51
-2017-08-15 13:26:08.872  INFO 11658 --- [ZkClient-EventThread-42-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.872  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.873  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.873  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.876  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f5, negotiated timeout = 10000
-2017-08-15 13:26:08.876  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.877  INFO 11658 --- [main] o.a.k.clients.producer.ProducerConfig    : ProducerConfig values: 
-       compression.type = none
-       metric.reporters = []
-       metadata.max.age.ms = 300000
-       metadata.fetch.timeout.ms = 60000
-       reconnect.backoff.ms = 50
-       sasl.kerberos.ticket.renew.window.factor = 0.8
-       bootstrap.servers = [106.125.46.44:9092]
-       retry.backoff.ms = 100
-       sasl.kerberos.kinit.cmd = /usr/bin/kinit
-       buffer.memory = 33554432
-       timeout.ms = 30000
-       key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       sasl.kerberos.service.name = null
-       sasl.kerberos.ticket.renew.jitter = 0.05
-       ssl.keystore.type = JKS
-       ssl.trustmanager.algorithm = PKIX
-       block.on.buffer.full = false
-       ssl.key.password = null
-       max.block.ms = 60000
-       sasl.kerberos.min.time.before.relogin = 60000
-       connections.max.idle.ms = 540000
-       ssl.truststore.password = null
-       max.in.flight.requests.per.connection = 5
-       metrics.num.samples = 2
-       client.id = 
-       ssl.endpoint.identification.algorithm = null
-       ssl.protocol = TLS
-       request.timeout.ms = 30000
-       ssl.provider = null
-       ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
-       acks = all
-       batch.size = 16384
-       ssl.keystore.location = null
-       receive.buffer.bytes = 32768
-       ssl.cipher.suites = null
-       ssl.truststore.type = JKS
-       security.protocol = PLAINTEXT
-       retries = 0
-       max.request.size = 1048576
-       value.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       ssl.truststore.location = null
-       ssl.keystore.password = null
-       ssl.keymanager.algorithm = SunX509
-       metrics.sample.window.ms = 30000
-       partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
-       send.buffer.bytes = 131072
-       linger.ms = 1
-
-2017-08-15 13:26:08.878  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:08.878  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.utils.VerifiableProperties         : Property client.id is overridden to .oic.ps.srv.report
-2017-08-15 13:26:08.879  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.utils.VerifiableProperties         : Property metadata.broker.list is overridden to sdas0054.surc.local:9092
-2017-08-15 13:26:08.879  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.utils.VerifiableProperties         : Property request.timeout.ms is overridden to 30000
-2017-08-15 13:26:08.881  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 0.9.0.0
-2017-08-15 13:26:08.881  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : fc7243c2af4b2b4a
-2017-08-15 13:26:08.882  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@69a90b81
-2017-08-15 13:26:08.882  INFO 11658 --- [ZkClient-EventThread-46-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.882  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.882  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.883  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.886  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f6, negotiated timeout = 10000
-2017-08-15 13:26:08.887  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.888  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@6dcbbb49
-2017-08-15 13:26:08.888  INFO 11658 --- [ZkClient-EventThread-49-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.888  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.889  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.889  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.892  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f7, negotiated timeout = 10000
-2017-08-15 13:26:08.896  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.896  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.client.ClientUtils$                : Fetching metadata from broker BrokerEndPoint(0,sdas0054.surc.local,9092) with correlation id 0 for 1 topic(s) Set(.oic.ps.srv.report)
-2017-08-15 13:26:08.899  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.producer.SyncProducer              : Connected to sdas0054.surc.local:9092 for producing
-2017-08-15 13:26:08.904  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:08.904  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property auto.commit.interval.ms is overridden to 6000
-2017-08-15 13:26:08.904  WARN 11658 --- [main] kafka.utils.VerifiableProperties         : Property enable.auto.commit is not valid
-2017-08-15 13:26:08.905  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property group.id is overridden to .oic.ps.srv.policy
-2017-08-15 13:26:08.905  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property zookeeper.connect is overridden to 106.125.46.44:2181
-2017-08-15 13:26:08.906  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Connecting to zookeeper instance at 106.125.46.44:2181
-2017-08-15 13:26:08.907  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@36c783ca
-2017-08-15 13:26:08.907  INFO 11658 --- [ZkClient-EventThread-52-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:08.907  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:08.909  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:08.910  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:08.912  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f8, negotiated timeout = 6000
-2017-08-15 13:26:08.913  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:08.914  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], starting auto committer every 6000 ms
-2017-08-15 13:26:08.915  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], begin registering consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 in ZK
-2017-08-15 13:26:08.915  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Creating /consumers/.oic.ps.srv.policy/ids/.oic.ps.srv.policy_a-1502792768906-d69ce853 (is it secure? false)
-2017-08-15 13:26:09.105  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Result of znode creation is: OK
-2017-08-15 13:26:09.105  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], end registering consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 in ZK
-2017-08-15 13:26:09.111  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.producer.SyncProducer              : Disconnecting from sdas0054.surc.local:9092
-2017-08-15 13:26:09.113  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853_watcher_executor] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], starting watcher executor thread for consumer .oic.ps.srv.policy_a-1502792768906-d69ce853
-2017-08-15 13:26:09.115  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], begin rebalancing consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 try #0
-2017-08-15 13:26:09.132  INFO 11658 --- [ConsumerFetcherThread-.oic.ps.srv.report_a-1502792768548-dac48c09-0-0] kafka.consumer.ConsumerFetcherThread     : [ConsumerFetcherThread-.oic.ps.srv.report_a-1502792768548-dac48c09-0-0], Starting 
-2017-08-15 13:26:09.135  INFO 11658 --- [.oic.ps.srv.report_a-1502792768548-dac48c09-leader-finder-thread] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768562] Added fetcher for partitions ArrayBuffer([[.oic.ps.srv.report,0], initOffset 1 to broker BrokerEndPoint(0,sdas0054.surc.local,9092)] )
-2017-08-15 13:26:09.141  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768913] Stopping leader finder thread
-2017-08-15 13:26:09.141  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768913] Stopping all fetchers
-2017-08-15 13:26:09.141  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768913] All connections stopped
-2017-08-15 13:26:09.141  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:09.141  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:09.142  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:09.142  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Releasing partition ownership
-2017-08-15 13:26:09.159  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : Consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 rebalancing the following partitions: ArrayBuffer(0) for topic .oic.ps.srv.policy with consumers: List(.oic.ps.srv.policy_a-1502792768906-d69ce853-0, .oic.ps.srv.policy_sdas0088-1502785508172-a03fe0a9-0)
-2017-08-15 13:26:09.159  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : .oic.ps.srv.policy_a-1502792768906-d69ce853-0 attempting to claim partition 0
-2017-08-15 13:26:09.160  WARN 11658 --- [main] kafka.consumer.RangeAssignor             : No broker partitions consumed by consumer thread .oic.ps.srv.policy_sdas0088-1502785508172-a03fe0a9-0 for topic .oic.ps.srv.policy
-2017-08-15 13:26:09.164  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], .oic.ps.srv.policy_a-1502792768906-d69ce853-0 successfully owned partition 0 for topic .oic.ps.srv.policy
-2017-08-15 13:26:09.170  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], Consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 selected partitions : .oic.ps.srv.policy:0: fetched offset = 7: consumed offset = 7
-2017-08-15 13:26:09.171  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.policy_a-1502792768906-d69ce853], end rebalancing consumer .oic.ps.srv.policy_a-1502792768906-d69ce853 try #0
-2017-08-15 13:26:09.171  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] onsumerFetcherManager$LeaderFinderThread : [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread], Starting 
-2017-08-15 13:26:09.172 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribe complete
-2017-08-15 13:26:09.172 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribeTopic - .oic.ps.srv.policy
-2017-08-15 13:26:09.173 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Policy Listener waiting messages.......................
-2017-08-15 13:26:09.175 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Created Device Registretion Listener
-2017-08-15 13:26:09.176  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@3041beb3
-2017-08-15 13:26:09.177  INFO 11658 --- [ZkClient-EventThread-60-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.177  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.178  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.178  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:09.178  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.179  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.utils.VerifiableProperties         : Property client.id is overridden to .oic.ps.srv.policy
-2017-08-15 13:26:09.179  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.utils.VerifiableProperties         : Property metadata.broker.list is overridden to sdas0054.surc.local:9092
-2017-08-15 13:26:09.179  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.utils.VerifiableProperties         : Property request.timeout.ms is overridden to 30000
-2017-08-15 13:26:09.180  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.client.ClientUtils$                : Fetching metadata from broker BrokerEndPoint(0,sdas0054.surc.local,9092) with correlation id 0 for 1 topic(s) Set(.oic.ps.srv.policy)
-2017-08-15 13:26:09.181  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.producer.SyncProducer              : Connected to sdas0054.surc.local:9092 for producing
-2017-08-15 13:26:09.182  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600f9, negotiated timeout = 10000
-2017-08-15 13:26:09.183  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.183  INFO 11658 --- [main] o.a.k.clients.producer.ProducerConfig    : ProducerConfig values: 
-       compression.type = none
-       metric.reporters = []
-       metadata.max.age.ms = 300000
-       metadata.fetch.timeout.ms = 60000
-       reconnect.backoff.ms = 50
-       sasl.kerberos.ticket.renew.window.factor = 0.8
-       bootstrap.servers = [106.125.46.44:9092]
-       retry.backoff.ms = 100
-       sasl.kerberos.kinit.cmd = /usr/bin/kinit
-       buffer.memory = 33554432
-       timeout.ms = 30000
-       key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       sasl.kerberos.service.name = null
-       sasl.kerberos.ticket.renew.jitter = 0.05
-       ssl.keystore.type = JKS
-       ssl.trustmanager.algorithm = PKIX
-       block.on.buffer.full = false
-       ssl.key.password = null
-       max.block.ms = 60000
-       sasl.kerberos.min.time.before.relogin = 60000
-       connections.max.idle.ms = 540000
-       ssl.truststore.password = null
-       max.in.flight.requests.per.connection = 5
-       metrics.num.samples = 2
-       client.id = 
-       ssl.endpoint.identification.algorithm = null
-       ssl.protocol = TLS
-       request.timeout.ms = 30000
-       ssl.provider = null
-       ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
-       acks = all
-       batch.size = 16384
-       ssl.keystore.location = null
-       receive.buffer.bytes = 32768
-       ssl.cipher.suites = null
-       ssl.truststore.type = JKS
-       security.protocol = PLAINTEXT
-       retries = 0
-       max.request.size = 1048576
-       value.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       ssl.truststore.location = null
-       ssl.keystore.password = null
-       ssl.keymanager.algorithm = SunX509
-       metrics.sample.window.ms = 30000
-       partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
-       send.buffer.bytes = 131072
-       linger.ms = 1
-
-2017-08-15 13:26:09.183  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.producer.SyncProducer              : Disconnecting from sdas0054.surc.local:9092
-2017-08-15 13:26:09.186  INFO 11658 --- [.oic.ps.srv.policy_a-1502792768906-d69ce853-leader-finder-thread] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792768913] Added fetcher for partitions ArrayBuffer([[.oic.ps.srv.policy,0], initOffset 7 to broker BrokerEndPoint(0,sdas0054.surc.local,9092)] )
-2017-08-15 13:26:09.186  INFO 11658 --- [ConsumerFetcherThread-.oic.ps.srv.policy_a-1502792768906-d69ce853-0-0] kafka.consumer.ConsumerFetcherThread     : [ConsumerFetcherThread-.oic.ps.srv.policy_a-1502792768906-d69ce853-0-0], Starting 
-2017-08-15 13:26:09.187  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 0.9.0.0
-2017-08-15 13:26:09.187  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : fc7243c2af4b2b4a
-2017-08-15 13:26:09.188  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@14dbfdb1
-2017-08-15 13:26:09.188  INFO 11658 --- [ZkClient-EventThread-65-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.188  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.189  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.189  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.192  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600fa, negotiated timeout = 10000
-2017-08-15 13:26:09.192  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.193  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@7856f41a
-2017-08-15 13:26:09.193  INFO 11658 --- [ZkClient-EventThread-68-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.193  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.194  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.194  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.197  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600fb, negotiated timeout = 10000
-2017-08-15 13:26:09.197  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.203  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:09.203  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property auto.commit.interval.ms is overridden to 6000
-2017-08-15 13:26:09.204  WARN 11658 --- [main] kafka.utils.VerifiableProperties         : Property enable.auto.commit is not valid
-2017-08-15 13:26:09.204  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property group.id is overridden to .oic.ps.srv.reg
-2017-08-15 13:26:09.204  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property zookeeper.connect is overridden to 106.125.46.44:2181
-2017-08-15 13:26:09.205  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Connecting to zookeeper instance at 106.125.46.44:2181
-2017-08-15 13:26:09.206  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@2c08c787
-2017-08-15 13:26:09.207  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.208  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.208  INFO 11658 --- [ZkClient-EventThread-71-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.209  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.212  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600fc, negotiated timeout = 6000
-2017-08-15 13:26:09.212  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.213  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], starting auto committer every 6000 ms
-2017-08-15 13:26:09.216  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], begin registering consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 in ZK
-2017-08-15 13:26:09.217  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Creating /consumers/.oic.ps.srv.reg/ids/.oic.ps.srv.reg_a-1502792769205-e97a48f1 (is it secure? false)
-2017-08-15 13:26:09.222  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Result of znode creation is: OK
-2017-08-15 13:26:09.222  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], end registering consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 in ZK
-2017-08-15 13:26:09.224  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1_watcher_executor] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], starting watcher executor thread for consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1
-2017-08-15 13:26:09.227  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], begin rebalancing consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 try #0
-2017-08-15 13:26:09.243  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769213] Stopping leader finder thread
-2017-08-15 13:26:09.243  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769213] Stopping all fetchers
-2017-08-15 13:26:09.243  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769213] All connections stopped
-2017-08-15 13:26:09.244  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:09.244  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:09.244  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:09.244  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Releasing partition ownership
-2017-08-15 13:26:09.268  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : Consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 rebalancing the following partitions: ArrayBuffer(0) for topic .oic.ps.srv.reg with consumers: List(.oic.ps.srv.reg_a-1502792769205-e97a48f1-0, .oic.ps.srv.reg_sdas0088-1502785508361-f1a3d232-0)
-2017-08-15 13:26:09.269  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : .oic.ps.srv.reg_a-1502792769205-e97a48f1-0 attempting to claim partition 0
-2017-08-15 13:26:09.269  WARN 11658 --- [main] kafka.consumer.RangeAssignor             : No broker partitions consumed by consumer thread .oic.ps.srv.reg_sdas0088-1502785508361-f1a3d232-0 for topic .oic.ps.srv.reg
-2017-08-15 13:26:09.273  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], .oic.ps.srv.reg_a-1502792769205-e97a48f1-0 successfully owned partition 0 for topic .oic.ps.srv.reg
-2017-08-15 13:26:09.274  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], Consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 selected partitions : .oic.ps.srv.reg:0: fetched offset = 9: consumed offset = 9
-2017-08-15 13:26:09.274  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.reg_a-1502792769205-e97a48f1], end rebalancing consumer .oic.ps.srv.reg_a-1502792769205-e97a48f1 try #0
-2017-08-15 13:26:09.275  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] onsumerFetcherManager$LeaderFinderThread : [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread], Starting 
-2017-08-15 13:26:09.275 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribe complete
-2017-08-15 13:26:09.276 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribeTopic - .oic.ps.srv.reg
-2017-08-15 13:26:09.276 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener waiting messages.......................
-2017-08-15 13:26:09.279 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Created Device UnRegistretion Listener
-2017-08-15 13:26:09.279  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@7c956dda
-2017-08-15 13:26:09.280  INFO 11658 --- [ZkClient-EventThread-78-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.282  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:09.282  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.utils.VerifiableProperties         : Property client.id is overridden to .oic.ps.srv.reg
-2017-08-15 13:26:09.282  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.utils.VerifiableProperties         : Property metadata.broker.list is overridden to sdas0054.surc.local:9092
-2017-08-15 13:26:09.282  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.utils.VerifiableProperties         : Property request.timeout.ms is overridden to 30000
-2017-08-15 13:26:09.282  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.283  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.284  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.284  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.client.ClientUtils$                : Fetching metadata from broker BrokerEndPoint(0,sdas0054.surc.local,9092) with correlation id 0 for 1 topic(s) Set(.oic.ps.srv.reg)
-2017-08-15 13:26:09.284  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.producer.SyncProducer              : Connected to sdas0054.surc.local:9092 for producing
-2017-08-15 13:26:09.286  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.producer.SyncProducer              : Disconnecting from sdas0054.surc.local:9092
-2017-08-15 13:26:09.287  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600fd, negotiated timeout = 10000
-2017-08-15 13:26:09.287  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.287  INFO 11658 --- [main] o.a.k.clients.producer.ProducerConfig    : ProducerConfig values: 
-       compression.type = none
-       metric.reporters = []
-       metadata.max.age.ms = 300000
-       metadata.fetch.timeout.ms = 60000
-       reconnect.backoff.ms = 50
-       sasl.kerberos.ticket.renew.window.factor = 0.8
-       bootstrap.servers = [106.125.46.44:9092]
-       retry.backoff.ms = 100
-       sasl.kerberos.kinit.cmd = /usr/bin/kinit
-       buffer.memory = 33554432
-       timeout.ms = 30000
-       key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       sasl.kerberos.service.name = null
-       sasl.kerberos.ticket.renew.jitter = 0.05
-       ssl.keystore.type = JKS
-       ssl.trustmanager.algorithm = PKIX
-       block.on.buffer.full = false
-       ssl.key.password = null
-       max.block.ms = 60000
-       sasl.kerberos.min.time.before.relogin = 60000
-       connections.max.idle.ms = 540000
-       ssl.truststore.password = null
-       max.in.flight.requests.per.connection = 5
-       metrics.num.samples = 2
-       client.id = 
-       ssl.endpoint.identification.algorithm = null
-       ssl.protocol = TLS
-       request.timeout.ms = 30000
-       ssl.provider = null
-       ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
-       acks = all
-       batch.size = 16384
-       ssl.keystore.location = null
-       receive.buffer.bytes = 32768
-       ssl.cipher.suites = null
-       ssl.truststore.type = JKS
-       security.protocol = PLAINTEXT
-       retries = 0
-       max.request.size = 1048576
-       value.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
-       ssl.truststore.location = null
-       ssl.keystore.password = null
-       ssl.keymanager.algorithm = SunX509
-       metrics.sample.window.ms = 30000
-       partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
-       send.buffer.bytes = 131072
-       linger.ms = 1
-
-2017-08-15 13:26:09.288  INFO 11658 --- [.oic.ps.srv.reg_a-1502792769205-e97a48f1-leader-finder-thread] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769213] Added fetcher for partitions ArrayBuffer([[.oic.ps.srv.reg,0], initOffset 9 to broker BrokerEndPoint(0,sdas0054.surc.local,9092)] )
-2017-08-15 13:26:09.288  INFO 11658 --- [ConsumerFetcherThread-.oic.ps.srv.reg_a-1502792769205-e97a48f1-0-0] kafka.consumer.ConsumerFetcherThread     : [ConsumerFetcherThread-.oic.ps.srv.reg_a-1502792769205-e97a48f1-0-0], Starting 
-2017-08-15 13:26:09.292  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 0.9.0.0
-2017-08-15 13:26:09.292  INFO 11658 --- [main] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : fc7243c2af4b2b4a
-2017-08-15 13:26:09.292  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@6591f8ea
-2017-08-15 13:26:09.292  INFO 11658 --- [ZkClient-EventThread-83-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.292  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.293  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.293  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.296  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600fe, negotiated timeout = 10000
-2017-08-15 13:26:09.296  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.296  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=10000 watcher=org.I0Itec.zkclient.ZkClient@5273143e
-2017-08-15 13:26:09.296  INFO 11658 --- [ZkClient-EventThread-86-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.297  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.297  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.298  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.301  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d600ff, negotiated timeout = 10000
-2017-08-15 13:26:09.301  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.311  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:09.311  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property auto.commit.interval.ms is overridden to 6000
-2017-08-15 13:26:09.311  WARN 11658 --- [main] kafka.utils.VerifiableProperties         : Property enable.auto.commit is not valid
-2017-08-15 13:26:09.311  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property group.id is overridden to .oic.ps.srv.unreg
-2017-08-15 13:26:09.312  INFO 11658 --- [main] kafka.utils.VerifiableProperties         : Property zookeeper.connect is overridden to 106.125.46.44:2181
-2017-08-15 13:26:09.312  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Connecting to zookeeper instance at 106.125.46.44:2181
-2017-08-15 13:26:09.313  INFO 11658 --- [main] org.apache.zookeeper.ZooKeeper           : Initiating client connection, connectString=106.125.46.44:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@334b392d
-2017-08-15 13:26:09.313  INFO 11658 --- [ZkClient-EventThread-89-106.125.46.44:2181] org.I0Itec.zkclient.ZkEventThread        : Starting ZkClient event thread.
-2017-08-15 13:26:09.324  INFO 11658 --- [main] org.I0Itec.zkclient.ZkClient             : Waiting for keeper state SyncConnected
-2017-08-15 13:26:09.324  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Opening socket connection to server 106.125.46.44/106.125.46.44:2181. Will not attempt to authenticate using SASL (unknown error)
-2017-08-15 13:26:09.325  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Socket connection established to 106.125.46.44/106.125.46.44:2181, initiating session
-2017-08-15 13:26:09.327  INFO 11658 --- [main-SendThread(106.125.46.44:2181)] org.apache.zookeeper.ClientCnxn          : Session establishment complete on server 106.125.46.44/106.125.46.44:2181, sessionid = 0x15de4e1f4d60100, negotiated timeout = 6000
-2017-08-15 13:26:09.328  INFO 11658 --- [main-EventThread] org.I0Itec.zkclient.ZkClient             : zookeeper state changed (SyncConnected)
-2017-08-15 13:26:09.328  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], starting auto committer every 6000 ms
-2017-08-15 13:26:09.329  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], begin registering consumer .oic.ps.srv.unreg_a-1502792769312-d569816d in ZK
-2017-08-15 13:26:09.330  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Creating /consumers/.oic.ps.srv.unreg/ids/.oic.ps.srv.unreg_a-1502792769312-d569816d (is it secure? false)
-2017-08-15 13:26:09.335  INFO 11658 --- [main] kafka.utils.ZKCheckedEphemeral           : Result of znode creation is: OK
-2017-08-15 13:26:09.335  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], end registering consumer .oic.ps.srv.unreg_a-1502792769312-d569816d in ZK
-2017-08-15 13:26:09.337  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d_watcher_executor] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], starting watcher executor thread for consumer .oic.ps.srv.unreg_a-1502792769312-d569816d
-2017-08-15 13:26:09.339  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], begin rebalancing consumer .oic.ps.srv.unreg_a-1502792769312-d569816d try #0
-2017-08-15 13:26:09.352  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping leader finder thread
-2017-08-15 13:26:09.353  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping all fetchers
-2017-08-15 13:26:09.353  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] All connections stopped
-2017-08-15 13:26:09.353  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:09.353  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:09.353  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:09.353  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Releasing partition ownership
-2017-08-15 13:26:09.365  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : Consumer .oic.ps.srv.unreg_a-1502792769312-d569816d rebalancing the following partitions: ArrayBuffer(0) for topic .oic.ps.srv.unreg with consumers: List(.oic.ps.srv.unreg_a-1502792769312-d569816d-0, .oic.ps.srv.unreg_sdas0088-1502785508505-55763d6a-0)
-2017-08-15 13:26:09.365  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : .oic.ps.srv.unreg_a-1502792769312-d569816d-0 attempting to claim partition 0
-2017-08-15 13:26:09.365  WARN 11658 --- [main] kafka.consumer.RangeAssignor             : No broker partitions consumed by consumer thread .oic.ps.srv.unreg_sdas0088-1502785508505-55763d6a-0 for topic .oic.ps.srv.unreg
-2017-08-15 13:26:09.374  INFO 11658 --- [main] kafka.utils.ZkUtils                      : conflict in /consumers/.oic.ps.srv.unreg/owners/.oic.ps.srv.unreg/0 data: .oic.ps.srv.unreg_a-1502792769312-d569816d-0 stored data: .oic.ps.srv.unreg_sdas0088-1502785508505-55763d6a-0
-2017-08-15 13:26:09.375  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], waiting for the partition ownership to be deleted: 0
-2017-08-15 13:26:09.375  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], end rebalancing consumer .oic.ps.srv.unreg_a-1502792769312-d569816d try #0
-2017-08-15 13:26:09.375  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Rebalancing attempt failed. Clearing the cache before the next rebalancing operation is triggered
-2017-08-15 13:26:09.376  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping leader finder thread
-2017-08-15 13:26:09.376  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping all fetchers
-2017-08-15 13:26:09.376  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] All connections stopped
-2017-08-15 13:26:09.377  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:09.377  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:09.377  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:11.377  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], begin rebalancing consumer .oic.ps.srv.unreg_a-1502792769312-d569816d try #1
-2017-08-15 13:26:11.389  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping leader finder thread
-2017-08-15 13:26:11.389  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Stopping all fetchers
-2017-08-15 13:26:11.390  INFO 11658 --- [main] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] All connections stopped
-2017-08-15 13:26:11.390  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared all relevant queues for this fetcher
-2017-08-15 13:26:11.390  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Cleared the data chunks in all the consumer message iterators
-2017-08-15 13:26:11.390  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Committing all offsets after clearing the fetcher queues
-2017-08-15 13:26:11.390  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Releasing partition ownership
-2017-08-15 13:26:11.401  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : Consumer .oic.ps.srv.unreg_a-1502792769312-d569816d rebalancing the following partitions: ArrayBuffer(0) for topic .oic.ps.srv.unreg with consumers: List(.oic.ps.srv.unreg_a-1502792769312-d569816d-0, .oic.ps.srv.unreg_sdas0088-1502785508505-55763d6a-0)
-2017-08-15 13:26:11.402  INFO 11658 --- [main] kafka.consumer.RangeAssignor             : .oic.ps.srv.unreg_a-1502792769312-d569816d-0 attempting to claim partition 0
-2017-08-15 13:26:11.402  WARN 11658 --- [main] kafka.consumer.RangeAssignor             : No broker partitions consumed by consumer thread .oic.ps.srv.unreg_sdas0088-1502785508505-55763d6a-0 for topic .oic.ps.srv.unreg
-2017-08-15 13:26:11.408  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], .oic.ps.srv.unreg_a-1502792769312-d569816d-0 successfully owned partition 0 for topic .oic.ps.srv.unreg
-2017-08-15 13:26:11.409  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], Consumer .oic.ps.srv.unreg_a-1502792769312-d569816d selected partitions : .oic.ps.srv.unreg:0: fetched offset = 20: consumed offset = 20
-2017-08-15 13:26:11.410  INFO 11658 --- [main] k.consumer.ZookeeperConsumerConnector    : [.oic.ps.srv.unreg_a-1502792769312-d569816d], end rebalancing consumer .oic.ps.srv.unreg_a-1502792769312-d569816d try #1
-2017-08-15 13:26:11.410  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] onsumerFetcherManager$LeaderFinderThread : [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread], Starting 
-2017-08-15 13:26:11.410 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribe complete
-2017-08-15 13:26:11.410 DEBUG 11658 --- [main] c.s.s.iotivity.KafkaConsumerWrapper      : kafka subscribeTopic - .oic.ps.srv.unreg
-2017-08-15 13:26:11.411 DEBUG 11658 --- [main] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener waiting messages.......................
-2017-08-15 13:26:11.415  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.utils.VerifiableProperties         : Verifying properties
-2017-08-15 13:26:11.416  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.utils.VerifiableProperties         : Property client.id is overridden to .oic.ps.srv.unreg
-2017-08-15 13:26:11.416  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.utils.VerifiableProperties         : Property metadata.broker.list is overridden to sdas0054.surc.local:9092
-2017-08-15 13:26:11.416  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.utils.VerifiableProperties         : Property request.timeout.ms is overridden to 30000
-2017-08-15 13:26:11.417  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.client.ClientUtils$                : Fetching metadata from broker BrokerEndPoint(0,sdas0054.surc.local,9092) with correlation id 0 for 1 topic(s) Set(.oic.ps.srv.unreg)
-2017-08-15 13:26:11.418  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.producer.SyncProducer              : Connected to sdas0054.surc.local:9092 for producing
-2017-08-15 13:26:11.419  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.producer.SyncProducer              : Disconnecting from sdas0054.surc.local:9092
-2017-08-15 13:26:11.421  INFO 11658 --- [.oic.ps.srv.unreg_a-1502792769312-d569816d-leader-finder-thread] kafka.consumer.ConsumerFetcherManager    : [ConsumerFetcherManager-1502792769328] Added fetcher for partitions ArrayBuffer([[.oic.ps.srv.unreg,0], initOffset 20 to broker BrokerEndPoint(0,sdas0054.surc.local,9092)] )
-2017-08-15 13:26:11.422  INFO 11658 --- [ConsumerFetcherThread-.oic.ps.srv.unreg_a-1502792769312-d569816d-0-0] kafka.consumer.ConsumerFetcherThread     : [ConsumerFetcherThread-.oic.ps.srv.unreg_a-1502792769312-d569816d-0-0], Starting 
-2017-08-15 13:26:11.424  INFO 11658 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService  'listenerScheduler'
-2017-08-15 13:26:11.720  INFO 11658 --- [main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@192d43ce: startup date [Tue Aug 15 13:26:01 EEST 2017]; root of context hierarchy
-2017-08-15 13:26:11.799  INFO 11658 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dsmmq/notification],methods=[POST]}" onto public org.springframework.http.ResponseEntity<java.lang.Void> com.samsung.servermq.rest.DSMRestController.sendNotification(com.samsung.servermq.rest.model.Notification,org.springframework.validation.BindingResult)
-2017-08-15 13:26:11.800  INFO 11658 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/dsmmq/policy],methods=[POST]}" onto public org.springframework.http.ResponseEntity<java.lang.Void> com.samsung.servermq.rest.DSMRestController.sendPolicy(com.samsung.servermq.rest.model.MQPolicy,org.springframework.validation.BindingResult)
-2017-08-15 13:26:11.802  INFO 11658 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
-2017-08-15 13:26:11.802  INFO 11658 --- [main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
-2017-08-15 13:26:11.837  INFO 11658 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
-2017-08-15 13:26:11.837  INFO 11658 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
-2017-08-15 13:26:11.884  INFO 11658 --- [main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
-2017-08-15 13:26:12.182  INFO 11658 --- [main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService  'taskScheduler'
-2017-08-15 13:26:12.364  INFO 11658 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
-2017-08-15 13:26:12.365 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:12.365 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:12.375  INFO 11658 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'integrationMbeanExporter' has been autodetected for JMX exposure
-2017-08-15 13:26:12.377  INFO 11658 --- [main] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'integrationMbeanExporter': registering with JMX server as MBean [org.springframework.integration.monitor:name=integrationMbeanExporter,type=IntegrationMBeanExporter]
-2017-08-15 13:26:12.392 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:12.392 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Report Listener get message: ï¿½dduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127freportx�{"data":{"some_data":"report data"},"date":"Tue Aug 15 13:13:22 2017
-","did":"0cdb099f-85ea-5090-fdfe-abf6a6766127","name":"sim","result":7}�
-2017-08-15 13:26:12.431 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.ReportPostDataExtractor   : Get report data:[B@2f487ca
-2017-08-15 13:26:12.432  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Registering beans for JMX exposure on startup
-2017-08-15 13:26:12.432  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel nullChannel
-2017-08-15 13:26:12.436  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]
-2017-08-15 13:26:12.458  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel errorChannel
-2017-08-15 13:26:12.461  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel]
-2017-08-15 13:26:12.531  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageHandler errorLogger
-2017-08-15 13:26:12.532  INFO 11658 --- [main] o.s.i.monitor.IntegrationMBeanExporter   : Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal]
-2017-08-15 13:26:12.555  INFO 11658 --- [main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
-2017-08-15 13:26:12.555  INFO 11658 --- [main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
-2017-08-15 13:26:12.556  INFO 11658 --- [main] o.s.i.channel.PublishSubscribeChannel    : Channel 'application:8888.errorChannel' has 1 subscriber(s).
-2017-08-15 13:26:12.556  INFO 11658 --- [main] o.s.i.endpoint.EventDrivenConsumer       : started _org.springframework.integration.errorLogger
-2017-08-15 13:26:12.559 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.ReportPostDataExtractor   : null
-
-java.lang.NullPointerException: null
-       at com.samsung.servermq.iotivity.extractor.impl.ReportPostDataExtractor.extract(ReportPostDataExtractor.java:40)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.559 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:12.560 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:12.566 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:12.566 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612fpolicyy\ 1D[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.569 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.571 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.571 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]
-2017-08-15 13:26:12.573 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.573 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612fpolicyy\ 1D[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.576 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.578 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.578 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]
-2017-08-15 13:26:12.580 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.580 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07fpolicyy\ 1D[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.583 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.584 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.584 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]
-2017-08-15 13:26:12.587 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.587 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07fpolicyy\ 1D[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.593 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.605 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.605 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]
-2017-08-15 13:26:12.607 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.607 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07fpolicyy\ 1D[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.613 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.614 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.615 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":1,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200",""]}]}]
-2017-08-15 13:26:12.616 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.616 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07fpolicyy\ 1G[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200","",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.619 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.636 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.637 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":0,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200","",""]}]}]
-2017-08-15 13:26:12.639 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.639 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Policy Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07fpolicyy\ 1G[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200","",""]}]}]eroutex$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:12.642 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain agent information
-2017-08-15 13:26:12.643 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy with parameters: did = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.643 DEBUG 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Get policy data:[{"group":"tv-extension","policies":[{"name":"sound","state":1,"items":[]},{"name":"bluetooth","state":0,"items":[]},{"name":"wifi","state":1,"items":[]},{"name":"usb","state":1,"items":[]},{"name":"dtv-tunner","state":1,"items":[]},{"name":"iptables","state":0,"items":["tcp:192.168.0.0/24:* 192.169.0.0/24:100-200","",""]}]}]
-2017-08-15 13:26:12.645 ERROR 11658 --- [listenerScheduler-1] c.s.s.i.e.impl.PolicyPostDataExtractor   : Device with such UUID doesn't exist
-
-java.lang.Exception: Device with such UUID doesn't exist
-       at com.samsung.servermq.service.impl.PolicyServiceImpl.setDevicePolicy(PolicyServiceImpl.java:109)
-       at com.samsung.servermq.iotivity.extractor.impl.PolicyPostDataExtractor.extract(PolicyPostDataExtractor.java:46)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-
-2017-08-15 13:26:12.645 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.reg
-2017-08-15 13:26:12.646 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:12.650  INFO 11658 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8888 (http)
-2017-08-15 13:26:12.651 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:12.651 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612emodelgbig hubdnamekCentral Huberoutex$155b3b2a-575e-3bf4-afda-6ae8522e9612dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.654  INFO 11658 --- [main] com.samsung.servermq.ServerMQ            : Started ServerMQ in 11.086 seconds (JVM running for 11.494)
-2017-08-15 13:26:12.656 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 155b3b2a-575e-3bf4-afda-6ae8522e9612, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.862  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.862 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (1, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 1, null, f).
-2017-08-15 13:26:12.863  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.864 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.867 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (1, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 1, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.868 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$768afb92-17a3-8890-8ff4-3f90608dac07emodelhLED lampdnamelColored lamperoutex$768afb92-17a3-8890-8ff4-3f90608dac07dtypedlampduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.871 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 768afb92-17a3-8890-8ff4-3f90608dac07, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Colored lamp, model = LED lamp, route = 768afb92-17a3-8890-8ff4-3f90608dac07
-2017-08-15 13:26:12.890  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.890 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (2, LED lamp, Colored lamp, 1, lamp, 768afb92-17a3-8890-8ff4-3f90608dac07, 2, null, f).
-2017-08-15 13:26:12.890  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.891 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.892 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (2, LED lamp, Colored lamp, 1, lamp, 768afb92-17a3-8890-8ff4-3f90608dac07, 2, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.892 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612emodelgbig hubdnamekCentral Huberoutex$155b3b2a-575e-3bf4-afda-6ae8522e9612dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.897 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 155b3b2a-575e-3bf4-afda-6ae8522e9612, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.915  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.915 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (3, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 3, null, f).
-2017-08-15 13:26:12.915  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.916 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.917 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (3, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 3, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.918 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$71002835-fdab-d705-395e-a37e2ee854f9emodelgbig hubdnamekCentral Huberoutex$71002835-fdab-d705-395e-a37e2ee854f9dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.922 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 71002835-fdab-d705-395e-a37e2ee854f9, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 71002835-fdab-d705-395e-a37e2ee854f9
-2017-08-15 13:26:12.932  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.932 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (4, big hub, Central Hub, 1, tv, 71002835-fdab-d705-395e-a37e2ee854f9, 4, null, f).
-2017-08-15 13:26:12.932  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.933 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.934 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (4, big hub, Central Hub, 1, tv, 71002835-fdab-d705-395e-a37e2ee854f9, 4, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.934 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612emodelgbig hubdnamekCentral Huberoutex$155b3b2a-575e-3bf4-afda-6ae8522e9612dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.938 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 155b3b2a-575e-3bf4-afda-6ae8522e9612, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.948  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.949 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (5, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 5, null, f).
-2017-08-15 13:26:12.949  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.949 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.950 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (5, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 5, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.951 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612emodelgbig hubdnamekCentral Huberoutex$155b3b2a-575e-3bf4-afda-6ae8522e9612dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.955 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 155b3b2a-575e-3bf4-afda-6ae8522e9612, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.973  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.974 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (6, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 6, null, f).
-2017-08-15 13:26:12.974  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:12.975 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:12.976 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (6, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 6, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:12.976 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612emodelgbig hubdnamekCentral Huberoutex$155b3b2a-575e-3bf4-afda-6ae8522e9612dtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:12.980 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 155b3b2a-575e-3bf4-afda-6ae8522e9612, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Central Hub, model = big hub, route = 155b3b2a-575e-3bf4-afda-6ae8522e9612
-2017-08-15 13:26:12.998  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:12.999 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (7, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 7, null, f).
-2017-08-15 13:26:12.999  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:13.000 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:13.009 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (7, big hub, Central Hub, 1, tv, 155b3b2a-575e-3bf4-afda-6ae8522e9612, 7, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:13.009 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127emodeljFake modeldnamekFake devicedtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:13.013 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain route information
-2017-08-15 13:26:13.013 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 0cdb099f-85ea-5090-fdfe-abf6a6766127, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = Fake device, model = Fake model, route = null
-2017-08-15 13:26:13.034  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:13.034 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (8, Fake model, Fake device, 1, tv, 0cdb099f-85ea-5090-fdfe-abf6a6766127, 8, null, f).
-2017-08-15 13:26:13.035  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:13.035 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:13.036 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (8, Fake model, Fake device, 1, tv, 0cdb099f-85ea-5090-fdfe-abf6a6766127, 8, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:13.036 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device Registretion Listener get message: ï¿½dduidx$12345678-aabb-ccdd-eeff-000000000001emodeljtest_modeldnamektest_devicedtypebtvduuidx$2fea3c27-dc69-4c49-96b8-25a87d820c08�
-2017-08-15 13:26:13.040 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain route information
-2017-08-15 13:26:13.040 DEBUG 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : New device with params : did = 12345678-aabb-ccdd-eeff-000000000001, uid =  2fea3c27-dc69-4c49-96b8-25a87d820c08, device type = test_device, model = test_model, route = null
-2017-08-15 13:26:13.056  WARN 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 23502
-2017-08-15 13:26:13.057 ERROR 11658 --- [listenerScheduler-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (9, test_model, test_device, 1, tv, 12345678-aabb-ccdd-eeff-000000000001, 9, null, f).
-2017-08-15 13:26:13.057  INFO 11658 --- [listenerScheduler-1] o.h.e.j.b.internal.AbstractBatchImpl     : HHH000010: On release of batch it still contained JDBC statements
-2017-08-15 13:26:13.057 ERROR 11658 --- [listenerScheduler-1] o.h.i.ExceptionMapperStandardImpl        : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]
-2017-08-15 13:26:13.059 ERROR 11658 --- [listenerScheduler-1] .e.i.DeviceRegistrationPostDataExtractor : could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-
-org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [user_id]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:278)
-       at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
-       at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:504)
-       at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:292)
-       at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
-       at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
-       at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
-       at com.sun.proxy.$Proxy91.save(Unknown Source)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.save(DeviceServiceImpl.java:55)
-       at com.samsung.servermq.service.impl.DeviceServiceImpl.init(DeviceServiceImpl.java:118)
-       at com.samsung.servermq.iotivity.extractor.impl.DeviceRegistrationPostDataExtractor.extract(DeviceRegistrationPostDataExtractor.java:39)
-       at com.samsung.servermq.iotivity.MessageQueueListener.getMessages(MessageQueueListener.java:48)
-       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
-       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-       at java.lang.reflect.Method.invoke(Method.java:498)
-       at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
-       at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
-       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-       at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
-       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
-       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
-       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
-       at java.lang.Thread.run(Thread.java:745)
-Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
-       at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)
-       at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
-       at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
-       at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:45)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3003)
-       at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3503)
-       at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:89)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:589)
-       at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463)
-       at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
-       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
-       at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
-       at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
-       at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
-       at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
-       at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
-       at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
-       at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
-       at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
-       ... 33 common frames omitted
-Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
-  Detail: Failing row contains (9, test_model, test_device, 1, tv, 12345678-aabb-ccdd-eeff-000000000001, 9, null, f).
-       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
-       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
-       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
-       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
-       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
-       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
-       at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
-       at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)
-       at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:205)
-       ... 51 common frames omitted
-
-2017-08-15 13:26:13.060 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.unreg
-2017-08-15 13:26:13.060 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:13.065 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:13.065 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$768afb92-17a3-8890-8ff4-3f90608dac07�
-2017-08-15 13:26:13.069 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [768afb92-17a3-8890-8ff4-3f90608dac07] : null with action = delete
-2017-08-15 13:26:13.069  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.069 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$768afb92-17a3-8890-8ff4-3f90608dac07�
-2017-08-15 13:26:13.072 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [768afb92-17a3-8890-8ff4-3f90608dac07] : null with action = unregister
-2017-08-15 13:26:13.072  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.072 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.074 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = delete
-2017-08-15 13:26:13.075  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.075 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.077 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = unregister
-2017-08-15 13:26:13.077  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.077 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.080 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = delete
-2017-08-15 13:26:13.080  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.080 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.082 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = unregister
-2017-08-15 13:26:13.082  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.082 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$71002835-fdab-d705-395e-a37e2ee854f9�
-2017-08-15 13:26:13.085 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [71002835-fdab-d705-395e-a37e2ee854f9] : null with action = delete
-2017-08-15 13:26:13.085  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.085 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.088 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = delete
-2017-08-15 13:26:13.088  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.088 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.090 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = unregister
-2017-08-15 13:26:13.090  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.090 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.093 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = delete
-2017-08-15 13:26:13.093  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.093 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.095 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = unregister
-2017-08-15 13:26:13.095  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.095 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionfdeletedduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.098 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = delete
-2017-08-15 13:26:13.098  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.098 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$155b3b2a-575e-3bf4-afda-6ae8522e9612�
-2017-08-15 13:26:13.100 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [155b3b2a-575e-3bf4-afda-6ae8522e9612] : null with action = unregister
-2017-08-15 13:26:13.100  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.100 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127�
-2017-08-15 13:26:13.103 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [0cdb099f-85ea-5090-fdfe-abf6a6766127] : null with action = unregister
-2017-08-15 13:26:13.103  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.103 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½dduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127�
-2017-08-15 13:26:13.104 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain action information
-2017-08-15 13:26:13.105 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [0cdb099f-85ea-5090-fdfe-abf6a6766127] : null with action = null
-2017-08-15 13:26:13.105  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.106 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127�
-2017-08-15 13:26:13.107 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [0cdb099f-85ea-5090-fdfe-abf6a6766127] : null with action = unregister
-2017-08-15 13:26:13.107  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.108 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½factionjunregisterdduidx$0cdb099f-85ea-5090-fdfe-abf6a6766127�
-2017-08-15 13:26:13.109 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [0cdb099f-85ea-5090-fdfe-abf6a6766127] : null with action = unregister
-2017-08-15 13:26:13.109  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.109 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½dduidx$12345678-aabb-ccdd-eeff-000000000001�
-2017-08-15 13:26:13.110 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain action information
-2017-08-15 13:26:13.112 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [12345678-aabb-ccdd-eeff-000000000001] : null with action = null
-2017-08-15 13:26:13.112  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.112 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½dduidx$12345678-aabb-ccdd-eeff-000000000001�
-2017-08-15 13:26:13.113 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain action information
-2017-08-15 13:26:13.114 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [12345678-aabb-ccdd-eeff-000000000001] : null with action = null
-2017-08-15 13:26:13.115  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:13.115 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.MessageQueueListener      : Device UnRegistretion Listener get message: ï¿½dduidx$12345678-aabb-ccdd-eeff-000000000001�
-2017-08-15 13:26:13.116 ERROR 11658 --- [listenerScheduler-1] c.s.servermq.utils.MessageQueueUtils     : payload doesn't contain action information
-2017-08-15 13:26:13.120 DEBUG 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistere device [12345678-aabb-ccdd-eeff-000000000001] : null with action = null
-2017-08-15 13:26:13.121  INFO 11658 --- [listenerScheduler-1] .i.DeviceUnRegistrationPostDataExtractor : Unregistered device: null
-2017-08-15 13:26:17.560 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:17.560 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:17.562 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:17.646 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:17.646 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:17.647 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:18.060 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.reg
-2017-08-15 13:26:18.060 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:18.062 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:18.121 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.unreg
-2017-08-15 13:26:18.123 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:18.125 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:22.563 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:22.563 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:22.565 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:22.647 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:22.648 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:22.650 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:23.063 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.reg
-2017-08-15 13:26:23.063 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:23.065 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:23.126 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.unreg
-2017-08-15 13:26:23.126 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:23.129 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:27.566 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:27.566 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:27.569 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:27.650 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:27.651 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:27.653 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:28.065 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.reg
-2017-08-15 13:26:28.066 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:28.068 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:28.130 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.unreg
-2017-08-15 13:26:28.130 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:28.132 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:32.569 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:32.570 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:32.572 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:32.653 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:32.654 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:32.656 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:33.068 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.reg
-2017-08-15 13:26:33.068 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:33.070 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:33.133 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.unreg
-2017-08-15 13:26:33.133 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:33.135 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:37.573 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.report
-2017-08-15 13:26:37.573 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:37.575 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:37.656 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages - .oic.ps.srv.policy
-2017-08-15 13:26:37.656 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : host 106.125.46.44, port 9092
-2017-08-15 13:26:37.659 DEBUG 11658 --- [listenerScheduler-1] c.s.s.iotivity.KafkaConsumerWrapper      : kafka get all messages complete
-2017-08-15 13:26:37.914  INFO 11658 --- [Thread-24] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@192d43ce: startup date [Tue Aug 15 13:26:01 EEST 2017]; root of context hierarchy
-2017-08-15 13:26:37.915  INFO 11658 --- [Thread-24] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
-2017-08-15 13:26:37.916  INFO 11658 --- [Thread-24] o.s.i.endpoint.EventDrivenConsumer       : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
-2017-08-15 13:26:37.917  INFO 11658 --- [Thread-24] o.s.i.channel.PublishSubscribeChannel    : Channel 'application:8888.errorChannel' has 0 subscriber(s).
-2017-08-15 13:26:37.917  INFO 11658 --- [Thread-24] o.s.i.endpoint.EventDrivenConsumer       : stopped _org.springframework.integration.errorLogger
-2017-08-15 13:26:37.917  INFO 11658 --- [Thread-24] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
-2017-08-15 13:26:37.918  INFO 11658 --- [Thread-24] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans on shutdown
-2017-08-15 13:26:37.918  INFO 11658 --- [Thread-24] o.s.i.monitor.IntegrationMBeanExporter   : Unregistering JMX-exposed beans
-2017-08-15 13:26:37.919  INFO 11658 --- [Thread-24] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: nullChannel
-2017-08-15 13:26:37.919  INFO 11658 --- [Thread-24] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: errorChannel
-2017-08-15 13:26:37.919  INFO 11658 --- [Thread-24] o.s.i.monitor.IntegrationMBeanExporter   : Summary on shutdown: _org.springframework.integration.errorLogger.handler
-2017-08-15 13:26:37.919  INFO 11658 --- [Thread-24] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
-2017-08-15 13:26:37.919  INFO 11658 --- [Thread-24] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans
-2017-08-15 13:26:37.920  INFO 11658 --- [Thread-24] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'listenerScheduler'
-2017-08-15 13:26:37.923  INFO 11658 --- [Thread-24] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
index bcca761..e3475c9 100644 (file)
@@ -35,7 +35,7 @@
         <property name="jpaProperties">
             <props>
                 <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
-                <prop key="hibernate.show_sql">true</prop>
+                <prop key="hibernate.show_sql">false</prop>
                 <prop key="hibernate.hbm2ddl.auto">create</prop>
                 <prop key="hibernate.hbm2ddl.import_files">sql/init.sql</prop>
             </props>
index 31390c1..619a974 100644 (file)
@@ -32,7 +32,7 @@ public class IotCloudUser implements Serializable {
     @Column(unique = true)
     private String uuid;
 
-    @OneToOne(cascade = CascadeType.REMOVE)
+    @OneToOne
     @JoinColumn(name = "user_id", nullable = false)
     private User user;
 
index 7fe6029..2f6d894 100644 (file)
@@ -27,30 +27,23 @@ public class Policy implements Serializable {
 
     private static final long serialVersionUID = 4096729934577742517L;
 
-    /**
-     * The Constant DEFAULT_POLICY_PATH.
-     */
+    /** The Constant DEFAULT_POLICY_PATH. */
     private static final String DEFAULT_POLICY_PATH = "default-policy.json";
 
-    /**
-     * The unique ID in database table.
-     */
+    /** The unique ID in database table. */
     @Id
     @SequenceGenerator(name = "policy_id_seq", sequenceName = "policy_id_seq", allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "policy_id_seq")
     @Column
     private Long id;
 
-    /**
-     * The Policy file
-     * Contain list of Rules. Based on Policy format.
-     */
+    /** The Policy file
+     * Contain list of Rules. Based on Policy format. */
     @Column
     @Type(type = "text")
     private String policy;
 
-    /**
-     * The hash.
+    /** The hash. 
      * Is used as checker of actual policy being applied on device.
      * Send 4bytes of hash is cheaper then sending all policy file.
      */
@@ -70,6 +63,16 @@ public class Policy implements Serializable {
     }
 
     /**
+     * Instantiates a new policy.
+     *
+     * @param policy the policy
+     * @param route the route
+     */
+    public Policy(String policy, String route) {
+        setPolicy(policy, route);
+    }
+
+    /**
      * Gets the id.
      *
      * @return the id
@@ -98,9 +101,8 @@ public class Policy implements Serializable {
 
     /**
      * Sets the policy
-     *
      * @param policy - the new policy
-     * @param route  - route for
+     * @param route - route for 
      */
     public void setPolicy(String policy, String route) {
         this.policy = policy.replace("\n", "").replace("\r", "");
@@ -141,7 +143,6 @@ public class Policy implements Serializable {
 
     /**
      * Get route for HUB
-     *
      * @return route
      */
     public String getRoute() {
@@ -150,18 +151,31 @@ public class Policy implements Serializable {
 
     /**
      * Set route for HUB
-     *
      * @param route
      */
     public void setRoute(String route) {
         this.route = route;
     }
-    
+
+    /**
+     * Method provides reflection to print names and values of all fields
+     * <em>declared in this class</em>. Note that superclass fields are left out
+     * of this implementation.
+     * 
+     * @return String with names and values of all fields declared in this
+     *         class.
+     */
     @Override
     public String toString() {
         return "Policy [id=" + id + ", policy=" + policy + ", hash=" + hash + ", route=" + route + "]";
     }
 
+    /**
+     * Checks whether objects are equal.
+     * @param object to compare with
+     *
+     * @return true if objects are equels, otherwise false
+     */
     @Override
     public boolean equals(Object obj) {
         if (this == obj) {
@@ -200,5 +214,5 @@ public class Policy implements Serializable {
         result = prime * result + ((policy == null) ? 0 : policy.hashCode());
         return result;
     }
-
+    
 }
index 971ab13..730ccbf 100644 (file)
@@ -11,10 +11,10 @@ import java.io.Serializable;
 /**
  * <h1> Role DAO table</h1>
  * DAO representation of role types for {@link User}.
+ * @see User
  *
  * @author <A HREF="mailto:s.shram@samsung.com">Sergii Shram</A>
  * @version 1.0
- * @see User
  * @since 2016-09-01
  */
 @Entity
@@ -26,24 +26,16 @@ public class Role implements Serializable {
      */
     public enum Type {
 
-        /**
-         * Admin role.
-         */
+        /** Admin role.*/
         ADMIN("ROLE_ADMIN"),
 
-        /**
-         * User role.
-         */
+        /** User role.*/
         USER("ROLE_USER"),
 
-        /**
-         * Guest role (default).
-         */
+        /** Guest role (default).*/
         GUEST("ROLE_GUEST");
 
-        /**
-         * The type.
-         */
+        /** The type. */
         public final String type;
 
         /**
@@ -51,7 +43,7 @@ public class Role implements Serializable {
          *
          * @param type the type
          */
-        Type(final String type) {
+        private Type(final String type) {
             this.type = type;
         }
 
@@ -66,18 +58,14 @@ public class Role implements Serializable {
 
     private static final long serialVersionUID = 5696861289134152951L;
 
-    /**
-     * The id.
-     */
+    /** The id. */
     @Id
     @SequenceGenerator(name = "roles_id_seq", sequenceName = "roles_id_seq", allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "roles_id_seq")
     @Column
     private Long id;
 
-    /**
-     * The name.
-     */
+    /** The name. */
     @Column
     private String name;
 
@@ -97,8 +85,19 @@ public class Role implements Serializable {
     }
 
     /**
-     * Method provides getting ID of Role.
+     * Constructor for tests.
      *
+     * @param id the id
+     * @param name the name
+     */
+    public Role(Long id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    /**
+     * Method provides getting ID of Role.
+     * 
      * @return ID of Role.
      */
     public Long getId() {
@@ -131,27 +130,4 @@ public class Role implements Serializable {
     public void setName(String name) {
         this.name = name;
     }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        Role role = (Role) o;
-
-        return name.equals(role.name);
-    }
-
-    @Override
-    public int hashCode() {
-        return name.hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return "Role{" +
-                "id=" + id +
-                ", name='" + name + '\'' +
-                '}';
-    }
 }
index a9cb0be..b480332 100644 (file)
@@ -23,53 +23,35 @@ public class User implements Serializable {
 
     private static final long serialVersionUID = 4360094182916246858L;
 
-    /**
-     * The id.
-     */
+    /** The id. */
     @Id
     @SequenceGenerator(name = "users_id_seq", sequenceName = "users_id_seq", allocationSize = 1)
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "users_id_seq")
     @Column
     private Long id;
 
-    /**
-     * The username.
-     */
+    /** The username. */
     @Column
     private String username;
 
-    /**
-     * The email.
-     */
-    @Column(unique = true)
+    /** The email. */
+    @Column(unique=true)
     private String email;
-
-    /**
-     * True if user is Locked.
-     * False otherwise
-     */
+    
+    /** True if user is Locked.
+     * False otherwise */
     @Column
     private Boolean locked;
 
-    /**
-     * The date.
-     */
+    /** The date. */
     @Column
     private Date date;
 
-    /**
-     * User role.
-     */
+    /** User role. */
     @ManyToOne
     @JoinColumn(name = "role_id", nullable = false)
     private Role role;
 
-    @OneToOne(mappedBy = "user", cascade = CascadeType.ALL)
-    private CustomUserDetails userDetails;
-
-    @OneToOne(mappedBy = "user", cascade = CascadeType.ALL)
-    private IotCloudUser cloudUser;
-
     /**
      * Public constructor for class User. Creates object User with field <code>locked = false;</code>
      */
@@ -81,10 +63,9 @@ public class User implements Serializable {
     /**
      * Public constructor for class User with parameters. Creates object User with setting parameters
      * and <code>locked = false;</code>
-     *
      * @param username username of user.
-     * @param email    e-mail of user.
-     * @param role     {@link Role} of user.
+     * @param email e-mail of user.
+     * @param role {@link Role} of user.
      */
     public User(String username, String email, Role role) {
         this.username = username;
@@ -94,23 +75,14 @@ public class User implements Serializable {
         this.locked = false;
     }
 
-    public User(Long id, String username, String email, Role role) {
-        this.id = id;
-        this.username = username;
-        this.email = email;
-        this.date = new Date();
-        this.role = role;
-        this.locked = false;
-    }
-
     /**
      * Public constructor for class User with all fields for Tests.
      *
      * @param username the username
-     * @param email    the email
-     * @param locked   the locked
-     * @param date     the date
-     * @param role     the role
+     * @param email the email
+     * @param locked the locked
+     * @param date the date
+     * @param role the role
      */
     public User(String username, String email, Boolean locked, Date date, Role role) {
         this.username = username;
@@ -122,7 +94,6 @@ public class User implements Serializable {
 
     /**
      * Method provides getting ID of user.
-     *
      * @return user's ID.
      */
     public Long getId() {
@@ -131,7 +102,6 @@ public class User implements Serializable {
 
     /**
      * Method provides setting ID for user.
-     *
      * @param id ID for user.
      */
     public void setId(Long id) {
@@ -140,7 +110,6 @@ public class User implements Serializable {
 
     /**
      * Method provides setting username for user.
-     *
      * @param username for user.
      */
     public void setUsername(String username) {
@@ -149,7 +118,6 @@ public class User implements Serializable {
 
     /**
      * Method provides getting information is user locked or not.
-     *
      * @return TRUE - user locked; FALSE - user isn't locked.
      */
     public Boolean getLocked() {
@@ -158,7 +126,6 @@ public class User implements Serializable {
 
     /**
      * Method provides setting information is user locked or not.
-     *
      * @param locked TRUE - setting user as locked; FALSE - setting user as isn't locked.
      */
     public void setLocked(Boolean locked) {
@@ -167,7 +134,6 @@ public class User implements Serializable {
 
     /**
      * Method provides getting role of user.
-     *
      * @return role of user (ROLE_ADMIN, ROLE_USER)
      */
     public Role getRole() {
@@ -177,32 +143,14 @@ public class User implements Serializable {
 
     /**
      * Method provides setting role for user.
-     *
      * @param role {@link Role} of user (ROLE_ADMIN, ROLE_USER)
      */
     public void setRole(Role role) {
         this.role = role;
     }
 
-    public CustomUserDetails getUserDetails() {
-        return userDetails;
-    }
-
-    public void setUserDetails(CustomUserDetails userDetails) {
-        this.userDetails = userDetails;
-    }
-
-    public IotCloudUser getCloudUser() {
-        return cloudUser;
-    }
-
-    public void setCloudUser(IotCloudUser cloudUser) {
-        this.cloudUser = cloudUser;
-    }
-
     /**
      * Method provides getting e-mail of user.
-     *
      * @return e-mail of user.
      */
     public String getEmail() {
@@ -211,7 +159,6 @@ public class User implements Serializable {
 
     /**
      * Method provides getting username of user.
-     *
      * @return username of user.
      */
     public String getUsername() {
@@ -220,7 +167,6 @@ public class User implements Serializable {
 
     /**
      * Method provides setting e-mail for user.
-     *
      * @param email for user.
      */
     public void setEmail(String email) {
@@ -229,7 +175,6 @@ public class User implements Serializable {
 
     /**
      * Method provides getting of user's registration date.
-     *
      * @return registration date.
      */
     public Date getDate() {
@@ -238,7 +183,6 @@ public class User implements Serializable {
 
     /**
      * Method provides setting of user's registration date.
-     *
      * @param date registration date.
      */
     public void setDate(Date date) {
@@ -249,7 +193,6 @@ public class User implements Serializable {
      * Method provides reflection to print
      * names and values of all fields <em>declared in this class</em>. Note that
      * superclass fields are left out of this implementation.
-     *
      * @return String with names and values of all fields declared in this class.
      */
     @Override
@@ -258,32 +201,10 @@ public class User implements Serializable {
                 "id=" + id +
                 ", username='" + username + '\'' +
                 ", email='" + email + '\'' +
+                ", date='" + date + '\'' +
                 ", locked=" + locked +
-                ", date=" + date +
-                ", role=" + role.getName() +
+                ", role=" + role +
                 '}';
     }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        User user = (User) o;
-
-        if (!username.equals(user.username)) return false;
-        if (!email.equals(user.email)) return false;
-        if (!locked.equals(user.locked)) return false;
-        return role.equals(user.role);
-    }
-
-    @Override
-    public int hashCode() {
-        int result = username.hashCode();
-        result = 31 * result + email.hashCode();
-        result = 31 * result + locked.hashCode();
-        result = 31 * result + role.hashCode();
-        return result;
-    }
 }
 
index 6d5bd97..13d51af 100644 (file)
@@ -10,6 +10,7 @@ import java.util.Map;
 import javax.validation.constraints.NotNull;
 
 /**
+ * 
  * Model for Message Queue.
  *
  * @author <A HREF="mailto:y.zozulia@samsung.com">Yevhen Zozulia</A>
@@ -29,31 +30,31 @@ public class Notification {
      */
     @NotNull(message = "required field")
     private String deviceId;
-
+    
     /**
      * Current time in milliseconds
      */
     @NotNull(message = "required field")
     private Long currentTime;
-
+    
     /**
      * Error code
      */
     @NotNull(message = "required field")
     private String code;
-
+    
     /**
      * Message title
      */
     @NotNull(message = "required field")
     private String title;
-
+    
     /**
      * Message
      */
     @NotNull(message = "required field")
     private String message;
-
+    
     /**
      * Policy for user
      */
@@ -64,28 +65,25 @@ public class Notification {
      * Additional map for reports
      */
     private Map<String, String> additionalMap;
-
     /**
      * Create notification model to send Message Queue
      */
-    public Notification() {
-    }
+    public Notification(){}
 
     /**
      * Create notification model to send Message Queue with parameters:
-     *
-     * @param cloudUserId   - Cloud user id
-     * @param deviceId      - Device id
-     * @param currentTime   - Current time in milliseconds
-     * @param code          - Error code
-     * @param title         - Message title
-     * @param message       - Message
-     * @param policy        - Policy for user
+     * @param cloudUserId - Cloud user id
+     * @param deviceId - Device id
+     * @param currentTime - Current time in milliseconds
+     * @param code - Error code
+     * @param title - Message title
+     * @param message - Message
+     * @param policy - Policy for user
      * @param additionalMap - additional map
      */
     public Notification(String cloudUserId, String deviceId, Long currentTime, String code, String title, String message,
-                        String policy, Map<String, String> additionalMap) {
-
+            String policy, Map<String, String> additionalMap) {
+        super();
         this.cloudUserId = cloudUserId;
         this.currentTime = currentTime;
         this.code = code;
@@ -98,7 +96,6 @@ public class Notification {
 
     /**
      * Get cloud user id
-     *
      * @return cloudUserId
      */
     public String getCloudUserId() {
@@ -107,7 +104,6 @@ public class Notification {
 
     /**
      * Set cloud user id
-     *
      * @param cloudUserId - cloud user id
      */
     public void setCloudUserId(String cloudUserId) {
@@ -116,7 +112,6 @@ public class Notification {
 
     /**
      * Get device id
-     *
      * @return deviceId
      */
     public String getDeviceId() {
@@ -125,7 +120,6 @@ public class Notification {
 
     /**
      * Set device id
-     *
      * @param deviceId - device id
      */
     public void setDeviceId(String deviceId) {
@@ -134,7 +128,6 @@ public class Notification {
 
     /**
      * Get current time
-     *
      * @return currentTime
      */
     public Long getCurrentTime() {
@@ -143,7 +136,6 @@ public class Notification {
 
     /**
      * Set current time
-     *
      * @param currentTime - current time in milliseconds
      */
     public void setCurrentTime(Long currentTime) {
@@ -152,7 +144,6 @@ public class Notification {
 
     /**
      * Get error code
-     *
      * @return code
      */
     public String getCode() {
@@ -161,7 +152,6 @@ public class Notification {
 
     /**
      * Set error code
-     *
      * @param code - error code
      */
     public void setCode(String code) {
@@ -170,7 +160,6 @@ public class Notification {
 
     /**
      * Get message title
-     *
      * @return title
      */
     public String getTitle() {
@@ -179,7 +168,6 @@ public class Notification {
 
     /**
      * Set message title
-     *
      * @param title - message title
      */
     public void setTitle(String title) {
@@ -188,7 +176,6 @@ public class Notification {
 
     /**
      * Get notification message
-     *
      * @return message
      */
     public String getMessage() {
@@ -197,7 +184,6 @@ public class Notification {
 
     /**
      * Set notification message
-     *
      * @param message - notification message
      */
     public void setMessage(String message) {
@@ -206,7 +192,6 @@ public class Notification {
 
     /**
      * Get Policy for user
-     *
      * @return policy
      */
     public String getPolicy() {
@@ -215,7 +200,6 @@ public class Notification {
 
     /**
      * Set policy
-     *
      * @param policy - policy
      */
     public void setPolicy(String policy) {
@@ -224,7 +208,6 @@ public class Notification {
 
     /**
      * Get additional map
-     *
      * @return additionalMap
      */
     public Map<String, String> getAdditionalMap() {
@@ -233,7 +216,6 @@ public class Notification {
 
     /**
      * Set additional map
-     *
      * @param additionalMap
      */
     public void setAdditionalMap(Map<String, String> additionalMap) {
@@ -244,9 +226,9 @@ public class Notification {
      * Method provides reflection to print names and values of all fields
      * <em>declared in this class</em>. Note that superclass fields are left out
      * of this implementation.
-     *
+     * 
      * @return String with names and values of all fields declared in this
-     * class.
+     *         class.
      */
     @Override
     public String toString() {
index 8d6b919..35b553c 100644 (file)
@@ -49,6 +49,6 @@ public interface ReportRepository extends CrudRepository<Report, Long> {
      * @param type_id   report type ID in DB: {@link Report#getId()}
      * @return {@link Report}
      */
-    @Query(value = "SELECT r FROM Report r WHERE r.device.id = :device_id AND r.type.id = :type_id")
+    @Query(value = "select * from report r where r.device_id= :device_id and r.type_id= :type_id", nativeQuery = true)
     Report findByIdAndType(@Param("device_id") long device_id, @Param("type_id") long type_id);
 }
index 520e782..05b8544 100644 (file)
@@ -17,10 +17,10 @@ import java.util.List;
 /**
  * <h1> User Details repository</h1>
  * CRUD repository for User class.
+ * @see User
  *
  * @author <A HREF="mailto:a.motchanyi@samsung.com">Artem Motchanyi</A>
  * @version 1.0
- * @see User
  * @since 2016-09-01
  */
 @Repository
@@ -34,12 +34,13 @@ public interface UserRepository extends CrudRepository<User, Long> {
     User findByUsername(String username);
 
     /**
-     * How many users with such email address
+     * Check is email nonexistent in DB
      *
-     * @param email email
-     * @return count
+     * @param email email address
+     * @return true is email is nonexistent, false - in other cases
      */
-    Long countByEmail(@Param("email") String email);
+    @Query(value = "select count(u.id) = 0 from users u where u.email = :email", nativeQuery = true)
+    boolean isEmailAvailable(@Param("email") String email);
 
     /**
      * Find user by email address
@@ -65,13 +66,6 @@ public interface UserRepository extends CrudRepository<User, Long> {
     List<User> findAllByOrderByDateAsc();
 
     /**
-     * Get all users order by Date DESC
-     *
-     * @return users list
-     */
-    List<User> findAllByOrderByDateDesc();
-
-    /**
      * Delete by username
      *
      * @param userName user name
index 88a84e0..84ccbc2 100644 (file)
@@ -19,7 +19,13 @@ import java.util.List;
  * @see Agent
  * @since 2017-06-29
  */
-public interface AgentService {
+public interface AgentService extends CommonService<Agent> {
+    /**
+     * Service method provides getting List of all agents in DB.
+     *
+     * @return List&#60;{@link Agent}&#62; containing all agents in DB.
+     */
+    List<Agent> getAll();
 
     /**
      * Service method returns Agent by UUID in DB.
@@ -42,8 +48,9 @@ public interface AgentService {
      * @param uuid unique agent id
      * @param name agent name
      * @return {@link Agent}
+     * @throws Exception the empty name exception.
      */
-    Agent init(String uuid, String name);
+    Agent init(String uuid, String name) throws Exception;
 
     /**
      * Service method to create new Agent in DB.
@@ -53,7 +60,12 @@ public interface AgentService {
      * @param device device to which the agent belongs
      * 
      * @return {@link Agent}
-     * @throws IllegalArgumentException exception on creation
+     * @throws Exception the empty name exception.
+     */
+    Agent init(String uuid, String name, Device device) throws Exception;
+
+    /**
+     * Remove all agents
      */
-    Agent init(String uuid, String name, Device device);
+    void removeAll();
 }
diff --git a/servers/commons/src/main/java/com/samsung/commons/service/CommonCrudService.java b/servers/commons/src/main/java/com/samsung/commons/service/CommonCrudService.java
deleted file mode 100644 (file)
index d982e9e..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.samsung.commons.service;
-
-import org.springframework.data.repository.CrudRepository;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Default implementation of basic CRUD operations
- *
- * @param <T>  type of Entity
- * @param <ID> type of ID of Entity
- */
-public class CommonCrudService<T, ID extends Serializable> {
-
-    private final CrudRepository<T, ID> repository;
-
-    /**
-     * Provide CRUD repository
-     *
-     * @param repository CRUD repo
-     */
-    public CommonCrudService(CrudRepository<T, ID> repository) {
-        this.repository = repository;
-    }
-
-
-    // --------------------------------------------- SAVE --------------------------------------------------------------
-    public T save(T entity) {
-        return repository.save(entity);
-    }
-
-    // --------------------------------------------- FIND --------------------------------------------------------------
-    public T findOne(ID id) {
-        return repository.findOne(id);
-    }
-
-    public List<T> findAll() {
-        return (List<T>) repository.findAll();
-    }
-
-    public long count() {
-        return repository.count();
-    }
-
-    public boolean exists(ID id) {
-        return repository.exists(id);
-    }
-
-    // --------------------------------------------- DELETE ------------------------------------------------------------
-
-    public void deleteAll() {
-        repository.deleteAll();
-    }
-
-    public void delete(ID id) {
-        repository.delete(id);
-    }
-
-    public void delete(T entity) {
-        repository.delete(entity);
-    }
-
-    /**
-     * Check if entity exists (by ID) then delete
-     *
-     * @param id ID
-     * @return whether deletion was successful or not
-     */
-    public boolean deleteWithCheck(ID id) {
-        if (repository.exists(id)) {
-            repository.delete(id);
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-}
index 10c5ea6..859176e 100644 (file)
@@ -39,7 +39,7 @@ public interface DeviceService extends CommonService<Device> {
 
     /**
      * Devices by user
-     * <p>
+     *
      * Shows only not removed devices
      *
      * @param user user
@@ -84,9 +84,9 @@ public interface DeviceService extends CommonService<Device> {
      * @param status device status
      * @param user   user
      * @return {@link Device}
-     * @throws IllegalArgumentException wrong parameters
+     * @throws Exception the empty name exception.
      */
-    Device init(String uuid, String name, String type, String model, int status, User user, String route);
+    Device init(String uuid, String name, String type, String model, int status, User user, String route) throws Exception;
 
     /**
      * Remove all devices
index 5ef80c2..8bbb1a7 100644 (file)
@@ -50,8 +50,6 @@ public interface IotCloudService {
      */
     void deleteAllUsers();
 
-    void delete(Long id);
-
     /**
      * How many users in table
      *
index 25d8c38..2fa9b8e 100644 (file)
@@ -16,7 +16,7 @@ import com.samsung.commons.domain.Policy;
  * @see Policy
  * @since 2017-06-13
  */
-public interface PolicyService {
+public interface PolicyService extends CommonService<Policy> {
 
     /**
      * Get policy by Device ID
index 82452fb..24a0689 100644 (file)
@@ -40,7 +40,7 @@ public interface ReportService extends CommonService<Report> {
      * @param type     report type
      * @return Report report.
      */
-    Report findReport(long deviceId, ReportType.Type type);
+    Report getReport(long deviceId, ReportType.Type type);
 
     /**
      * Service method provides getting reports by Device id.
@@ -61,7 +61,7 @@ public interface ReportService extends CommonService<Report> {
     /**
      * Find all reports
      */
-    List<Report> findAll();
+    List<Report> findAllReports();
 
 
     /**
@@ -73,7 +73,7 @@ public interface ReportService extends CommonService<Report> {
      * @param result   report result
      * @param report   report
      */
-    Report saveReport(long deviceId, String type, String date, int result, String report);
+    Report setReport(long deviceId, String type, String date, int result, String report);
 
     /**
      * Remove all
index eae9281..f8183ff 100644 (file)
@@ -17,7 +17,7 @@ import com.samsung.commons.domain.ReportType;
  * @version 1.0
  * @since 2016-09-01
  */
-public interface ReportTypeService {
+public interface ReportTypeService extends CommonService<ReportType> {
     /**
      * Service method returns ReportType by name in DB.
      * @param name unique report name
index 4c87862..ca9af87 100644 (file)
@@ -6,23 +6,27 @@
 package com.samsung.commons.service;
 
 import com.samsung.commons.domain.Role;
-import com.samsung.commons.domain.User;
 
 import java.util.ArrayList;
 
 /**
  * <h1> User Role service</h1>
  * Service for user roles.
+ * @see Role
  *
  * @author <A HREF="mailto:s.shram@samsung.com">Sergiy Shram</A>
  * @version 1.0
- * @see Role
  * @since 2016-09-01
  */
-public interface RoleService {
+public interface RoleService extends CommonService<Role> {
+    /**
+     * Service method provides getting List of all roles in DB
+     * @return List of all roles in DB
+     */
+    ArrayList<Role> getAll();
+
     /**
      * Service method provides getting role by name in DB
-     *
      * @return role by name in DB
      */
     Role getByName(String name);
diff --git a/servers/commons/src/main/java/com/samsung/commons/service/UserSelfRemoveException.java b/servers/commons/src/main/java/com/samsung/commons/service/UserSelfRemoveException.java
deleted file mode 100644 (file)
index b591bba..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.samsung.commons.service;
-
-/**
- * Throws when user tries to remote itself
- */
-public class UserSelfRemoveException extends IllegalArgumentException {
-    public UserSelfRemoveException(String message) {
-        super(message);
-    }
-}
index 451419a..9dca920 100644 (file)
@@ -21,7 +21,7 @@ import java.util.List;
  * @see Role
  * @since 2016-09-01
  */
-public interface UserService {
+public interface UserService extends CommonService<User> {
 
     /**
      * Service method provides search user in DB by username.
@@ -31,9 +31,13 @@ public interface UserService {
      */
     User findByUsername(String username);
 
-    void remove(User user);
-
-    void remove(Long id);
+    /**
+     * Service method provides checking if e-mail is available for registration(not used for others accounts).
+     *
+     * @param request http request from client-side, contains e-mail for search.
+     * @return true is available/false already exist.
+     */
+    boolean isEmailAvailable(HttpServletRequest request);
 
     /**
      * Service method provides checking if e-mail is available for registration(not used for others accounts).
@@ -46,10 +50,9 @@ public interface UserService {
     /**
      * Service method provides getting List of all users in DB.
      *
-     * @param isDateAsc true - ascending order, false - descending
      * @return List of all users in DB
      */
-    List<User> findAll(boolean isDateAsc);
+    List<User> getAll(boolean isDateAsc);
 
     /**
      * Service method provides inverting of locked/unlocked state for user by ID.
@@ -60,6 +63,19 @@ public interface UserService {
     boolean changeLockedState(Long id);
 
     /**
+     * Service method provides user removal by ID.
+     *
+     * @param id of user for removal.
+     * @throws Exception self removal occurred
+     */
+    void remove(Long id) throws Exception;
+
+    /**
+     * Remove all users
+     */
+    void removeAll();
+
+    /**
      * Remove by user name
      *
      * @param userName user name
@@ -73,7 +89,7 @@ public interface UserService {
      * @param email email of user being searched.
      * @return object User with current e-mail.
      */
-    User findUserByEmail(String email);
+    User getUserByEmail(String email);
 
     /**
      * Service method provides editing the user account.
index b13fdaf..5d50210 100644 (file)
@@ -10,10 +10,8 @@ import com.samsung.commons.domain.Device;
 import com.samsung.commons.domain.Policy;
 import com.samsung.commons.repository.AgentRepository;
 import com.samsung.commons.service.AgentService;
-import com.samsung.commons.service.CommonCrudService;
 import com.samsung.commons.service.PolicyService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -21,14 +19,14 @@ import java.util.List;
 /**
  * <h1> Agent service</h1>
  * Service implementation for Agent repository.
+ * @see Agent
  *
  * @author <A HREF="mailto:a.motchanyi@samsung.com">Artem Motchanyi</A>
  * @version 1.0
- * @see Agent
  * @since 2017-06-29
  */
 @Service("agentService")
-public class AgentServiceImpl extends CommonCrudService<Agent, Long> implements AgentService {
+public class AgentServiceImpl implements AgentService {
 
     @Autowired
     private AgentRepository agentRepository;
@@ -36,13 +34,34 @@ public class AgentServiceImpl extends CommonCrudService<Agent, Long> implements
     @Autowired
     private PolicyService policyService;
 
-    /**
-     * Provide CRUD repository
-     *
-     * @param repository CRUD repo
-     */
-    public AgentServiceImpl(AgentRepository repository) {
-        super(repository);
+    @Override
+    public Agent findById(Long id) {
+        return agentRepository.findOne(id);
+    }
+
+    @Override
+    public List<Agent> getAll() {
+        return (List<Agent>) agentRepository.findAll();
+    }
+
+    @Override
+    public long count() {
+        return agentRepository.count();
+    }
+
+    @Override
+    public Agent save(Agent agent) {
+        return agentRepository.save(agent);
+    }
+
+    @Override
+    public void remove(Agent agent) {
+        agentRepository.delete(agent);
+    }
+
+    @Override
+    public void removeAll() {
+        agentRepository.deleteAll();
     }
 
     @Override
@@ -56,20 +75,23 @@ public class AgentServiceImpl extends CommonCrudService<Agent, Long> implements
     }
 
     @Override
-    public Agent init(String uuid, String name) {
+    public Agent init(String uuid, String name) throws Exception {
         return init(uuid, name, null);
     }
 
     @Override
-    public Agent init(String uuid, String name, Device device) {
+    public Agent init(String uuid, String name, Device device) throws Exception {
         if (name.isEmpty() || uuid.isEmpty()) {
-            throw new IllegalArgumentException("Cannot create agent with empty fields");
+            throw new Exception("Cannot create agent with empty fields");
         }
 
         if (findByUUID(uuid) != null) {
-            throw new IllegalArgumentException("Cannot create agent with the same UUID");
+            throw new Exception("Cannot create agent with the same UUID");
         }
 
-        return save(new Agent(uuid, name, policyService.initPolicy(uuid), device));
+        Policy policy = policyService.initPolicy(uuid);
+        Agent agent = new Agent(uuid, name, policy, device);
+
+        return save(agent);
     }
 }
index 69e60e6..b987c26 100644 (file)
@@ -7,6 +7,7 @@ package com.samsung.commons.service.impl;
 
 import com.samsung.commons.domain.Agent;
 import com.samsung.commons.domain.Device;
+import com.samsung.commons.domain.Policy;
 import com.samsung.commons.domain.User;
 import com.samsung.commons.repository.DeviceRepository;
 import com.samsung.commons.service.DeviceService;
@@ -28,7 +29,6 @@ import java.util.Set;
  */
 @Service("deviceService")
 public class DeviceServiceImpl implements DeviceService {
-
     @Autowired
     private DeviceRepository deviceRepository;
 
@@ -92,7 +92,11 @@ public class DeviceServiceImpl implements DeviceService {
 
     @Override
     public void removeAll() {
-        deviceRepository.deleteAll();
+        Iterable<Device> devices = deviceRepository.findAll();
+
+        for (Device device : devices) {
+            remove(device);
+        }
     }
 
     @Override
@@ -103,12 +107,15 @@ public class DeviceServiceImpl implements DeviceService {
     }
 
     @Override
-    public Device init(String uuid, String name, String type, String model, int status, User user, String route) {
+    public Device init(String uuid, String name, String type, String model, int status, User user, String route) throws Exception {
         if (name.isEmpty() || uuid.isEmpty() || type.isEmpty() || model.isEmpty()) {
-            throw new IllegalArgumentException("Cannot create device with empty fields");
+            throw new Exception("Cannot create device with empty fields");
         }
 
-        return save(new Device(uuid, name, type, model, status, policyService.initPolicy(route), user));
+        Policy policy = policyService.initPolicy(route);
+        Device device = new Device(uuid, name, type, model, status, policy, user);
+
+        return save(device);
     }
 
     @Override
index f862ba9..b2b2652 100644 (file)
@@ -6,12 +6,11 @@ import com.samsung.commons.repository.IotCloudUserRepository;
 import com.samsung.commons.repository.UserRepository;
 import com.samsung.commons.service.IotCloudService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 
-import static java.util.Optional.ofNullable;
-
 @Service("iotCloudService")
 public class IotCloudServiceImpl implements IotCloudService {
 
@@ -29,33 +28,28 @@ public class IotCloudServiceImpl implements IotCloudService {
             throw new IllegalArgumentException("User hasn't been found by email");
         }
 
-        IotCloudUser byUser = repository.findByUser(user);
-
-        if (byUser == null) {
-            return repository.save(new IotCloudUser(user, iotCloudUserUuid));
-        } else {
+        IotCloudUser iotCloudUser = new IotCloudUser(user, iotCloudUserUuid);
+        try {
+            return repository.save(iotCloudUser);
+        } catch (DataIntegrityViolationException e) {
             return null;
         }
     }
 
     @Override
     public User findAssociatedUserByUuid(String uuid) {
-        return ofNullable(repository.findByUuid(uuid))
-                .map(IotCloudUser::getUser)
-                .orElse(null);
-    }
+        IotCloudUser iotCloudUser = repository.findByUuid(uuid);
 
-    @Override
-    public void deleteAllUsers() {
-        Iterable<IotCloudUser> all = repository.findAll();
-        for (IotCloudUser iotCloudUser : all) {
-            repository.delete(iotCloudUser);
+        if (iotCloudUser == null) {
+            return null;
+        } else {
+            return iotCloudUser.getUser();
         }
     }
 
     @Override
-    public void delete(Long id) {
-        repository.delete(id);
+    public void deleteAllUsers() {
+        repository.deleteAll();
     }
 
     @Override
index e3d8071..dce629b 100644 (file)
@@ -11,19 +11,11 @@ import com.samsung.commons.domain.Policy;
 import com.samsung.commons.repository.AgentRepository;
 import com.samsung.commons.repository.DeviceRepository;
 import com.samsung.commons.repository.PolicyRepository;
-import com.samsung.commons.service.CommonCrudService;
 import com.samsung.commons.service.PolicyService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Objects;
-
-import static java.util.Optional.ofNullable;
-import static java.util.stream.Stream.of;
-
 /**
  * <h1> Policy service</h1>
  * Service implementation for Policy repository.
@@ -34,8 +26,9 @@ import static java.util.stream.Stream.of;
  * @since 2016-09-01
  */
 @Service("policyService")
-public class PolicyServiceImpl extends CommonCrudService<Policy, Long> implements PolicyService{
+public class PolicyServiceImpl implements PolicyService {
 
+    @Autowired
     private PolicyRepository policyRepository;
 
     @Autowired
@@ -44,20 +37,23 @@ public class PolicyServiceImpl extends CommonCrudService<Policy, Long> implement
     @Autowired
     private AgentRepository agentRepository;
 
-    /**
-     * Provide CRUD repository
-     *
-     * @param repository CRUD repo
-     */
-    public PolicyServiceImpl(PolicyRepository repository) {
-        super(repository);
+    @Override
+    public Policy save(Policy policy) {
+        return policyRepository.save(policy);
+    }
 
-        this.policyRepository = repository;
+    @Override
+    public Policy findById(Long id) {
+        return policyRepository.findOne(id);
     }
 
     @Override
-    public void delete(Policy policy) {
-        // todo: try to remove this method
+    public long count() {
+        return policyRepository.count();
+    }
+
+    @Override
+    public void remove(Policy policy) {
         try {
             policyRepository.delete(policy);
         } catch (DataIntegrityViolationException e) {
@@ -68,27 +64,33 @@ public class PolicyServiceImpl extends CommonCrudService<Policy, Long> implement
 
     @Override
     public Policy findByDeviceId(long deviceId) {
-        return of(deviceRepository.findOne(deviceId))
-                .filter(Objects::nonNull)
-                .map(Device::getPolicy)
-                .findFirst().orElse(null);
+        try {
+            return deviceRepository.findOne(deviceId).getPolicy();
+        } catch (NullPointerException e) {
+            //no device with such ID
+            return null;
+        }
     }
 
     @Override
     public Policy findByAgentId(long agentId) {
-        return of(agentRepository.findOne(agentId))
-                .filter(Objects::nonNull)
-                .map(Agent::getPolicy)
-                .findFirst().orElse(null);
+        try {
+            return agentRepository.findOne(agentId).getPolicy();
+        } catch (NullPointerException e) {
+            //no device with such ID
+            return null;
+        }
     }
 
     @Override
     public Policy findByDeviceUuidAndByAgentUuid(String deviceUuId, String agentUuId) {
-        return of(agentRepository.findByUuidAndDeviceUuid(agentUuId, deviceUuId))
-                .filter(Objects::nonNull)
-                .map(Agent::getPolicy)
-                .findFirst().orElse(null);
+        Agent agent = agentRepository.findByUuidAndDeviceUuid(agentUuId, deviceUuId);
+
+        if (agent == null) {
+            return null;
+        }
 
+        return agent.getPolicy();
     }
 
     @Override
@@ -100,15 +102,17 @@ public class PolicyServiceImpl extends CommonCrudService<Policy, Long> implement
     }
 
     @Override
-    public Policy setDevicePolicy(String deviceUuid, String policyString, String route) throws Exception {
-        return ofNullable(deviceRepository.findByUuid(deviceUuid))
-                .map(Device::getPolicy)
-                .map(policy -> {
-                    policy.setPolicy(policyString, route);
-                    return policy;
-                })
-                .map(policyRepository::save)
-                .orElseThrow(() -> new Exception("Device with such UUID doesn't exist"));
+    public Policy setDevicePolicy(String deviceUuid, String policy, String route) throws Exception {
+        Device device = deviceRepository.findByUuid(deviceUuid);
+
+        if (device == null) {
+            throw new Exception("Device with such UUID doesn't exist");
+        }
+
+        Policy p = device.getPolicy();
+        p.setPolicy(policy, route);
+
+        return policyRepository.save(p);
     }
 
     @Override
index c0612e0..cf0f302 100644 (file)
@@ -5,7 +5,6 @@
  */
 package com.samsung.commons.service.impl;
 
-import com.samsung.commons.domain.Device;
 import com.samsung.commons.domain.Report;
 import com.samsung.commons.domain.ReportType;
 import com.samsung.commons.repository.DeviceRepository;
@@ -43,25 +42,21 @@ public class ReportServiceImpl implements ReportService {
         t.setReport(strip(t.getReport()));
         return reportRepository.save(t);
     }
-
+    
     private String strip(String str){
         return str.replace("\n", "").replace("\b", "").replace("\t", "").replace("\r", "");
     }
 
     @Override
     public Report save(long deviceId, String type, String date, int result, String report) {
-        Device device = deviceRepository.findOne(deviceId);
-        if (device == null) {
-            throw new IllegalArgumentException("No device found by it's ID");
-        }
+        Report r = new Report(reportTypeRepository.findByType(ReportType.Type.getType(type).toString()), report, date, result, deviceRepository.findOne(deviceId));
 
-        ReportType reportType = reportTypeRepository.findByType(type);
-        return save(new Report(reportType, report, date, result, device));
+        return save(r);
     }
 
     @Override
-    public void remove(Report report) {
-        reportRepository.delete(report);
+    public void remove(Report t) {
+        reportRepository.delete(t);
     }
 
     @Override
@@ -75,7 +70,7 @@ public class ReportServiceImpl implements ReportService {
     }
 
     @Override
-    public Report findReport(long deviceId, ReportType.Type type) {
+    public Report getReport(long deviceId, ReportType.Type type) {
         return reportRepository.findByIdAndType(deviceId, reportTypeRepository.findByType(type.toString()).getId());
     }
 
@@ -90,13 +85,13 @@ public class ReportServiceImpl implements ReportService {
     }
 
     @Override
-    public List<Report> findAll() {
+    public List<Report> findAllReports() {
         return (List<Report>) reportRepository.findAll();
     }
 
     @Override
-    public Report saveReport(long deviceId, String type, String date, int result, String report) {
-        Report deviceReport = findReport(deviceId, ReportType.Type.getType(type));
+    public Report setReport(long deviceId, String type, String date, int result, String report) {
+        Report deviceReport = getReport(deviceId, ReportType.Type.getType(type));
 
         if (deviceReport == null) {
             return save(deviceId, type, date, result, report);
index dd2cdc9..0b11b9f 100644 (file)
@@ -7,32 +7,44 @@ package com.samsung.commons.service.impl;
 
 import com.samsung.commons.domain.ReportType;
 import com.samsung.commons.repository.ReportTypeRepository;
-import com.samsung.commons.service.CommonCrudService;
 import com.samsung.commons.service.ReportTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Service;
 
 /**
  * <h1> ReportType service</h1>
  * Implementation of the service for the ReportType repository.
+ * @see ReportType
  *
  * @author <A HREF="mailto:a.motchanyi@samsung.com">Artem Motchanyi</A>
  * @version 1.0
- * @see ReportType
  * @since 2016-09-01
  */
 @Service("reportTypeService")
-public class ReportTypeServiceImpl extends CommonCrudService<ReportType, Long> implements ReportTypeService {
-
+public class ReportTypeServiceImpl implements ReportTypeService {
+    @Autowired
     private ReportTypeRepository reportTypeRepository;
 
-    public ReportTypeServiceImpl(ReportTypeRepository repository) {
-        super(repository);
+    @Override
+    public ReportType save(ReportType t) {
+        return reportTypeRepository.save(t);
+    }
 
-        this.reportTypeRepository = repository;
+    @Override
+    public void remove(ReportType t) {
+        reportTypeRepository.delete(t);
     }
-    
+
+    @Override
+    public ReportType findById(Long id) {
+        return reportTypeRepository.findOne(id);
+    }
+
+    @Override
+    public long count() {
+        return reportTypeRepository.count();
+    }
+
     @Override
     public ReportType findByName(String name) {
         return reportTypeRepository.findByType(name);
index 61d3125..8b5c44f 100644 (file)
@@ -6,12 +6,9 @@
 package com.samsung.commons.service.impl;
 
 import com.samsung.commons.domain.Role;
-import com.samsung.commons.domain.User;
 import com.samsung.commons.repository.RoleRepository;
-import com.samsung.commons.service.CommonCrudService;
 import com.samsung.commons.service.RoleService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -27,14 +24,34 @@ import java.util.ArrayList;
  * @since 2016-09-01
  */
 @Service("roleService")
-public class RoleServiceImpl extends CommonCrudService<Role, Long> implements RoleService {
+public class RoleServiceImpl implements RoleService {
 
+    @Autowired
     private RoleRepository roleRepository;
 
-    public RoleServiceImpl(RoleRepository repository) {
-        super(repository);
+    @Override
+    public Role save(Role t) {
+        return roleRepository.save(t);
+    }
+
+    @Override
+    public void remove(Role t) {
+        roleRepository.delete(t);
+    }
+
+    @Override
+    public Role findById(Long id) {
+        return roleRepository.findOne(id);
+    }
+
+    @Override
+    public long count() {
+        return roleRepository.count();
+    }
 
-        roleRepository = repository;
+    @Override
+    public ArrayList<Role> getAll() {
+        return (ArrayList<Role>) roleRepository.findAll();
     }
 
     @Override
index 3e2112c..1c437d3 100644 (file)
@@ -31,10 +31,8 @@ import java.util.List;
  */
 @Service("userDetailsService")
 public class UserDetailsServiceImpl implements UserDetailsService, org.springframework.security.core.userdetails.UserDetailsService {
-
     @Autowired
     private UserRepository userRepository;
-
     @Autowired
     private UserDetailsRepository userDetailsRepository;
 
index 5121444..78dc6ce 100644 (file)
@@ -9,13 +9,8 @@ import com.samsung.commons.domain.Role;
 import com.samsung.commons.domain.User;
 import com.samsung.commons.repository.UserDetailsRepository;
 import com.samsung.commons.repository.UserRepository;
-import com.samsung.commons.service.CommonCrudService;
-import com.samsung.commons.service.UserSelfRemoveException;
 import com.samsung.commons.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.stereotype.Service;
@@ -33,23 +28,15 @@ import java.util.List;
  * @since 2016-09-01
  */
 @Service("userService")
-public class UserServiceImpl extends CommonCrudService<User,Long> implements UserService {
-
+public class UserServiceImpl implements UserService {
+    @Autowired
     private UserRepository userRepository;
 
-    /**
-     * Provide CRUD repository
-     *
-     * @param repository CRUD repo
-     */
-    public UserServiceImpl(UserRepository repository) {
-        super(repository);
-
-        this.userRepository = repository;
-    }
+    @Autowired
+    private UserDetailsRepository userDetailsRepository;
 
     @Override
-    public User findUserByEmail(String email) {
+    public User getUserByEmail(String email) {
         return userRepository.findByEmail(email);
     }
 
@@ -63,18 +50,24 @@ public class UserServiceImpl extends CommonCrudService<User,Long> implements Use
      */
     @Override
     public void remove(User user) {
-        // Don't allow a suicide :)
+        // do not allow suicide :)
         if (isSelf(user)) {
-            throw new UserSelfRemoveException("Can't remove itself");
+            return;
         }
 
-        userRepository.delete(user);
+        if (userDetailsRepository.findByUserId(user.getId()) != null) {
+            //cascade remove of user details and user
+            userDetailsRepository.deleteByUserId(user.getId());
+        } else {
+            // there is no user details for this user
+            // so just remove user
+            userRepository.delete(user);
+        }
     }
 
     @Override
-    public void remove(Long id) {
-        User user = findOne(id);
-        remove(user);
+    public User findById(Long id) {
+        return userRepository.findOne(id);
     }
 
     @Override
@@ -83,13 +76,27 @@ public class UserServiceImpl extends CommonCrudService<User,Long> implements Use
     }
 
     @Override
+    public long count() {
+        return userRepository.count();
+    }
+
+    @Override
+    public boolean isEmailAvailable(HttpServletRequest request) {
+        return userRepository.isEmailAvailable(request.getParameter("email"));
+    }
+
+    @Override
     public boolean isEmailAvailable(String email) {
-        return userRepository.countByEmail(email) == 0;
+        return userRepository.isEmailAvailable(email);
     }
 
     @Override
-    public List<User> findAll(boolean isDateAsc) {
-        return isDateAsc ? userRepository.findAllByOrderByDateAsc() : userRepository.findAllByOrderByDateDesc();
+    public List<User> getAll(boolean isDateAsc) {
+        if (isDateAsc) {
+            return (List<User>) userRepository.findAllByOrderByDateAsc();
+        } else {
+            return (List<User>) userRepository.findAll();
+        }
     }
 
     @Override
@@ -108,6 +115,17 @@ public class UserServiceImpl extends CommonCrudService<User,Long> implements Use
     }
 
     @Override
+    public void remove(Long id) throws Exception {
+        User user = userRepository.findOne(id);
+
+        if (isSelf(user)) {
+            throw new Exception("Self remove is prohibited");
+        }
+
+        remove(user);
+    }
+
+    @Override
     public User editUser(User editedUser) {
         // user should not change role/locked_state to himself
         if (isSelf(editedUser)) {
@@ -124,23 +142,23 @@ public class UserServiceImpl extends CommonCrudService<User,Long> implements Use
     }
 
     private boolean isSelf(final User user) {
-        if (user == null) {
-            throw new IllegalArgumentException("Can't determine for null user");
-        }
-
-        SecurityContext context = SecurityContextHolder.getContext();
-        Authentication authentication = context.getAuthentication();
-        if (authentication == null) {
-            return false;
-        }
-
-        final String secContextUserName = ((UserDetails) authentication.getPrincipal()).getUsername();
+        final String secContextUserName = ((UserDetails) SecurityContextHolder.getContext().getAuthentication()
+                .getPrincipal()).getUsername();
 
         // to guarantee uniqueness - userEMAIL is stored in secContextUserNAME
         return secContextUserName.equals(user.getEmail());
     }
 
     @Override
+    public void removeAll() {
+        List<User> users = getAll(false);
+
+        for (User user : users) {
+            remove(user);
+        }
+    }
+
+    @Override
     public Long removeByUserName(String userName) {
         return userRepository.removeByUsername(userName);
     }
diff --git a/servers/commons/src/main/java/com/samsung/commons/utils/UrlBuilder.java b/servers/commons/src/main/java/com/samsung/commons/utils/UrlBuilder.java
deleted file mode 100644 (file)
index fb458fc..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.samsung.commons.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static java.lang.String.valueOf;
-
-/**
- * Builds String URL
- */
-public class UrlBuilder {
-    private final List<String> chunks = new ArrayList<>();
-
-    public UrlBuilder() {
-        this.chunks.add("restapi");
-    }
-
-    public UrlBuilder add(String fragment) {
-        chunks.add(fragment);
-
-        return this;
-    }
-
-    public UrlBuilder add(String fragment, String parameter) {
-        chunks.add(fragment);
-        chunks.add(parameter);
-
-        return this;
-    }
-
-    public UrlBuilder add(String fragment, int parameter) {
-        chunks.add(fragment);
-        chunks.add(valueOf(parameter));
-
-        return this;
-    }
-
-    public UrlBuilder add(String fragment, Long parameter) {
-        chunks.add(fragment);
-        chunks.add(parameter.toString());
-
-        return this;
-    }
-
-    public String build() {
-        StringBuilder builder = new StringBuilder();
-
-        for (String chunk : chunks) {
-            builder.append("/").append(chunk);
-        }
-
-        chunks.clear();
-        
-        return builder.toString();
-    }
-}
\ No newline at end of file
index 6dccb50..ad0f1dd 100644 (file)
@@ -1,18 +1,21 @@
 package com.samsung.commons.utils;
 
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
 import java.util.Scanner;
 
-import static java.util.Optional.empty;
-import static java.util.Optional.of;
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.validation.FieldError;
+import org.springframework.validation.ObjectError;
 
 /**
  * <h1>Utils</h1>
@@ -23,21 +26,37 @@ import static java.util.Optional.of;
  * @since 2016-09-01
  */
 public class Utils {
+    /**
+     * Parse validation object into the new format Map&#60;key,value&#62;.
+     *
+     * @param validationObject error objects.
+     * @return validation result in the Map&#60;key,value&#62; format.
+     */
+    public static Map<String, String> getRejectedFields(List<ObjectError> validationObject) {
+        Map<String, String> map = new HashMap<String, String>();
 
-    public static <T> Optional<Collection<T>> ofEmpty(Collection<T> collection) {
-        if (collection == null) {
-            throw new IllegalArgumentException("Collection is null");
+        for (ObjectError objectError : validationObject) {
+            FieldError fieldError = (FieldError) objectError;
+            map.put(fieldError.getField(), objectError.getDefaultMessage());
         }
 
-        return collection.isEmpty() ? empty() : of(collection);
+        return map;
     }
 
-    public static <T> Optional<List<T>> ofEmpty(List<T> list) {
-        if (list == null) {
-            throw new IllegalArgumentException("List is null");
+    public static <T> Optional<Collection<T>> ofEmpty(Collection<T> collection) {
+        if (collection.isEmpty()) {
+            return Optional.empty();
+        } else {
+            return Optional.of(collection);
         }
+    }
 
-        return list.isEmpty() ? empty() : of(list);
+    public static <T> Optional<List<T>> ofEmpty(List<T> collection) {
+        if (collection.isEmpty()) {
+            return Optional.empty();
+        } else {
+            return Optional.of(collection);
+        }
     }
 
     public static String readAllFile(String path, Charset encoding) throws IOException {
@@ -48,4 +67,13 @@ public class Utils {
             return s.useDelimiter("\\A").hasNext() ? s.next() : "";
         }
     }
+
+    public static String returnView(HttpServletRequest request) {
+        if (request.isUserInRole("ROLE_ADMIN")) {
+            return "redirect:/admin";
+        } else if (request.isUserInRole("ROLE_USER")) {
+            return "redirect:/user";
+        }
+        return "login";
+    }
 }
diff --git a/servers/commons/src/main/resources/sql/init.sql b/servers/commons/src/main/resources/sql/init.sql
new file mode 100644 (file)
index 0000000..99260b8
--- /dev/null
@@ -0,0 +1,19 @@
+--Role table setup
+INSERT INTO roles (id, name) VALUES (nextval('roles_id_seq'), 'ROLE_ADMIN');
+INSERT INTO roles (id, name) VALUES (nextval('roles_id_seq'), 'ROLE_USER');
+
+--Report types setup
+INSERT INTO report_type (id, type) VALUES (nextval('report_type_id_seq'), 'sim');
+INSERT INTO report_type (id, type) VALUES (nextval('report_type_id_seq'), 'smart-security');
+INSERT INTO report_type (id, type) VALUES (nextval('report_type_id_seq'), 'smack');
+INSERT INTO report_type (id, type) VALUES (nextval('report_type_id_seq'), 'wbs');
+
+--granted applications
+INSERT INTO granted_app(id, comm, p_comm) VALUES (nextval('granted_app_seq'), 'ls', 'bash');
+INSERT INTO granted_app(id, comm, p_comm) VALUES (nextval('granted_app_seq'), 'bash', 'bash');
+
+--Add admin user to the system
+-- login:    admin@samsung.com
+-- password: 111111
+INSERT INTO users(id, username, email, locked, date, role_id) VALUES (nextval('users_id_seq'), 'admin', 'admin@samsung.com', false, now(), 1);
+INSERT INTO user_details(id, password, restore_password_link, user_id) VALUES (nextval('user_details_id_seq'), '$2a$12$hrhsmzoFyO24LmyOaBgLnu4wZv1QS18oOv/vTRpo7upTlpPK9IS3a', 'link', 1);
\ No newline at end of file
index e538be0..b02f6af 100644 (file)
@@ -1,14 +1,16 @@
 package com.samsung.commons;
 
-import com.samsung.commons.utils.Utils;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mock;
 
-import java.util.*;
+import javax.servlet.http.HttpServletRequest;
 
-import static com.samsung.commons.utils.Utils.ofEmpty;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static com.samsung.commons.utils.Utils.returnView;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.when;
 import static org.mockito.MockitoAnnotations.initMocks;
 
 /**
@@ -17,43 +19,29 @@ import static org.mockito.MockitoAnnotations.initMocks;
  * Created by o.abakumov on 6/30/2017.
  */
 public class UtilsTest {
+    @Mock
+    private HttpServletRequest request;
 
     @Before
     public void before() {
         initMocks(this);
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testOfEmptyNullCollection() {
-        ofEmpty((Collection) null);
-    }
-
     @Test
-    public void testOfEmptyEmptyCollection() {
-        assertFalse(ofEmpty(new HashSet<>()).isPresent());
-    }
-
-    @Test
-    public void testOfEmptyNonEmptyCollection() {
-        HashSet<Integer> set = new HashSet<>();
-        set.add(1);
-        set.add(2);
-        set.add(3);
-        assertTrue(ofEmpty(set).isPresent());
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testOfEmptyNullList() {
-        Utils.ofEmpty((List) null);
+    public void testAdminRedirect() throws Exception {
+        when(request.isUserInRole("ROLE_ADMIN")).thenReturn(true);
+        assertThat(returnView(request), equalTo("redirect:/admin"));
     }
 
     @Test
-    public void testOfEmptyEmptyList() {
-        assertFalse(ofEmpty(new ArrayList<>()).isPresent());
+    public void testUserRedirect() throws Exception {
+        when(request.isUserInRole("ROLE_USER")).thenReturn(true);
+        assertThat(returnView(request), equalTo("redirect:/user"));
     }
 
     @Test
-    public void testOfEmptyNonEmptyList() {
-        assertTrue(ofEmpty(Arrays.asList(1, 2 ,3)).isPresent());
+    public void testDefaultController() throws Exception {
+        when(request.isUserInRole(anyString())).thenReturn(false);
+        assertThat(returnView(request), equalTo("login"));
     }
 }
\ No newline at end of file
index 4814c98..7d71b69 100644 (file)
@@ -2,16 +2,15 @@ package com.samsung.commons.domain.user;
 
 import com.samsung.commons.domain.Role;
 import com.samsung.commons.domain.User;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Date;
-
-import static java.lang.String.format;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.Date;
+
 /**
  * @author Ivan Gonchar (iv.gonchar@samsung.com)
  * @version 1.0
@@ -114,12 +113,21 @@ public class UserTest {
     @Test
     public void toStringTest() {
         Role mockedRole = mock(Role.class);
-        when(mockedRole.getName()).thenReturn("role");
+        when(mockedRole.toString()).thenReturn("role");
 
-        User user = new User(1L, "user", "user@company.com", mockedRole);
+        User user = new User("user", "user@company.com", mockedRole);
+        user.setId(1l);
+
+        String toString = user.toString();
 
-        assertEquals(format(
-                "User{id=1, username='user', email='user@company.com', locked=false, date=%s, " +
-                        "role=role}", user.getDate()), user.toString());
+        //User{id=1, username='user', email='user@company.com', 
+        //date='Tue Jul 19 13:16:53 EEST 2016', locked=false, role=role}
+        assertTrue(toString.contains("User{"));
+        assertTrue(toString.contains("id=" + user.getId()));
+        assertTrue(toString.contains("email='" + user.getEmail()+"'"));
+        assertTrue(toString.contains("date='" + user.getDate()+"'"));
+        assertTrue(toString.contains("locked=" + user.getLocked()));
+        assertTrue(toString.contains("role=" + user.getRole()));
     }
+
 }
diff --git a/servers/commons/src/test/java/com/samsung/commons/model/NotificationTest.java b/servers/commons/src/test/java/com/samsung/commons/model/NotificationTest.java
deleted file mode 100644 (file)
index 597faeb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.samsung.commons.model;
-
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class NotificationTest {
-
-    @Test
-    public void toStringTest() {
-        Map<String, String> map = new HashMap<>();
-        map.put("key", "value");
-
-        Notification notification = new Notification(
-                "cloudUserId",
-                "deviceId",
-                1L,
-                "code",
-                "title",
-                "message",
-                "policy",
-                map
-        );
-
-        assertThat(notification.toString(),
-                is("Notification [cloudUserId=cloudUserId, deviceId=deviceId, currentTime=1, code=code, " +
-                        "title=title, message=message, policy=policy, additionalMap = {key=value}]"));
-    }
-}
\ No newline at end of file
index cde4abd..74bd007 100644 (file)
@@ -9,7 +9,6 @@ import com.samsung.commons.domain.Policy;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -26,11 +25,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
  */
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+@ContextConfiguration(locations = { "classpath:root-context.xml" })
 public class AgentRepositoryTest {
-
     @Autowired
     private AgentRepository agentRepository;
 
index 5f970c2..01674eb 100644 (file)
@@ -12,7 +12,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -31,7 +30,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = { "classpath:root-context.xml" })
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DeviceRepositoryTest {
     @Autowired
     private DeviceRepository deviceRepository;
@@ -48,7 +46,7 @@ public class DeviceRepositoryTest {
 
     @Before
     public void before() {
-        user = userService.findUserByEmail("admin@samsung.com");
+        user = userService.getUserByEmail("admin@samsung.com");
         policy = policyRepository.save(new Policy());
     }
 
index 202f53a..3c51214 100644 (file)
@@ -9,7 +9,6 @@ import com.samsung.commons.domain.Role;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -17,7 +16,6 @@ import org.springframework.test.context.web.WebAppConfiguration;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = { "classpath:root-context.xml" })
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class RoleRepositoryTest {
 
     @Autowired
index b00384f..5bb488c 100644 (file)
@@ -4,7 +4,6 @@ import com.samsung.commons.domain.User;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -15,7 +14,6 @@ import static org.junit.Assert.assertNull;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = { "classpath:root-context.xml" })
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class UserRepositoryTest {
 
     @Autowired
index 9cb3258..f850da1 100644 (file)
@@ -1,8 +1,5 @@
 package com.samsung.commons.service;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -16,13 +13,11 @@ import com.samsung.commons.domain.Agent;
 import com.samsung.commons.domain.Device;
 import com.samsung.commons.domain.Policy;
 import com.samsung.commons.domain.User;
-import com.samsung.commons.service.impl.AgentServiceImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -40,14 +35,13 @@ import org.springframework.test.context.web.WebAppConfiguration;
  */
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+@ContextConfiguration(locations = { "classpath:root-context.xml" })
 public class AgentServiceTest {
     private static final String AGENT_UUID = "uuid";
 
     @Autowired
-    private AgentServiceImpl agentService;
+    private AgentService agentService;
 
     @Autowired
     private PolicyService policyService;
@@ -58,15 +52,14 @@ public class AgentServiceTest {
     @Autowired
     private DeviceService deviceService;
 
-    private Agent agent;
 
     @Before
     public void before() {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
-        agent = agentService.save(new Agent(AGENT_UUID, "name", policy));
+        agentService.save(new Agent(AGENT_UUID, "name", policy));
 
-        User user = userService.findUserByEmail("admin@samsung.com");
+        User user = userService.getUserByEmail("admin@samsung.com");
         Device device1 = new Device("uuid1", "name1", "type", "model", 1, policyService.initPolicy(route), user);
         device1.setAgents(createAgents(device1));
 
@@ -76,34 +69,33 @@ public class AgentServiceTest {
         deviceService.save(device2);
     }
 
-    @After
-    public void after() {
-        deviceService.removeAll();
-        agentService.deleteAll();
-    }
+    private List<Agent> createAgents(Device device) {
+        String route = "route";
+        List<Agent> agents = new ArrayList<>();
+        Agent agent1 = new Agent("123", "agent1", policyService.initPolicy(route));
+        agent1.setDevice(device);
+        agents.add(agent1);
 
-    @Test(expected = IllegalArgumentException.class)
-    public void test_Init_Empty() {
-        agentService.init("", "", null);
+        return agents;
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void test_Init_Agent_Exists() {
-        agentService.init(agent.getUuid(), "name", null);
+    @After
+    public void after() {
+        deviceService.removeAll();
+        agentService.removeAll();
     }
 
-    @Test
-    public void test_Init() {
-        Device device = agent.getDevice();
-        assertThat(agentService.init("uuid_new", "name", device), is(notNullValue()));
-    }
 
     @Test
     public void testGetAll() {
-        List<Agent> agentList = agentService.findAll();
+        List<Agent> agentList = agentService.getAll();
         assertEquals(2, agentList.size());
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#save(java.lang.Object)}.
+     */
     @Test
     public void testSave() {
         String route = "route";
@@ -113,16 +105,20 @@ public class AgentServiceTest {
         Agent savedAgent = agentService.save(newAgent);
         assertNotNull("ID should appair after save operation", savedAgent.getId());
         assertEquals(agentService.findByUUID(savedAgent.getUuid()).getId(), savedAgent.getId());
-        agentService.delete(savedAgent);
+        agentService.remove(savedAgent);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#remove(java.lang.Object)}.
+     */
     @Test
     public void testRemove() {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
         Agent newAgent = agentService.save(new Agent("newuuid", "newname", policy));
-        agentService.delete(agentService.findOne(newAgent.getId()));
-        assertNull(agentService.findOne(newAgent.getId()));
+        agentService.remove(agentService.findById(newAgent.getId()));
+        assertNull(agentService.findById(newAgent.getId()));
     }
 
     @Test
@@ -131,11 +127,18 @@ public class AgentServiceTest {
         assertEquals(AGENT_UUID, foundAgent.getUuid());
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#count()}.
+     */
     @Test
     public void testCount() {
         assertEquals(2, agentService.count());
     }
 
+    /**
+     * Test init method
+     */
     @Test
     public void testInit() throws Exception {
         String initUuid = "inituuid";
@@ -147,9 +150,12 @@ public class AgentServiceTest {
         assertNotNull(initedAgent);
         assertNotNull(initedAgent.getPolicy());
 
-        agentService.delete(initedAgent);
+        agentService.remove(initedAgent);
     }
 
+    /**
+     * Test init method wrong case
+     */
     @Test(expected = Exception.class)
     public void testSameInit() throws Exception {
         String initUuid = "inituuid";
@@ -166,7 +172,7 @@ public class AgentServiceTest {
         } catch (Exception e) {
             throw e;
         } finally {
-            agentService.delete(initedAgent);
+            agentService.remove(initedAgent);
         }
     }
 
@@ -185,14 +191,4 @@ public class AgentServiceTest {
     public void testAgentsEmptyNotExistentUuid() {
         assertTrue(agentService.findDeviceAgents("unexistent-uuid").isEmpty());
     }
-
-    private List<Agent> createAgents(Device device) {
-        String route = "route";
-        List<Agent> agents = new ArrayList<>();
-        Agent agent1 = new Agent("123", "agent1", policyService.initPolicy(route));
-        agent1.setDevice(device);
-        agents.add(agent1);
-
-        return agents;
-    }
 }
diff --git a/servers/commons/src/test/java/com/samsung/commons/service/CommonCrudServiceTest.java b/servers/commons/src/test/java/com/samsung/commons/service/CommonCrudServiceTest.java
deleted file mode 100644 (file)
index b7a0dbe..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.samsung.commons.service;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.test.util.ReflectionTestUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-public class CommonCrudServiceTest {
-
-    @Mock
-    private CrudRepository crudRepository;
-
-    private CommonCrudService commonCrudService;
-
-    @Before
-    public void setUp() throws Exception {
-        initMocks(this);
-
-        // Allow to call real methods, set field as far as calling constructor is impossible now
-        commonCrudService = Mockito.mock(CommonCrudService.class, CALLS_REAL_METHODS);
-        ReflectionTestUtils.setField(commonCrudService, "repository", crudRepository);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void save() throws Exception {
-        Object entity = new Object();
-        Object saved = new Object();
-        when(crudRepository.save(entity)).thenReturn(saved);
-        assertThat(commonCrudService.save(entity), is(saved));
-        verify(crudRepository, times(1)).save(entity);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void findOne() throws Exception {
-        long id = 1L;
-        Object found = new Object();
-        when(crudRepository.findOne(id)).thenReturn(found);
-        assertThat(commonCrudService.findOne(id), is(found));
-        verify(crudRepository, times(1)).findOne(id);
-    }
-
-    @Test
-    public void findAll() throws Exception {
-        List list = new ArrayList();
-        when(crudRepository.findAll()).thenReturn(list);
-        assertThat(commonCrudService.findAll(), is(list));
-        verify(crudRepository, times(1)).findAll();
-    }
-
-    @Test
-    public void count() throws Exception {
-        long count = 0;
-        when(crudRepository.count()).thenReturn(count);
-        assertThat(commonCrudService.count(), is(count));
-        verify(crudRepository, times(1)).count();
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void exists() throws Exception {
-        Long id = 1L;
-        when(commonCrudService.exists(id)).thenReturn(true);
-        assertThat(commonCrudService.exists(id), is(true));
-        verify(crudRepository, times(1)).exists(id);
-    }
-
-    @Test
-    public void deleteAll() throws Exception {
-        commonCrudService.deleteAll();
-        verify(crudRepository, times(1)).deleteAll();
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void deleteById() throws Exception {
-        Long id = 1L;
-        commonCrudService.delete(id);
-        verify(crudRepository, times(1)).delete(id);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void deleteEntity() throws Exception {
-        Object entity = new Object();
-        commonCrudService.delete(entity);
-        verify(crudRepository, times(1)).delete(entity);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void deleteWithCheck() throws Exception {
-        Long id = 1L;
-        when(crudRepository.exists(id)).thenReturn(true);
-        assertThat(commonCrudService.deleteWithCheck(id), is(true));
-        verify(crudRepository, times(1)).exists(id);
-        verify(crudRepository, times(1)).delete(id);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void deleteWithCheckNotExists() throws Exception {
-        Long id = 1L;
-        when(crudRepository.exists(id)).thenReturn(false);
-        assertThat(commonCrudService.deleteWithCheck(id), is(false));
-        verify(crudRepository, times(1)).exists(id);
-        verify(crudRepository, never()).delete(id);
-    }
-}
\ No newline at end of file
index e592130..1edd449 100644 (file)
@@ -2,30 +2,25 @@ package com.samsung.commons.service;
 
 import com.samsung.commons.domain.*;
 import com.samsung.commons.repository.ReportTypeRepository;
-import com.samsung.commons.service.impl.AgentServiceImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
 
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
 
 /**
  * @author Mail to: <A HREF="mailto:an.petrov@samsung.com">Andriy Petrov,
- * an.petrov@samsung.com</A>
+ *         an.petrov@samsung.com</A>
  * @version 1.0
  * @file DeviceServiceTest.java
  * @brief Unit tests for Device service
@@ -39,9 +34,7 @@ import static org.junit.Assert.*;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DeviceServiceTest {
-
     private static final String DEVICE_UUID = "uuid";
 
     private static final String DEVICE_UUID_WITHOUT_AGENTS = "uuid-no-agents";
@@ -60,7 +53,7 @@ public class DeviceServiceTest {
     private PolicyService policyService;
 
     @Autowired
-    private AgentServiceImpl agentService;
+    private AgentService agentService;
 
     @Autowired
     private ReportService reportService;
@@ -71,48 +64,82 @@ public class DeviceServiceTest {
 
     @Before
     public void before() {
-        user = userService.findUserByEmail("admin@samsung.com");
-        Device device = new Device(DEVICE_UUID, "name", "type", "model", 1, policyService.initPolicy("route"), user);
+        String route = "route";
+        user = userService.getUserByEmail("admin@samsung.com");
+        Device device = new Device(DEVICE_UUID, "name", "type", "model", 1, policyService.initPolicy(route), user);
         device.setReports(createReports(device));
         device.setAgents(createAgents(device));
 
         deviceService.save(device);
-        deviceService.save(new Device(DEVICE_UUID_WITHOUT_AGENTS, "name2", "type", "model", 1, policyService.initPolicy("route"), user));
+        deviceService.save(new Device(DEVICE_UUID_WITHOUT_AGENTS, "name2", "type", "model", 1, policyService.initPolicy(route), user));
+
+        // Alone agent. No device.
+        agentService.save(new Agent("789", "agent3", policyService.initPolicy(route)));
+    }
+
+    private List<Report> createReports(Device device) {
+        List<Report> reports = new ArrayList<>();
+        Report report = new Report(reportTypeRepository.findByType(ReportType.Type.SIM.type), "report", "date", 1, device);
+        report.setDevice(device);
+        reports.add(report);
+
+        return reports;
+    }
+
+    private List<Agent> createAgents(Device device) {
+        String route = "route";
+        List<Agent> agents = new ArrayList<>();
+        Agent agent1 = new Agent("123", "agent1", policyService.initPolicy(route));
+        agent1.setDevice(device);
+        agents.add(agent1);
+
+        Agent agent2 = new Agent("456", "agent2", policyService.initPolicy(route));
+        agent2.setDevice(device);
+        agents.add(agent2);
 
-        // Unbounded agent (no associated device)
-        agentService.save(new Agent("789", "agent3", policyService.initPolicy("route")));
+        return agents;
     }
 
     @After
     public void after() {
         deviceService.removeAll();
 
-        // Some agents aren't bound to device (so need to delete'em separately)
-        agentService.deleteAll();
+        // Some agents aren't bound to device
+        agentService.removeAll();
     }
 
     @Test
     public void testGetByUserAndStatus() {
-        assertEquals(deviceService.findUserDevicesByStatus(user.getId(), 1).size(), 2);
-        assertEquals(deviceService.findUserDevicesByStatus(user.getId(), 0).size(), 0);
-    }
+        List<Device> deviceList = deviceService.findUserDevicesByStatus(user.getId(), 1);
+        assertEquals(deviceList.size(), 2);
 
-    @Test
-    public void testFindByUser() {
-        assertThat(deviceService.findByUser(user), is(not(empty())));
+        deviceList = deviceService.findUserDevicesByStatus(user.getId(), 0);
+        assertEquals(deviceList.size(), 0);
     }
 
     @Test
     public void testGetByUserAndType() {
-        assertEquals(deviceService.findUserDevicesByType(user.getId(), "type").size(), 2);
-        assertEquals(deviceService.findUserDevicesByType(user.getId(), "wrong-type").size(), 0);
+        List<Device> deviceList = deviceService.findUserDevicesByType(user.getId(), "type");
+        assertEquals(deviceList.size(), 2);
+
+        deviceList = deviceService.findUserDevicesByType(user.getId(), "wrong-type");
+        assertEquals(deviceList.size(), 0);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.DeviceService#getAll()}.
+     */
     @Test
     public void testGetAll() {
-        assertEquals(deviceService.getAll().size(), 2);
+        List<Device> deviceList = deviceService.getAll();
+        assertEquals(deviceList.size(), 2);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#save(java.lang.Object)}.
+     */
     @Test
     public void testSave() {
         String route = "route";
@@ -125,26 +152,23 @@ public class DeviceServiceTest {
         assertEquals(deviceService.findByUUID(savedDevice.getUuid()).getId(), savedDevice.getId());
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#remove(java.lang.Object)}.
+     */
     @Test
     public void testRemove() {
-        Policy policy = policyService.initPolicy("route");
+        String route = "route";
+        Policy policy = policyService.initPolicy(route);
         Device newDevice = deviceService.save(new Device("newuuid", "newname", "newtype", "newmodel", 0, policy, user));
         deviceService.remove(deviceService.findById(newDevice.getId()));
         assertNull(deviceService.findById(newDevice.getId()));
     }
 
-    // Just to increase coverage
-    // Must remove all without exceptions
-    @Test
-    public void testRemoveAll() {
-        Device saved = deviceService.save(new Device("some_uuid", "name", "type", "model", 1, policyService.initPolicy("route"), user));
-
-        HashSet<Device> devices = new HashSet<>();
-        devices.add(saved);
-
-        deviceService.remove(devices);
-    }
-
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#findById(Long)} (java.lang.Long)}.
+     */
     @Test
     public void testFindByUUID() {
         assertEquals(DEVICE_UUID, deviceService.findByUUID(DEVICE_UUID).getUuid());
@@ -181,24 +205,30 @@ public class DeviceServiceTest {
 
     @Test
     public void testAgentsAndReportsMustBeRemovedWithDevice() {
-        deviceService.remove(deviceService.findByUUID(DEVICE_UUID));
+        Device device = deviceService.findByUUID(DEVICE_UUID);
+
+        deviceService.remove(device);
 
         // Device removed
         assertNull(deviceService.findByUUID(DEVICE_UUID));
 
         // Agents removed
-        assertThat(agentService.findByUUID("123"), is(nullValue()));
-        assertThat(agentService.findByUUID("456"), is(nullValue()));
+        Agent agent1 = agentService.findByUUID("123");
+        Agent agent2 = agentService.findByUUID("456");
+        assertThat(agent1, is(nullValue()));
+        assertThat(agent2, is(nullValue()));
 
         // Reports removed
-        assertTrue(reportService.findReportsByDeviceUuid(DEVICE_UUID).isEmpty());
+        List<Report> reports = reportService.findReportsByDeviceUuid(DEVICE_UUID);
+        assertTrue(reports.isEmpty());
     }
 
     @Test
-    public void testInit() {
+    public void testInit() throws Exception {
+        String route = "route";
         String initUuid = "inituuid";
         assertEquals(2, deviceService.count());
-        deviceService.init(initUuid, "initname", "inittype", "initmodel", 0, user, "route");
+        deviceService.init(initUuid, "initname", "inittype", "initmodel", 0, user, route);
         assertEquals(3, deviceService.count());
 
         Device initedDevice = deviceService.findByUUID(initUuid);
@@ -206,16 +236,15 @@ public class DeviceServiceTest {
         assertNotNull(initedDevice.getPolicy());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void test_Init_Empty_Fields() {
-        deviceService.init("uuid", "", "", "", 0, null, null);
-    }
-
+    /**
+     * Test init method wrong case
+     */
     @Test(expected = Exception.class)
     public void testSameInit() throws Exception {
+        String route = "route";
         String initUuid = "inituuid";
         assertEquals(2, deviceService.count());
-        deviceService.init(initUuid, "initname", "inittype", "initmodel", 0, user, "route");
+        deviceService.init(initUuid, "initname", "inittype", "initmodel", 0, user, route);
         assertEquals(3, deviceService.count());
 
         Device initedDevice = deviceService.findByUUID(initUuid);
@@ -223,34 +252,11 @@ public class DeviceServiceTest {
         assertNotNull(initedDevice.getPolicy());
 
         try {
-            deviceService.init(initUuid, "duplikatename", "duplikatetype", "duplikatemodel", 0, user, "route");
+            deviceService.init(initUuid, "duplikatename", "duplikatetype", "duplikatemodel", 0, user, route);
         } catch (Exception e) {
             throw e;
         } finally {
             deviceService.remove(initedDevice);
         }
     }
-
-    private List<Report> createReports(Device device) {
-        List<Report> reports = new ArrayList<>();
-        Report report = new Report(reportTypeRepository.findByType(ReportType.Type.SIM.type), "report", "date", 1, device);
-        report.setDevice(device);
-        reports.add(report);
-
-        return reports;
-    }
-
-    private List<Agent> createAgents(Device device) {
-        String route = "route";
-        List<Agent> agents = new ArrayList<>();
-        Agent agent1 = new Agent("123", "agent1", policyService.initPolicy(route));
-        agent1.setDevice(device);
-        agents.add(agent1);
-
-        Agent agent2 = new Agent("456", "agent2", policyService.initPolicy(route));
-        agent2.setDevice(device);
-        agents.add(agent2);
-
-        return agents;
-    }
 }
\ No newline at end of file
index b21eaaf..68b11c0 100644 (file)
 
 package com.samsung.commons.service;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.samsung.commons.domain.IotCloudUser;
 import com.samsung.commons.domain.User;
-import com.samsung.commons.service.impl.UserServiceImpl;
+import com.samsung.commons.repository.UserRepository;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.context.annotation.ImportResource;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
 
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.*;
+import org.springframework.test.context.web.WebAppConfiguration;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class IoTCloudServiceTest {
 
+
     @Autowired
     private IotCloudService iotCloudService;
-
+    
     @Autowired
-    private RoleService roleService;
+    private UserRepository userRepository;
 
-    @Autowired
-    private UserServiceImpl userService;
+    private final String adminEmail = "admin@samsung.com";
+    private final String userEmail = "user@samsung.com";
+    private final String wrongUserEmail = "wronguser@samsung.com";
+
+    private static final Long dbUserID = (long) 1;
+    private static final String dbUUID = "1234567890";
+    private static final String userUUID = "uuid";
+    private static final String adminUUID = "auid";
 
-    private static final String UUID = "1234567890";
 
     @Before
     public void init() {
-        iotCloudService.deleteAllUsers();
-        userService.removeByUserName("new_username");
-    }
-
-    @Test
-    public void test_Count() {
-        userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        iotCloudService.createAndSaveUser("email", UUID);
-        assertThat(iotCloudService.usersCount(), is(1L));
-    }
-
-    @Test
-    public void test_Create_And_Save_User() {
-        userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        assertNotNull(iotCloudService.createAndSaveUser("email", UUID));
-        assertEquals(iotCloudService.usersCount(), 1);
+        rollBackDBChanges();
     }
 
+    /*@Test
+    public void testCreateAndSaveUser() {
+        IotCloudUser iotCloudUser = iotCloudService.createAndSaveUser(userEmail, userUUID);
+        assertNotNull(iotCloudUser);
+        assertEquals(iotCloudService.usersCount(), 2);
+    }*/
+    
+    /*@Test
+    public void testDeleteAllUsers() {
+        iotCloudService.createAndSaveUser(adminEmail, adminUUID);
+        iotCloudService.createAndSaveUser(userEmail, userUUID);
+        assertEquals(iotCloudService.usersCount(), 3);
+        iotCloudService.deleteAllUsers();
+        assertEquals(iotCloudService.usersCount(), 0);
+    }*/
+
+    /*@Test(expected = IotCloudUserNotExists.class)
+    public void testCreateAndSaveUserWithWrongUserEmail() {
+        iotCloudService.createAndSaveUser(wrongUserEmail, userUUID);
+    }*/
+    
     @Test
-    public void test_Create_And_Save_User_That_Already_Exists() {
-        userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        assertNotNull(iotCloudService.createAndSaveUser("email", UUID));
-        assertNull(iotCloudService.createAndSaveUser("email", UUID));
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void test_Create_And_Save_User_Wrong_Email() {
-        iotCloudService.createAndSaveUser("user@example.com", null);
+    public void testFindAssociatedUserByUuid() {
+        User user = iotCloudService.findAssociatedUserByUuid(dbUUID);
+        assertNotNull(user);
     }
-
-    @Test
-    public void test_Find_All() {
-        userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        assertNotNull(iotCloudService.createAndSaveUser("email", UUID));
-        assertThat(iotCloudService.findAll(), is(not(empty())));
+    
+   /* @Test(expected = IotCloudUserNotExists.class)
+    public void testFindAssociatedUserByUuidWithWongUuid() {
+        iotCloudService.findAssociatedUserByUuid("");
     }
-
-    @Test
-    public void test_Find_By_User() {
-        User save = userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        iotCloudService.createAndSaveUser("email", UUID);
-        assertNotNull(iotCloudService.findByUser(save));
+*/
+    private void rollBackDBChanges() {
+        iotCloudService.deleteAllUsers();
+        User user = userRepository.findOne(dbUserID);
+        iotCloudService.createAndSaveUser(user.getEmail(), dbUUID);
     }
 
-    @Test
-    public void testFindAssociatedUserByUuid() {
-        User savedUser = userService.save(new User("new_username", "email", roleService.getByName("ROLE_ADMIN")));
-        iotCloudService.createAndSaveUser("email", UUID);
-        assertThat(iotCloudService.findAssociatedUserByUuid(UUID), is(savedUser));
-    }
 }
index 9ed2eae..841c8c4 100644 (file)
@@ -4,14 +4,11 @@ import com.samsung.commons.domain.Agent;
 import com.samsung.commons.domain.Device;
 import com.samsung.commons.domain.Policy;
 import com.samsung.commons.domain.User;
-import com.samsung.commons.service.impl.AgentServiceImpl;
-import com.samsung.commons.service.impl.PolicyServiceImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -19,14 +16,12 @@ import org.springframework.test.context.web.WebAppConfiguration;
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
 
+
 /**
  * @author Mail to: <A HREF="mailto:an.petrov@samsung.com">Andriy Petrov,
- * an.petrov@samsung.com</A>
+ *         an.petrov@samsung.com</A>
  * @version 1.0
  * @file PolicyServiceTest.java
  * @brief Unit tests for Policy service
@@ -38,20 +33,20 @@ import static org.junit.Assert.*;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class PolicyServiceTest {
+    static final String newPolicyJson = "new policy";
 
     @Autowired
     private UserService userService;
 
     @Autowired
-    private PolicyServiceImpl policyService;
+    private PolicyService policyService;
 
     @Autowired
     private DeviceService deviceService;
 
     @Autowired
-    private AgentServiceImpl agentService;
+    private AgentService agentService;
 
     private User user;
 
@@ -61,17 +56,17 @@ public class PolicyServiceTest {
 
     private Policy policy1;
 
-    private static final long NON_EXISTENT_ID = 42L;
+    private Policy policy2;
 
     @Before
-    public void before() {
+    public void init() {
         String route = "route";
-        user = userService.findUserByEmail("admin@samsung.com");
+        user = userService.getUserByEmail("admin@samsung.com");
         Device device = new Device("deviceuuid", "name", "type", "model", 0, policyService.initPolicy(route), user);
         List<Agent> agents = new ArrayList<>();
         policy1 = policyService.initPolicy(route);
         Agent agent1 = new Agent("agent1uuid", "name1", policy1);
-        Policy policy2 = policyService.initPolicy(route);
+        policy2 = policyService.initPolicy(route);
         Agent agent2 = new Agent("agent2uuid", "name2", policy2);
         agent1.setDevice(device);
         agent2.setDevice(device);
@@ -83,9 +78,9 @@ public class PolicyServiceTest {
     }
 
     @After
-    public void after() {
+    public void release() {
         deviceService.remove(device);
-        agentService.delete(agent);
+        agentService.remove(agent);
     }
 
     @Test
@@ -95,40 +90,30 @@ public class PolicyServiceTest {
     }
 
     @Test
-    public void test_Find_By_Device_Id() {
-        assertThat(policyService.findByDeviceId(device.getId()), is(notNullValue()));
-    }
-
-    @Test
-    public void test_Find_By_Device_Id_Negative() {
-        assertThat(policyService.findByDeviceId(NON_EXISTENT_ID), is(nullValue()));
-    }
-
-    @Test
     public void testUpdatePolicy() throws Exception {
         String route = "route";
         assertNotNull(policyService.findByDeviceId(device.getId()));
         assertEquals(Policy.getDefaultPolicy(), policyService.findByDeviceId(device.getId()).getPolicy());
         Policy newPolicy = policyService.findByDeviceId(device.getId());
-        newPolicy.setPolicy("new policy", route);
+        newPolicy.setPolicy(newPolicyJson, route);
         policyService.save(newPolicy);
-        assertEquals("new policy", policyService.findByDeviceId(device.getId()).getPolicy());
+        assertEquals(newPolicyJson, policyService.findByDeviceId(device.getId()).getPolicy());
     }
 
     @Test
     public void testRemovePolicy() throws Exception {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
-        assertNotNull(policyService.findOne(policy.getId()));
-        policyService.delete(policyService.findOne(policy.getId()));
-        assertNull(policyService.findOne(policy.getId()));
+        assertNotNull(policyService.findById(policy.getId()));
+        policyService.remove(policyService.findById(policy.getId()));
+        assertNull(policyService.findById(policy.getId()));
         policy = policyService.initPolicy(route);
         Device newDevice = deviceService.save(new Device("newuuid", "name", "type", "model", 0, policy, user));
         assertNotNull(policyService.findByDeviceId(newDevice.getId()));
-        policyService.delete(policyService.findByDeviceId(newDevice.getId()));
+        policyService.remove(policyService.findByDeviceId(newDevice.getId()));
         assertEquals("", policyService.findByDeviceId(newDevice.getId()).getPolicy());
         deviceService.remove(newDevice);
-        assertNull(policyService.findOne(policy.getId()));
+        assertNull(policyService.findById(policy.getId()));
     }
 
     @Test
@@ -142,30 +127,34 @@ public class PolicyServiceTest {
 
     @Test
     public void testSetDevicePolicy() throws Exception {
-        Policy policy = device.getPolicy();
-        Policy setPolicy = policyService.setDevicePolicy(device.getUuid(), "new policy", "route");
-        assertNotEquals(policy, setPolicy);
-        assertEquals("new policy", setPolicy.getPolicy());
+        String route = "route";
+        Policy p = device.getPolicy();
+        Policy setPolicy = policyService.setDevicePolicy(device.getUuid(), newPolicyJson, route);
+        assertNotEquals(p, setPolicy);
+        assertEquals(newPolicyJson, setPolicy.getPolicy());
     }
 
     @Test(expected = Exception.class)
     public void testSetDevicePolicyException() throws Exception {
-        policyService.setDevicePolicy("wrongUUID", "new policy", "route");
+        String route = "route";
+        String wrongUuid = "wrongUUID";
+        policyService.setDevicePolicy(wrongUuid, newPolicyJson, route);
     }
 
     @Test
     public void testSetAgentPolicy() throws Exception {
-        Policy policy = agent.getPolicy();
-        Policy setPolicy = policyService.setAgentPolicy(agent.getUuid(), "new policy", "route");
-        assertNotEquals(policy, setPolicy);
-        assertEquals("new policy", setPolicy.getPolicy());
+        String route = "route";
+        Policy p = agent.getPolicy();
+        Policy setPolicy = policyService.setAgentPolicy(agent.getUuid(), newPolicyJson, route);
+        assertNotEquals(p, setPolicy);
+        assertEquals(newPolicyJson, setPolicy.getPolicy());
     }
 
     @Test(expected = Exception.class)
     public void testSetAgentPolicyException() throws Exception {
         String route = "route";
         String wrongUuid = "wrongUUID";
-        policyService.setAgentPolicy(wrongUuid, "new policy", route);
+        policyService.setAgentPolicy(wrongUuid, newPolicyJson, route);
     }
 
     @Test
@@ -178,6 +167,6 @@ public class PolicyServiceTest {
 
     @Test
     public void testPolicyByDeviceUuidAndByAgentUuidNegative() throws Exception {
-        assertNull(policyService.findByDeviceUuidAndByAgentUuid("inexistent-deviceuuid", "inexistent-agentuuid"));
+        assertNull(policyService.findByDeviceUuidAndByAgentUuid("unexistent-deviceuuid", "unexistent-agentuuid"));
     }
 }
\ No newline at end of file
diff --git a/servers/commons/src/test/java/com/samsung/commons/service/ReportServiceTest.java b/servers/commons/src/test/java/com/samsung/commons/service/ReportServiceTest.java
deleted file mode 100644 (file)
index 9367333..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * @author Mail to: <A HREF="mailto:an.petrov@samsung.com">Andriy Petrov, an.petrov@samsung.com</A>
- * @version 1.0
- * @file ReportTypeServiceTest.java
- * @brief UT for ReportType service
- * @date Created : 26/07/16
- * @date Created : 26/07/16
- * @copyright In Samsung Ukraine R&D Center (SRK under a contract between)
- * @par LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
- * @par Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
- */
-
-package com.samsung.commons.service;
-
-import com.samsung.commons.domain.Device;
-import com.samsung.commons.domain.Report;
-import com.samsung.commons.domain.ReportType;
-import com.samsung.commons.repository.ReportTypeRepository;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import static com.samsung.commons.domain.ReportType.Type.SIM;
-import static com.samsung.commons.domain.ReportType.Type.SMACK;
-import static com.samsung.commons.domain.ReportType.Type.SMART_SECURITY;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.collection.IsEmptyCollection.empty;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-public class ReportServiceTest {
-
-    @Autowired
-    private ReportService reportService;
-
-    @Autowired
-    private DeviceService deviceService;
-
-    @Autowired
-    private UserService userService;
-
-    @Autowired
-    private PolicyService policyService;
-
-    @Autowired
-    private ReportTypeRepository reportTypeRepository;
-
-    private Device device;
-
-    private ReportType reportType;
-
-    private Report report;
-
-    private static final long NON_EXISTENT_ID = 42L;
-
-    @Before
-    public void before() {
-        device = new Device("uuid", "name", "type", "model", 1,
-                policyService.initPolicy("policy"), userService.findUserByEmail("admin@samsung.com"));
-        deviceService.save(device);
-        reportType = reportTypeRepository.findByType(ReportType.Type.SIM.type);
-        report = reportService.save(new Report(reportType, "report", "date", 0, device));
-    }
-
-    @After
-    public void after() {
-        deviceService.removeAll();
-    }
-
-    @Test
-    public void test_Save() {
-        assertThat(reportService.save(device.getId(), SMART_SECURITY.type, "date", 1, "report"), is(notNullValue()));
-    }
-
-    @Test
-    public void test_Save_Report() {
-        // Report was found
-        assertThat(reportService.saveReport(device.getId(), SIM.type, "date", 1, "report"), is(notNullValue()));
-
-        // Report is new
-        assertThat(reportService.saveReport(device.getId(), SMART_SECURITY.type, "date", 1, "report"), is(notNullValue()));
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void test_Save_Report_Wrong_Device_Id() {
-        reportService.saveReport(NON_EXISTENT_ID, SMART_SECURITY.type, null, 0, null);
-    }
-
-    @Test
-    public void test_Find_Report_By_Id() {
-        assertThat(reportService.findById(report.getId()), is(notNullValue()));
-        assertThat(reportService.findById(NON_EXISTENT_ID), is(nullValue()));
-    }
-
-    @Test
-    public void test_Find_Reports_By_Device_Id() {
-        assertThat(reportService.findReportsByDeviceId(device.getId()), is(not(empty())));
-        assertThat(reportService.findReportsByDeviceId(NON_EXISTENT_ID), is(empty()));
-    }
-
-    @Test
-    public void test_Find_Report_By_Did_And_Type() {
-        assertThat(reportService.findReport(device.getId(), ReportType.Type.SIM), is(notNullValue()));
-    }
-
-    @Test
-    public void test_Find_Report_By_Did_And_Type_Negative() {
-        assertThat(reportService.findReport(device.getId(), ReportType.Type.SMACK), is(nullValue()));
-        assertThat(reportService.findReport(NON_EXISTENT_ID, ReportType.Type.SIM), is(nullValue()));
-    }
-
-    @Test
-    public void test_FindAll() {
-        assertThat(reportService.findAll().size(), is(1));
-    }
-
-    @Test
-    public void test_Remove() {
-        reportService.remove(report);
-        assertThat(reportService.findAll(), is(empty()));
-    }
-
-    @Test
-    public void test_RemoveAll() {
-        reportService.removeAll();
-        assertThat(reportService.findAll(), is(empty()));
-    }
-
-    @Test
-    public void test_Count() {
-        assertThat(reportService.count(), is(1L));
-    }
-}
index d1b5889..d26ed18 100644 (file)
 package com.samsung.commons.service;
 
 import com.samsung.commons.domain.ReportType;
-import com.samsung.commons.service.impl.ReportTypeServiceImpl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -28,12 +26,14 @@ import static org.junit.Assert.*;
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class ReportTypeServiceTest {
 
     @Autowired
-    private ReportTypeServiceImpl reportTypeService;
-    
+    private ReportTypeService reportTypeService;
+
+    private final String NAME = "TestReportTypeName";
+
+
     @Test
     public void testFindByName() {
         ReportType simReportType = reportTypeService.findByName(ReportType.Type.SIM.toString());
@@ -41,4 +41,53 @@ public class ReportTypeServiceTest {
         assertNotNull(simReportType.getId());
         assertEquals(simReportType.getType(), ReportType.Type.SIM.toString());
     }
+
+    @Test
+    public void testSave() {
+        ReportType newReportType = new ReportType(NAME);
+        newReportType = reportTypeService.save(newReportType);
+        assertNotNull("ID should appear after save operation", newReportType.getId());
+
+        ReportType foundReportType = reportTypeService.findById(newReportType.getId());
+
+        assertEquals(newReportType.getId(), foundReportType.getId());
+
+        reportTypeService.remove(newReportType);
+    }
+
+
+    @Test
+    public void testRemove() {
+        ReportType newReportType = new ReportType(NAME);
+        newReportType = reportTypeService.save(newReportType);
+        assertNotNull(newReportType.getId());
+
+        ReportType foundReportType = reportTypeService.findById(newReportType.getId());
+
+        assertEquals(newReportType.getId(), foundReportType.getId());
+
+        reportTypeService.remove(foundReportType);
+        assertNull(reportTypeService.findById(foundReportType.getId()));
+    }
+
+
+    @Test
+    public void testFindById() {
+        ReportType newReportType = new ReportType(NAME);
+        newReportType = reportTypeService.save(newReportType);
+        assertNotNull(newReportType.getId());
+
+        ReportType foundReportType = reportTypeService.findById(newReportType.getId());
+
+        assertEquals(newReportType.getId(), foundReportType.getId());
+
+        reportTypeService.remove(newReportType);
+    }
+
+
+    @Test
+    public void testCount() {
+        assertEquals(reportTypeService.count(), 4); // hardcoded in init.sql script (not changed in runtime)
+    }
+
 }
index dcc1102..42c8a0d 100644 (file)
 package com.samsung.commons.service;
 
 import com.samsung.commons.domain.Role;
-import com.samsung.commons.service.impl.RoleServiceImpl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import java.util.List;
+
+import static org.junit.Assert.*;
 
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class RoleServiceTest {
 
     @Autowired
-    private RoleServiceImpl roleService;
+    private RoleService roleService;
+
+
+    @Test
+    public void testGetAll() {
+        List<Role> roleList = roleService.getAll();
+        assertTrue(roleList.size() == 2); // hardcoded in init.sql file
+    }
+
+
+    @Test
+    public void testSave() {
+        String roleName = "TestSave";
+        Role role = new Role(roleName);
+
+        Role savedRole = roleService.save(role);
+        assertNotNull("ID should appear after save operation", savedRole.getId());
+        assertEquals(role.getId(), savedRole.getId());
+
+        Role foundRole = roleService.findById(savedRole.getId());
+        assertNotNull(foundRole);
+        assertEquals(savedRole.getId(), foundRole.getId());
+        assertEquals(savedRole.getName(), foundRole.getName());
+
+        roleService.remove(savedRole);
+    }
+
+
+    @Test
+    public void testRemove() {
+        String roleName = "TestDelete";
+        Role role = new Role(roleName);
+
+        Role savedRole = roleService.save(role);
+        assertNotNull("ID should appear after save operation", savedRole.getId());
+        assertEquals(role.getId(), savedRole.getId());
+        roleService.remove(savedRole);
+
+        Role foundRole = roleService.findById(savedRole.getId());
+        assertNull(foundRole);
+    }
+
+
+    @Test
+    public void testFindById() {
+        Role adminRole = roleService.findById(1l); // hardcoded in init.sql file
+        Role userRole = roleService.findById(2l); // hardcoded in init.sql file
+
+        assertNotNull(adminRole);
+        assertNotNull(userRole);
+        assertEquals("ROLE_ADMIN", adminRole.getName());
+        assertEquals("ROLE_USER", userRole.getName());
+    }
+
+
+    @Test
+    public void testCount() {
+        assertEquals(2, roleService.count()); // hardcoded in init.sql file
+    }
 
     @Test
     public void getByName() {
index 8e6658e..55b63a5 100644 (file)
@@ -15,110 +15,141 @@ import com.samsung.commons.domain.CustomUserDetails;
 import com.samsung.commons.domain.Role;
 import com.samsung.commons.domain.User;
 import com.samsung.commons.service.impl.UserDetailsServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mockito;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
-import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class UserDetailsServiceTest {
 
+    //WARNING: UserDetailsServiceImpl implements two interfaces
+    //1. UserDetailsService
+    //2. org.springframework.security.core.userdetails.UserDetailsService
+    //UT will test UserDetailsServiceImpl class instead of UserDetailsService (interface) 
     @Autowired
-    private UserDetailsServiceImpl detailsService;
+    private UserDetailsServiceImpl customUserDetailsService;
 
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     @Autowired
     private RoleService roleService;
 
-    private final static String USER_EMAIL = "someUser@email.com";
-
-    private final String ROLE_ADMIN = "ROLE_ADMIN";
+    final static Long roleId = 1l; // admin
+    final static String securityContextAdminEmail = "admin@samsung.com";
+    final static String userEmail = "someUser@email.com";
 
     private User user;
-
     private CustomUserDetails details;
 
     @Before
-    public void before() {
-        initialData();
+    public void iniDB() {
+        Role role = roleService.findById(roleId);
+        assertNotNull(role);
+
+        user = userService.save(new User("someUser", userEmail, role));
+        assertNotNull(user);
+
+        details = customUserDetailsService.save(new CustomUserDetails("somePass", "someRestorePassLink.com", user));
+        assertNotNull(details);
+    }
+
+    @Before
+    public void setRole() {
+        UserDetails useDetails = Mockito.mock(UserDetails.class);
+        Authentication authentication = Mockito.mock(Authentication.class);
+        // Mockito.whens() for your authorization object
+        SecurityContext securityContext = Mockito.mock(SecurityContext.class);
+        Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
+        Mockito.when(authentication.getPrincipal()).thenReturn(useDetails);
+        Mockito.when(useDetails.getUsername()).thenReturn(securityContextAdminEmail);
+        SecurityContextHolder.setContext(securityContext);
     }
 
     @After
-    public void after() {
-        detailsService.remove(details);
+    public void cleanDB() {
+        //cascade remove
+        customUserDetailsService.remove(details);
     }
 
     @Test
     public void testSave() {
-        Role roleAdmin = roleService.getByName(ROLE_ADMIN);
-        User userToSave = userService.save(new User("userToSave", "userToSave@email.com", roleAdmin));
-        CustomUserDetails detailsToSave = detailsService.save(new CustomUserDetails("passToSave", "restorePassLinkToSave.com", userToSave));
-        assertNotNull(detailsToSave);
-        detailsService.remove(detailsToSave);
+        Role roleAdmin = roleService.findById(roleId);
+        assertNotNull(roleAdmin);
+
+        User userToSave = new User("userToSave", "userToSave@email.com", roleAdmin);
+        assertNotNull(userToSave);
+        assertNotNull(userToSave = userService.save(userToSave));
+
+        CustomUserDetails detailsToSave = new CustomUserDetails("passToSave", "restorePassLinkToSave.com", userToSave);
+        assertNull(detailsToSave.getId());
+
+        assertNotNull(detailsToSave = customUserDetailsService.save(detailsToSave));
+        assertNotNull(detailsToSave.getId());
+
+        assertNotNull(customUserDetailsService.findById(detailsToSave.getId()));
+        customUserDetailsService.remove(detailsToSave);
     }
 
     @Test
     public void testRemove() {
-        User userToSave = userService.save(new User("userToSave", "userToSave@email.com", roleService.getByName(ROLE_ADMIN)));
-        CustomUserDetails detailsToSave = detailsService.save(new CustomUserDetails("passToSave", "restorePassLinkToSave.com", userToSave));
-        detailsService.remove(detailsToSave);
-        assertNull(detailsService.findById(detailsToSave.getId()));
+        User userToSave = userService.save(new User("userToSave", "userToSave@email.com", roleService.findById(roleId)));
+        Long userId = userToSave.getId();
+        assertNotNull(userId);
+        CustomUserDetails detailsToSave = customUserDetailsService.save(new CustomUserDetails("passToSave", "restorePassLinkToSave.com", userToSave));
+        Long detailsId = detailsToSave.getId();
+        assertNotNull(detailsId);
+        assertNotNull(customUserDetailsService.findById(detailsId));
+
+        customUserDetailsService.remove(detailsToSave);
+        assertNull(customUserDetailsService.findById(detailsId));
+        assertNull(userService.findById(userId));
     }
 
     @Test
     public void testFindById() {
-        assertNotNull(detailsService.findById(details.getId()));
+        CustomUserDetails foundDetails = customUserDetailsService.findById(details.getId());
+        assertNotNull(foundDetails);
+        assertEquals(details.getId(), foundDetails.getId());
     }
 
 
     @Test
     public void testCount() {
-        assertEquals(2, detailsService.count());
+        //admin user detials is predefined in init.sql
+        //another user was made by @Before annotation
+        assertEquals(2, customUserDetailsService.count());
     }
 
     @Test
     public void testFindByUserId() {
-        assertNotNull(detailsService.findByUserId(user.getId()));
+        CustomUserDetails foundDetails = customUserDetailsService.findByUserId(user.getId());
+        assertNotNull(foundDetails);
+        assertEquals(details.getId(), foundDetails.getId());
     }
 
     @Test
     public void testLoadUserByUsername_shouldOK() {
-        assertNotNull(detailsService.loadUserByUsername(USER_EMAIL));
+        UserDetails ud = customUserDetailsService.loadUserByUsername(userEmail);
+        assertNotNull(ud);
     }
 
     @Test(expected = org.springframework.security.core.userdetails.UsernameNotFoundException.class)
-    public void testLoadUserByUsername_shouldException() {
-        detailsService.loadUserByUsername("unknown@email.com");
-    }
-
-    @Test
-    public void test_RemoveAll() {
-        User admin = userService.findByUsername("admin");
-        assertThat(detailsService.count(), is(2L));
-        detailsService.removeAll();
-        assertThat(detailsService.count(), is(0L));
-
-        // Restore
-        userService.save(admin);
-        initialData();
-    }
-
-    private void initialData() {
-        user = userService.save(new User("someUser", USER_EMAIL, roleService.getByName(ROLE_ADMIN)));
-        details = detailsService.save(new CustomUserDetails("somePass", "someRestorePassLink.com", user));
+    public void testLoadUserByUsername_shouldExeption() {
+        customUserDetailsService.loadUserByUsername("unknown@email.com");
     }
 }
index f7c9c01..76aedf8 100644 (file)
@@ -14,8 +14,6 @@ package com.samsung.commons.service;
 
 import com.samsung.commons.domain.Role;
 import com.samsung.commons.domain.User;
-import com.samsung.commons.service.impl.RoleServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -25,199 +23,190 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
 import javax.servlet.http.HttpServletRequest;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.List;
 
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.*;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+@ContextConfiguration(locations = { "classpath:root-context.xml" })
 public class UserServiceTest {
-
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     @Autowired
-    private UserDetailsService userDetailsService;
+    private RoleService roleService;
 
-    @Autowired
-    private RoleServiceImpl roleService;
+    // admin properties are hardcoded in USERS tab by init.sql script
+    private final Long adminId = 1l;
+    private final String adminName = "admin";
+    private final String adminEmail = "admin@samsung.com";
 
-    private final String ADMIN_EMAIL = "admin@samsung.com";
+    private final String uniqueEmail = "some@uniquie.email";
 
     private Role adminRole;
 
     @Before
-    public void before() {
-        adminRole = userService.findUserByEmail(ADMIN_EMAIL).getRole();
+    public void setRole() {
+        adminRole = roleService.findById(adminId);
+        assertNotNull(adminRole);
 
         UserDetails useDetails = Mockito.mock(UserDetails.class);
         Authentication authentication = Mockito.mock(Authentication.class);
         SecurityContext securityContext = Mockito.mock(SecurityContext.class);
         Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
         Mockito.when(authentication.getPrincipal()).thenReturn(useDetails);
-        Mockito.when(useDetails.getUsername()).thenReturn(ADMIN_EMAIL);
+        Mockito.when(useDetails.getUsername()).thenReturn(adminEmail);
         SecurityContextHolder.setContext(securityContext);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#findByUsername(String)}.
+     */
     @Test
-    public void findByUsername() {
+    public void testFindByUsername() {
         // default user - admin, hardcoded in init.sql
-        User user = userService.findUserByEmail(ADMIN_EMAIL);
+        User user = userService.getUserByEmail(adminEmail);
 
         assertNotNull(user);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#isEmailAvailable(HttpServletRequest)}.
+     */
     @Test
-    public void isEmailAvailableHttpServletRequest_ok() {
-        HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
-        Mockito.when(httpServletRequest.getParameter("email")).thenReturn("uniqueEmail");
-
-        assertTrue(userService.isEmailAvailable(httpServletRequest.getParameter("email")));
-    }
+    public void testIsEmailAvailableHttpServletRequest_ok() {
+        HttpServletRequest httpServleteRequest = Mockito.mock(HttpServletRequest.class);
+        // Mockito.whens() for your authorization object
 
-    @Test
-    public void isEmailAvailableHttpServletRequest_notUniqueEmail() {
-        HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
-        Mockito.when(httpServletRequest.getParameter("email")).thenReturn(ADMIN_EMAIL);
+        Mockito.when(httpServleteRequest.getParameter("email")).thenReturn("uniqueEmail");
 
-        assertFalse(userService.isEmailAvailable(httpServletRequest.getParameter("email")));
+        assertTrue(userService.isEmailAvailable(httpServleteRequest));
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#isEmailAvailable(HttpServletRequest)}.
+     */
     @Test
-    public void isEmailAvailableString_ok() {
-        assertTrue(userService.isEmailAvailable("some@unique.email"));
-    }
+    public void testIsEmailAvailableHttpServletRequest_notUniqueEmail() {
+        HttpServletRequest httpServleteRequest = Mockito.mock(HttpServletRequest.class);
+        // Mockito.whens() for your authorization object
 
-    @Test
-    public void isEmailAvailableString_notUniqueEmail() {
-        assertFalse(userService.isEmailAvailable(ADMIN_EMAIL));
-    }
+        Mockito.when(httpServleteRequest.getParameter("email")).thenReturn(adminEmail);
 
-    @Test
-    public void getAll_Date_Ordered() throws ParseException {
-        User admin = userService.findUserByEmail(ADMIN_EMAIL);
-        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
-        User u1 = userService.save(new User("username1", "email1@example.com", false, formatter.parse("01/01/3017"), adminRole));
-        User u2 = userService.save(new User("username2", "email2@example.com", false, formatter.parse("31/12/3016"), adminRole));
-
-        List<User> usersAscOrder = userService.findAll(true);
-        assertEquals(3, usersAscOrder.size());
-        assertEquals(admin, usersAscOrder.get(0));
-        assertEquals(u2, usersAscOrder.get(1));
-        assertEquals(u1, usersAscOrder.get(2));
-
-        List<User> usersDescOrder = userService.findAll(false);
-        assertEquals(3, usersDescOrder.size());
-        assertEquals(u1, usersDescOrder.get(0));
-        assertEquals(u2, usersDescOrder.get(1));
-        assertEquals(admin, usersDescOrder.get(2));
-
-        userService.remove(u1);
-        userService.remove(u2);
+        assertFalse(userService.isEmailAvailable(httpServleteRequest));
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#isEmailAvailable(String)}.
+     */
     @Test
-    public void findByUserName() {
-        assertNotNull(userService.findByUsername("admin"));
+    public void testIsEmailAvailableString_ok() {
+        assertTrue(userService.isEmailAvailable(uniqueEmail));
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#isEmailAvailable(String)}.
+     */
     @Test
-    public void removeById() {
-        User user = userService.save(new User("username", "email@example.com", adminRole));
-        userService.remove(user.getId());
-        assertNull(userService.findUserByEmail("email@example.com"));
+    public void testIsEmailAvailableString_notUniqueEmail() {
+        assertFalse(userService.isEmailAvailable(adminEmail));
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void removeNull() {
-        userService.remove((User) null);
-    }
 
     @Test
-    public void removeByUsername() {
-        userService.removeByUserName(
-                userService.save(new User("username", "email@example.com", adminRole)).getUsername());
-        assertNull(userService.findByUsername("username"));
+    public void testGetAll() {
+        List<User> userList = userService.getAll(true);
+        assertEquals(1, userList.size()); // hardcoded in init.sql file
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#changeLockedState(Long)}.
+     */
     @Test
-    public void findLockedAndUnlockedUsers() {
-        User u1 = userService.save(new User("username1", "email1@example.com", true, new Date(), adminRole));
-        User u2 = userService.save(new User("username2", "email2@example.com", false, new Date(), adminRole));
-
-        assertThat(userService.getLocked(), hasSize(1));
-        assertThat(userService.getUnlocked(), hasSize(2));
+    public void test_ChangeLockedState_ShouldLock() {
+        String name = "NewUser";
+        String email = "testSave@email.com";
 
-        userService.remove(u1);
-        userService.remove(u2);
-    }
-
-    @Test
-    public void changeLockedState_ShouldLock() {
-        User newUser = new User("NewUser", "testSave@email.com", adminRole);
+        User newUser = new User(name, email, adminRole);
         assertNull(newUser.getId());
-        // by default user isn't locked
-        assertFalse(newUser.getLocked());
+        assertFalse(newUser.getLocked()); // by default user is not locked
 
         User savedUser = userService.save(newUser);
         assertNotNull(savedUser);
 
-        assertTrue(userService.changeLockedState(savedUser.getId()));
+        boolean res = userService.changeLockedState(savedUser.getId());
+        assertTrue(res); // should be locked
 
-        User lockedUser = userService.findOne(savedUser.getId());
+        User lockedUser = userService.findById(savedUser.getId());
         assertTrue(lockedUser.getLocked());
 
         userService.remove(savedUser);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#changeLockedState(Long)}.
+     */
     @Test
-    public void changeLockedState_ShouldUnlock() {
-        User user = new User("NewUser", "testSave@email.com", adminRole);
-        user.setLocked(true);
-        assertNull(user.getId());
-        assertTrue(user.getLocked());
+    public void test_ChangeLockedState_ShouldUnlock() {
+        String name = "NewUser";
+        String email = "testSave@email.com";
 
-        User savedUser = userService.save(user);
+        User newUser = new User(name, email, adminRole);
+        newUser.setLocked(true);
+        assertNull(newUser.getId());
+        assertTrue(newUser.getLocked());
+
+        User savedUser = userService.save(newUser);
         assertNotNull(savedUser);
         assertTrue(savedUser.getLocked());
 
-        assertFalse(userService.changeLockedState(savedUser.getId()));
+        boolean res = userService.changeLockedState(savedUser.getId());
+        assertFalse(res); // should be unlocked
 
-        User lockedUser = userService.findOne(savedUser.getId());
+        User lockedUser = userService.findById(savedUser.getId());
         assertFalse(lockedUser.getLocked());
 
         userService.remove(savedUser);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#changeLockedState(Long)}.
+     */
     @Test
-    public void changeLockedState_ShouldNotLock() {
-        Long adminId = userService.findUserByEmail(ADMIN_EMAIL).getId();
-
+    public void test_ChangeLockedState_ShouldNotLock() {
         // admin user is in security context
         // should not lock (self lock protection)
-        assertFalse(userService.changeLockedState(adminId)); // should be unlocked
+        boolean res = userService.changeLockedState(adminId);
+        assertFalse(res); // should be unlocked
 
-        User adminUser = userService.findOne(adminId);
+        User adminUser = userService.findById(adminId);
         assertFalse(adminUser.getLocked());
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.UserService#remove(Long)}.
+     */
     @Test
-    public void remove() {
-        User newUser = new User("NewUser", "testSave@email.com", adminRole);
+    public void testRemoveById() {
+        String name = "NewUser";
+        String email = "testSave@email.com";
+
+        User newUser = new User(name, email, adminRole);
         assertNull(newUser.getId());
 
         User savedUser = userService.save(newUser);
@@ -227,18 +216,24 @@ public class UserServiceTest {
 
         userService.remove(savedUser);
 
-        assertNull(userService.findOne(savedUser.getId()));
+        assertNull(userService.findById(savedUser.getId()));
+    }
+
+    @Test(expected = Exception.class)
+    public void testRemoveById_Self() throws Exception {
+        userService.remove(adminId);
+        assertNotNull(userService.findById(adminId));
     }
 
     @Test
-    public void getUserByEmail() {
-        User user = userService.findUserByEmail(ADMIN_EMAIL);
+    public void testGetUserByEmail() {
+        User user = userService.getUserByEmail(adminEmail);
         assertNotNull(user);
-        assertEquals(user.getUsername(), "admin");
+        assertEquals(user.getUsername(), adminName);
     }
 
     @Test
-    public void editUser_ShouldChange() {
+    public void testEditUser_shouldChande() {
         String newUserName = "NewUser";
         String newUserEmail = "testSave@email.com";
         String editedUserName = "editedName";
@@ -249,17 +244,17 @@ public class UserServiceTest {
 
         newUser = userService.save(newUser);
 
-        User editedUser = userService.findOne(newUser.getId());
+        User editedUser = userService.findById(newUser.getId());
 
         assertNotNull(editedUser);
 
         // change all user fields
         editedUser.setUsername(editedUserName);
         editedUser.setEmail(editedUserEmail);
-        editedUser.setRole(roleService.findOne(2L));
+        editedUser.setRole(roleService.findById(2l));
         editedUser.setLocked(!newUser.getLocked());
 
-        boolean editedUserLockedState = editedUser.getLocked();
+        boolean editedUserLokedState = editedUser.getLocked();
         Long editedUserRoleId = editedUser.getRole().getId();
 
         User savedEditedUser = userService.editUser(editedUser);
@@ -268,7 +263,7 @@ public class UserServiceTest {
         assertEquals(editedUserName, savedEditedUser.getUsername());
         assertEquals(editedUserEmail, savedEditedUser.getEmail());
         assertEquals(editedUserRoleId, savedEditedUser.getRole().getId());
-        assertEquals(editedUserLockedState, savedEditedUser.getLocked());
+        assertEquals(editedUserLokedState, savedEditedUser.getLocked());
 
         assertNotEquals(newUser.getUsername(), savedEditedUser.getUsername());
         assertNotEquals(newUser.getEmail(), savedEditedUser.getEmail());
@@ -279,15 +274,18 @@ public class UserServiceTest {
     }
 
     @Test
-    public void eEditUser_self_shouldNotChangeRoleAndLocked() {
-        User adminDefaults = userService.findUserByEmail(ADMIN_EMAIL);
-        User adminToChange = userService.findUserByEmail(ADMIN_EMAIL);
+    public void testEditUser_self_shouldNotChandeRoleAndLocked() {
+        String updatedUserName = "editedName";
+        String updapedUserEmail = "edited@email.com";
+
+        User adminDefaults = userService.findById(adminId);
+        User adminToChange = userService.findById(adminId);
 
         assertNotNull(adminDefaults);
         assertNotNull(adminToChange);
 
         // change all admin fields
-        adminToChange.setUsername("editedName");
+        adminToChange.setUsername(updatedUserName);
 
         // FIXME user is able to change his profile details (role, locked) is he
         // change his email in same transaction!
@@ -295,69 +293,104 @@ public class UserServiceTest {
         // uncommenting this \|/ will set tests to fail
         // adminToChange.setEmail(updapedUserEmail);
 
-        adminToChange.setRole(roleService.findOne(2L)); // ROLE_USER
+        adminToChange.setRole(roleService.findById(2l)); // ROLE_USER
         adminToChange.setLocked(!adminDefaults.getLocked());
 
         Long adminToChangeRoleId = adminToChange.getRole().getId();
         boolean adminToChangeLockedState = adminToChange.getLocked();
         User editedAdmin = userService.editUser(adminToChange);
-
         assertNotNull(editedAdmin);
-        assertEquals("editedName", editedAdmin.getUsername());
+
+        assertEquals(updatedUserName, editedAdmin.getUsername());
+        // assertEquals(updapedUserEmail, editedAdmin.getEmail());
+
         assertNotEquals(adminToChange.getRole().getId(), adminToChangeRoleId);
         assertNotEquals(adminToChange.getLocked(), adminToChangeLockedState);
+
         // restore defaults
         assertNotNull(userService.save(adminDefaults));
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#save(Object)}.
+     */
     @Test
-    public void save() {
-        User newUser = new User("NewUser", "testSave@email.com", adminRole);
+    public void testSave() {
+        String name = "NewUser";
+        String email = "testSave@email.com";
+
+        User newUser = new User(name, email, adminRole);
         assertNull(newUser.getId());
 
         User savedUser = userService.save(newUser);
-        assertNotNull("Saved user mustn't be null", savedUser.getId());
+        assertNotNull(savedUser);
+        assertNotNull(savedUser.getId());
         assertSame(newUser, savedUser);
 
-        assertNotNull(userService.findOne(savedUser.getId()));
+        assertNotNull(userService.findById(savedUser.getId()));
 
         userService.remove(savedUser);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#remove(Object)}.
+     */
     @Test
-    public void removeAll_ShouldRemoveUserDetails() {
-        User admin = userService.findUserByEmail(ADMIN_EMAIL);
-        userService.save(new User("some name", "example@example.com", adminRole));
+    public void testRemove() {
+        String name = "NewUser";
+        String email = "testSave@email.com";
 
-        userService.deleteAll();
+        User newUser = new User(name, email, adminRole);
+        assertNull(newUser.getId());
+
+        User savedUser = userService.save(newUser);
+        assertNotNull(savedUser);
+        assertNotNull(savedUser.getId());
+        assertSame(newUser, savedUser);
 
-        assertTrue(userService.findAll(true).isEmpty());
-        assertThat(userDetailsService.count(), is(0L));
+        assertNotNull(userService.findById(savedUser.getId()));
 
-        // Restore deleted admin
-        userService.save(admin);
-    }
+        userService.remove(savedUser);
 
-    @Test(expected = IllegalArgumentException.class)
-    public void removeSelfShouldNotRemove() {
-        userService.remove(userService.findUserByEmail(ADMIN_EMAIL));
+        assertNull(userService.findById(savedUser.getId()));
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void removeById_Self() throws Exception {
-        userService.remove(userService.findUserByEmail(ADMIN_EMAIL));
-        assertNotNull(userService.findUserByEmail(ADMIN_EMAIL));
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#remove(Object)}.
+     */
+    @Test
+    public void testRemove_self_shouldNotRemove() {
+        User admin = userService.findById(adminId);
+        assertNotNull(admin);
+        userService.remove(admin);
+
+        User adminShouldNotBeDeleted = userService.findById(adminId);
+        assertNotNull(adminShouldNotBeDeleted);
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#findById(Long)}
+     * 
+     * find ADMIN user. hardcoed in USERS tab as id=1
+     */
     @Test
-    public void findById() {
-        User user = userService.findUserByEmail(ADMIN_EMAIL);
+    public void testFindById() {
+        User user = userService.findById(adminId);
         assertNotNull(user);
-        assertEquals(ADMIN_EMAIL, user.getEmail());
+        assertEquals(adminEmail, user.getEmail());
     }
 
+    /**
+     * Test method for
+     * {@link com.samsung.dsm.service.CommonService#count()}.
+     */
     @Test
-    public void count() {
+    public void testCount() {
+        // there is only one row predefined in USERS
         assertEquals(1, userService.count());
     }
 
diff --git a/servers/commons/src/test/java/com/samsung/commons/utils/UrlBuilderTest.java b/servers/commons/src/test/java/com/samsung/commons/utils/UrlBuilderTest.java
deleted file mode 100644 (file)
index 83c5a8b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.samsung.commons.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class UrlBuilderTest {
-
-    private UrlBuilder builder;
-
-    @Before
-    public void before() {
-        builder = new UrlBuilder();
-    }
-
-    @Test
-    public void add() throws Exception {
-        assertThat(builder.add("fragment1").build(), is("/restapi/fragment1"));
-    }
-
-    @Test
-    public void addTwo() throws Exception {
-        assertThat(builder.add("fragment1", "param1").build(), is("/restapi/fragment1/param1"));
-    }
-
-    @Test
-    public void addInt() throws Exception {
-        assertThat(builder.add("fragment1", 1).build(), is("/restapi/fragment1/1"));
-    }
-
-    @Test
-    public void addLong() throws Exception {
-        assertThat(builder.add("fragment1", 1L).build(), is("/restapi/fragment1/1"));
-    }
-}
\ No newline at end of file
index 07f6a72..877ff34 100644 (file)
@@ -3,9 +3,11 @@
        xmlns:jpa="http://www.springframework.org/schema/data/jpa"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-       http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
-       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
+                           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+                           http://www.springframework.org/schema/data/jpa 
+                           http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
+                           http://www.springframework.org/schema/tx 
+                           http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
 
 
     <tx:annotation-driven transaction-manager="transactionManager" />
@@ -15,7 +17,9 @@
 
     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
         <property name="driverClass" value="org.h2.Driver" />
-        <property name="jdbcUrl" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" />
+        <property name="jdbcUrl" value="jdbc:h2:~/test" />
+        <property name="user" value="sa" />
+        <property name="password" value="" />
 
         <!-- C3P0 properties -->
         <property name="acquireIncrement" value="1" />
@@ -33,7 +37,7 @@
         <property name="jpaProperties">
             <props>
                 <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
-                <prop key="hibernate.show_sql">false</prop>
+                <prop key="hibernate.show_sql">true</prop>
                 <prop key="hibernate.hbm2ddl.auto">create</prop>
                 <prop key="hibernate.hbm2ddl.import_files">sql/init.sql</prop>
             </props>
index d4d8a36..42cd4bd 100644 (file)
@@ -23,7 +23,7 @@ case "$1" in
   stop)
     $MQSERVER_SERVICE stop
     #lsof -i tcp:${SERVERMQ_PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill 
-       echo "DMS srver MQ was stoped"
+       echo "DMS server MQ was stoped"
     ;;
   restart)
     #lsof -i tcp:${SERVERMQ_PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill
index 1255651..41b5b14 100644 (file)
@@ -28,7 +28,7 @@ case "$1" in
   restart)
     #lsof -i tcp:${SERVERMQ_PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill
     $MQSERVER_SERVICE stop
-    echo "DMS srver MQ was stoped"
+    echo "DMS server MQ was stoped"
     #cd $SERVERMQ_SOURCE_DIR   
     #nohup mvn spring-boot:run &
     $MQSERVER_SERVICE start
index 9820fa0..0915cb7 100644 (file)
@@ -20,17 +20,21 @@ log4j.appender.stdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%-5p]
 #Define loggers
 
 # Application
-log4j.logger.com.samsung=DEBUG, stdout, file
+log4j.logger.com.samsung=INFO, stdout, file
 log4j.additivity.com.samsung=false
 
 #Spring
-log4j.logger.org.springframework=INFO, stdout, file
+log4j.logger.org.springframework=WARN, stdout, file
 log4j.additivity.org.springframework=false
 
 #Hibernate
-log4j.logger.org.hibernate=INFO, stdout, file
+log4j.logger.org.hibernate=WARN, stdout, file
 log4j.additivity.org.hibernate=false
 
 # Third-party libraries
-log4j.logger.org.apache=INFO, stdout, file
-log4j.additivity.org.apache=false
\ No newline at end of file
+log4j.logger.org.apache=WARN, stdout, file
+log4j.additivity.org.apache=false
+
+#c3p0
+log4j.logger.com.mchange=WARN, stdout, file
+log4j.additivity.com.mchange=false
\ No newline at end of file
index 91b9b5d..f73bd19 100644 (file)
@@ -33,4 +33,8 @@ log4j.additivity.org.hibernate=false
 
 # Third-party libraries
 log4j.logger.org.apache=WARN, stdout, file
-log4j.additivity.org.apache=false
\ No newline at end of file
+log4j.additivity.org.apache=false
+
+#c3p0
+log4j.logger.com.mchange=WARN, stdout, file
+log4j.additivity.com.mchange=false
\ No newline at end of file
index 9820fa0..f1fd8f6 100644 (file)
@@ -33,4 +33,8 @@ log4j.additivity.org.hibernate=false
 
 # Third-party libraries
 log4j.logger.org.apache=INFO, stdout, file
-log4j.additivity.org.apache=false
\ No newline at end of file
+log4j.additivity.org.apache=false
+
+#c3p0
+log4j.logger.com.mchange=WARN, stdout, file
+log4j.additivity.com.mchange=false
\ No newline at end of file
index 950f5b2..af36a56 100644 (file)
@@ -18,7 +18,7 @@ import com.samsung.commons.domain.User;
 import com.samsung.commons.service.RoleService;
 import com.samsung.commons.service.UserDetailsService;
 import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.UserServiceImpl;
+import com.samsung.commons.utils.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -31,8 +31,7 @@ import com.google.gson.Gson;
 import com.samsung.dsm.model.request.NewUser;
 import com.samsung.dsm.security.authentication.PasswordEncoder;
 
-import static com.samsung.dsm.utils.Utils.getRejectedFields;
-import static com.samsung.dsm.utils.Utils.returnView;
+import static com.samsung.commons.utils.Utils.returnView;
 
 /**
  * <h1>Account controller</h1> Provides basic account management methods.
@@ -48,7 +47,7 @@ public class AccountController {
     private RoleService roleService;
 
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     @Autowired
     private UserDetailsService userDetailsService;
@@ -95,7 +94,7 @@ public class AccountController {
         // validation
         if (result.hasErrors()) {
             // send hash map as a response and show validation messages
-            map = getRejectedFields(result.getAllErrors());
+            map = Utils.getRejectedFields(result.getAllErrors());
 
             return gson.toJson(map);
         }
index 6e0421f..80068d1 100644 (file)
@@ -5,18 +5,12 @@
  */
 package com.samsung.dsm.controller;
 
-import com.google.gson.Gson;
-import com.samsung.commons.domain.CustomUserDetails;
-import com.samsung.commons.domain.User;
-import com.samsung.commons.service.RoleService;
-import com.samsung.commons.service.UserDetailsService;
-import com.samsung.commons.service.UserSelfRemoveException;
-import com.samsung.commons.service.impl.RoleServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
-import com.samsung.dsm.model.request.EditUser;
-import com.samsung.dsm.model.request.NewUser;
-import com.samsung.dsm.model.request.ResetPassword;
-import com.samsung.dsm.security.authentication.PasswordEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.validation.Valid;
+
+import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -26,11 +20,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import javax.validation.Valid;
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.samsung.dsm.utils.Utils.getRejectedFields;
+import com.google.gson.Gson;
+import com.samsung.commons.domain.CustomUserDetails;
+import com.samsung.commons.domain.User;
+import com.samsung.commons.service.RoleService;
+import com.samsung.commons.service.UserDetailsService;
+import com.samsung.commons.service.UserService;
+import com.samsung.commons.utils.Utils;
+import com.samsung.dsm.model.request.EditUser;
+import com.samsung.dsm.model.request.NewUser;
+import com.samsung.dsm.model.request.ResetPassword;
+import com.samsung.dsm.security.authentication.PasswordEncoder;
 
 /**
  * <h1> Admin controller</h1>
@@ -43,14 +43,17 @@ import static com.samsung.dsm.utils.Utils.getRejectedFields;
 @Controller
 @RequestMapping(value = "/admin")
 public class AdminController {
+
+    private static final Logger log = Logger.getLogger(AdminController.class);
+
     @Autowired
-    UserServiceImpl userService;
+    UserService userService;
 
     @Autowired
-    PasswordEncoder passEncoder;
+    PasswordEncoder    passEncoder;
 
     @Autowired
-    RoleServiceImpl roleService;
+    RoleService roleService;
 
     @Autowired
     UserDetailsService userDetailsService;
@@ -73,9 +76,9 @@ public class AdminController {
      */
     @RequestMapping(value = "/users")
     public String users(Model model) {
-        model.addAttribute("roles", roleService.findAll());
-        model.addAttribute("users", userService.findAll(true));
-
+        model.addAttribute("roles", roleService.getAll());
+        model.addAttribute("users", userService.getAll(true));
+        log.debug("Show admin home page. Get users list: "  + model);
         return "users";
     }
 
@@ -88,26 +91,30 @@ public class AdminController {
     @RequestMapping(value = "/users/get/{id}", method = RequestMethod.GET)
     @ResponseBody
     public String getUser(@PathVariable Long id) {
-        return new Gson().toJson(userService.findOne(id));
+        User user = userService.findById(id);
+        log.debug(" Return user by id : "  + id + " - " + user);
+        return new Gson().toJson(user);
     }
 
     /**
      * (Async) Create a new user and add it to the DB.
      *
-     * @param user   model for new user.
+     * @param user model for new user.
      * @param result analyze the model for errors.
      * @return report of the creation of the new user.
      */
     @RequestMapping(value = "/users/new", method = RequestMethod.POST)
     @ResponseBody
     public String newUser(@Valid NewUser user, BindingResult result) {
-        Map<String, String> map = new HashMap<>();
+        Map<String, String> map = new HashMap<String, String>();
         Gson gson = new Gson();
 
         // validation
         if (result.hasErrors()) {
             // send hash map as a response and show validation messages
-            return gson.toJson(getRejectedFields(result.getAllErrors()));
+            map = Utils.getRejectedFields(result.getAllErrors());
+
+            return gson.toJson(map);
         }
 
         if (!userService.isEmailAvailable(user.getEmail())) {
@@ -116,7 +123,7 @@ public class AdminController {
             return gson.toJson(map);
         }
 
-        User newUser = new User(user.getName(), user.getEmail(), roleService.findOne(user.getRoleId()));
+        User newUser = new User(user.getName(), user.getEmail(), roleService.findById(user.getRoleId()));
         userService.save(newUser);
         // TODO: generate unique link for password recovery
         String link = "link";
@@ -129,25 +136,27 @@ public class AdminController {
      * (Async) Edit the existing user.
      *
      * @param editedUser edited user's model.
-     * @param result     analyze the model for errors.
+     * @param result analyze the model for errors.
      * @return edition report.
      */
     @RequestMapping(value = "/users/edit", method = RequestMethod.POST)
     @ResponseBody
     public String editUser(@Valid EditUser editedUser, BindingResult result) {
-        Map<String, String> map = new HashMap<>();
+        Map<String, String> map = new HashMap<String, String>();
         Gson gson = new Gson();
 
         // validation
         if (result.hasErrors()) {
             // send hash map as a response and show validation messages
-            return gson.toJson(getRejectedFields(result.getAllErrors()));
+            map = Utils.getRejectedFields(result.getAllErrors());
+
+            return gson.toJson(map);
         }
         try {
-            User user = userService.findOne(editedUser.getId());
+            User user = userService.findById(editedUser.getId());
             user.setUsername(editedUser.getName());
             user.setEmail(editedUser.getEmail());
-            user.setRole(roleService.findOne(editedUser.getRoleId()));
+            user.setRole(roleService.findById(editedUser.getRoleId()));
             userService.editUser(user);
         } catch (Exception e) {
             map.put("edit", "Something went wrong during editing.");
@@ -161,17 +170,22 @@ public class AdminController {
     /**
      * (Async) Reset the existing user's password.
      *
-     * @param password reset password's model.
-     * @param result   analyze the model for errors.
+     * @param password reseted password's model.
+     * @param result analyze the model for errors.
      * @return edition report.
      */
     @RequestMapping(value = "/users/reset_pass", method = RequestMethod.POST)
     @ResponseBody
     public String resetPassword(@Valid ResetPassword password, BindingResult result) {
+        Map<String, String> map = new HashMap<String, String>();
+        Gson gson = new Gson();
+
         // validation
         if (result.hasErrors()) {
             // send hash map as a response and show validation messages
-            return new Gson().toJson(getRejectedFields(result.getAllErrors()));
+            map = Utils.getRejectedFields(result.getAllErrors());
+
+            return gson.toJson(map);
         }
 
         CustomUserDetails userDetails = userDetailsService.findByUserId(password.getId());
@@ -204,9 +218,10 @@ public class AdminController {
     public String removeUser(@PathVariable Long id) {
         try {
             userService.remove(id);
-        } catch (UserSelfRemoveException e) {
-            return "false";
+        } catch (Exception e) {
+            return Boolean.toString(false);
         }
-        return "true";
+
+        return Boolean.toString(true);
     }
 }
index d83743d..e6bee69 100644 (file)
@@ -46,7 +46,7 @@ public class DashboardController {
      */
     @RequestMapping(value = "")
     public String dashboard(HttpServletRequest request, Model model) {
-        User currentUser = userService.findUserByEmail(request.getUserPrincipal().getName());
+        User currentUser = userService.getUserByEmail(request.getUserPrincipal().getName());
         ViewDashboard dashboard = new ViewDashboard();
 
         dashboard.setDeviceStatus(
index 4d07169..0b37bf3 100644 (file)
@@ -79,7 +79,7 @@ public class DashboardDevicesController {
      */
     @RequestMapping(value = "")
     public String iotDevices(Principal principal, Model model) {
-        User currentUser = userService.findUserByEmail(principal.getName());
+        User currentUser = userService.getUserByEmail(principal.getName());
         model.addAttribute("devices", ViewDevice.getViewDevicesList(deviceService.findByUser(currentUser)));
 
         return "devices";
index ea55f83..9c46244 100644 (file)
@@ -6,12 +6,12 @@
 package com.samsung.dsm.controller;
 
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
-import javax.servlet.http.HttpServletRequest;
-
-import static com.samsung.dsm.utils.Utils.returnView;
+import static com.samsung.commons.utils.Utils.returnView;
 
 /**
  * <h1> Home controller</h1>
index b396e93..8cc57ed 100644 (file)
@@ -52,8 +52,8 @@ public class OAuthCode implements Serializable {
     /**
      * Public constructor for class OAuthCode. Creates object OAuthCode with
      * parameters:
-     *
-     * @param code           - authorization code
+     * 
+     * @param code - authorization code
      * @param authentication - Authentication information
      */
     public OAuthCode(String code, byte[] authentication) {
@@ -64,7 +64,7 @@ public class OAuthCode implements Serializable {
 
     /**
      * Method provides getting authorization code.
-     *
+     * 
      * @return authorization code.
      */
     public String getCode() {
@@ -73,7 +73,7 @@ public class OAuthCode implements Serializable {
 
     /**
      * Method provides setting authorization code.
-     *
+     * 
      * @param code - authorization code.
      */
     public void setCode(String code) {
@@ -82,7 +82,7 @@ public class OAuthCode implements Serializable {
 
     /**
      * Method provides getting authentication information.
-     *
+     * 
      * @return authentication information.
      */
     public byte[] getAuthentication() {
@@ -91,7 +91,7 @@ public class OAuthCode implements Serializable {
 
     /**
      * Method provides setting authentication information.
-     *
+     * 
      * @param authentication - authentication information
      */
     public void setAuthentication(byte[] authentication) {
@@ -102,13 +102,13 @@ public class OAuthCode implements Serializable {
      * Method provides reflection to print names and values of all fields
      * <em>declared in this class</em>. Note that superclass fields are left out
      * of this implementation.
-     *
+     * 
      * @return String with names and values of all fields declared in this
-     * class.
+     *         class.
      */
     @Override
     public String toString() {
-        return "OAuthCode [code=" + code + ", authentication=" + Arrays.toString(authentication) + "]";
+        return "OAuthCode [id= + id + , code=" + code + ", authentication=" + Arrays.toString(authentication) + "]";
     }
 
 }
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/exception/PolicyException.java b/servers/dsm/src/main/java/com/samsung/dsm/exception/PolicyException.java
new file mode 100644 (file)
index 0000000..5437a6e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
+ */
+package com.samsung.dsm.exception;
+
+/**
+ * <h1> Policy handling exceptions</h1>
+ * In case of any problems with policy - this exception should be thrown.
+ *
+ * @author <A HREF="mailto:a.motchanyi@samsung.com">Artem Motchanyi</A>
+ * @version 1.0
+ * @since 2016-09-01
+ */
+public class PolicyException extends Exception {
+
+    /** The Constant serialVersionUID. */
+    private static final long serialVersionUID = 8548813024268456694L;
+
+    /** The error code. */
+    private String errorCode = "Unknown_Exception";
+
+    /**
+     * Instantiates a new policy exception.
+     *
+     * @param message the message
+     * @param errorCode the error code
+     */
+    public PolicyException(String message, String errorCode) {
+
+        super(message);
+
+        this.errorCode = errorCode;
+    }
+
+    /**
+     * Gets the error code.
+     *
+     * @return the error code
+     */
+    public String getErrorCode() {
+
+        return this.errorCode;
+    }
+}
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/jdbc/JdbcDriverUnregisteringListener.java b/servers/dsm/src/main/java/com/samsung/dsm/jdbc/JdbcDriverUnregisteringListener.java
new file mode 100644 (file)
index 0000000..8649f3f
--- /dev/null
@@ -0,0 +1,76 @@
+package com.samsung.dsm.jdbc;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Enumeration;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import org.apache.log4j.Logger;
+
+public class JdbcDriverUnregisteringListener implements ServletContextListener {
+    private static final Logger logger = Logger.getLogger(JdbcDriverUnregisteringListener.class);
+    /** 
+     * Instance of this class created like any other {@link ServletContextListener} on application startup.
+     * We can manage order of call {@link #contextInitialized(ServletContextEvent)} and 
+     * {@link #contextDestroyed(ServletContextEvent)} via {@code web.xml}. But servlet container (like Tomcat) creates
+     * all instances of listeners together. 
+     * 
+     * <p>So, if we initialize logger field ordinary (by class field in listener),
+     * then it will be initialized before first {@link #contextInitialized(ServletContextEvent)} and we lose
+     * opportunity to initialize system properties (like {@code LOG_FILE}) via 
+     * {@link org.jtalks.poulpe.web.listener.LoggerInitializationListener LoggerInitializationListener}</p>
+     * 
+     * <p><b>Best practices is</b>: Do not directly initialize fields of servlet listeners. Use 
+     * {@link #contextInitialized(ServletContextEvent)} and {@link #contextDestroyed(ServletContextEvent)} methods</p> 
+     */
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextInitialized(ServletContextEvent event) {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void contextDestroyed(ServletContextEvent event) {
+        deregisterDrivers(getDrivers());
+    }
+
+    /**
+     * Retrieves an Enumeration with all of the currently loaded JDBC drivers.
+     *
+     * @return the list of JDBC Drivers
+     */
+    private Enumeration<Driver> getDrivers() {
+        return DriverManager.getDrivers();
+    }
+
+    /**
+     * Unregistering JDBC drivers given as param.
+     *
+     * @param drivers {@link Enumeration} of {@link Driver} to unregister
+     */
+    private void deregisterDrivers(Enumeration<Driver> drivers) {
+        while (drivers.hasMoreElements()) {
+            deregisterDriver(drivers.nextElement());
+        }
+    }
+
+    /**
+     * Unregistering single JDBC driver given as param.
+     *
+     * @param driver to unregister
+     */
+    private void deregisterDriver(Driver driver) {
+        try {
+            DriverManager.deregisterDriver(driver);
+            logger.info("Deregistering JDBC driver: " + driver);
+        } catch (SQLException e) {
+            logger.error("Error deregistering JDBC driver: "+ driver + " Root cause: ", e);
+        }
+    }
+
+}
index f842449..af41d46 100644 (file)
@@ -33,7 +33,7 @@ public class ResetPassword {
      * Password confirmation (repeat)
      * Can't be empty.
      */
-    @NotNull(message = "passwords do not match")
+    @NotNull(message = "paswords do not match")
     private String repeatPassword;
 
     /**
index 745bc07..2e99a80 100644 (file)
@@ -37,4 +37,19 @@ abstract class DomainToRestConverter<T extends RestEntity, E> {
         }
         return list;
     }
+
+    /**
+     * Converts collection of entities
+     *
+     * @param entities entities
+     * @return collection of REST entities
+     */
+    public Collection<T> convert(Collection<E> entities) {
+        List<T> list = new ArrayList<>();
+
+        for (E entity : entities) {
+            list.add(convert(entity));
+        }
+        return list;
+    }
 }
index cd56c4d..00e1080 100644 (file)
@@ -17,11 +17,7 @@ public class PolicyParserFactory {
         JSON
     }
 
-    public static PolicyConfigParser getParser(Type type) {
-        if (type == null) {
-            return null;
-        }
-        
+    public PolicyConfigParser getParser(Type type) {
         PolicyConfigParser parser = null;
 
         switch (type) {
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/report/analyzer/ReportAnalyzerKeys.java b/servers/dsm/src/main/java/com/samsung/dsm/report/analyzer/ReportAnalyzerKeys.java
new file mode 100644 (file)
index 0000000..1bcac9a
--- /dev/null
@@ -0,0 +1,28 @@
+package com.samsung.dsm.report.analyzer;
+
+public class ReportAnalyzerKeys {
+    /**
+     * Keys for MAC reports
+     */
+    public static final String MAC = "[MAC]";
+    public static final String MAC_REPORT_USER_BT = "user_bt";
+    public static final String MAC_REPORT_INO = "ino";
+    public static final String MAC_REPORT_DEV = "dev";
+    public static final String MAC_REPORT_PATH = "path";
+    public static final String MAC_REPORT_COMM = "comm";
+    public static final String MAC_REPORT_APPNAME = "appname";
+    public static final String MAC_REPORT_PID = "pid";
+    public static final String MAC_REPORT_PPID_COMM = "ppid_comm";
+    public static final String MAC_REPORT_PPID = "ppid";
+    public static final String MAC_REPORT_D_INST = "d_inst";
+    public static final String MAC_REPORT_REQUESTED = "requested";
+    public static final String MAC_REPORT_OBJECT = "object";
+    public static final String MAC_REPORT_SUBJECT = "subject";
+    public static final String MAC_REPORT_WAIT = "wait";
+    public static final String MAC_REPORT_MODE = "mode";
+    public static final String MAC_REPORT_ACTION = "action";
+    public static final String MAC_REPORT_FN = "fn";
+    public static final String MAC_REPORT_LSM = "lsm";
+
+    private ReportAnalyzerKeys() {}
+}
index fe30a33..0b3573f 100644 (file)
@@ -1,43 +1,29 @@
 package com.samsung.dsm.report.analyzer.impl;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import com.samsung.commons.domain.GrantedApplication;
 import org.apache.log4j.Logger;
 
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.samsung.dsm.report.analyzer.ReportAnalyzer;
+import com.samsung.dsm.report.analyzer.ReportAnalyzerKeys;
 import com.samsung.dsm.service.GrantedApplicationService;
 
 public class MACReportAnalyzer implements ReportAnalyzer {
 
-    private static final String CODE_GRANTED = "1";
-    private static final String CODE_NOT_GRANTED = "2";
+    public static final String MAC_REPORT = "smack";
+    public static final String CODE_GRANTED = "1";
+    public static final String CODE_NOT_GRANTED = "2";
+
     private static final Logger log = Logger.getLogger(MACReportAnalyzer.class);
+
     private String code;
     private String title;
     private String message;
-    private static final String MAC = "[MAC]";
-    private static final String MAC_REPORT_USER_BT = "user_bt";
-    private static final String MAC_REPORT_INO = "ino";
-    private static final String MAC_REPORT_DEV = "dev";
-    private static final String MAC_REPORT_PATH = "path";
-    private static final String MAC_REPORT_D_INST = "d_inst";
-    private static final String MAC_REPORT_REQUESTED = "requested";
-    private static final String MAC_REPORT_OBJECT = "object";
-    public static final String MAC_REPORT_SUBJECT = "subject";
-    private static final String MAC_REPORT_WAIT = "wait";
-    private static final String MAC_REPORT_MODE = "mode";
-    private static final String MAC_REPORT_ACTION = "action";
-    private static final String MAC_REPORT_FN = "fn";
-    private static final String MAC_REPORT_LSM = "lsm";
-    public static final String MAC_REPORT_COMM = "comm";
-    public static final String MAC_REPORT_PID = "pid";
-    public static final String MAC_REPORT_PPID_COMM = "ppid_comm";
-    public static final String MAC_REPORT_PPID = "ppid";
-    public static final String MAC_REPORT = "smack";
-    public static final String MAC_REPORT_APPNAME = "appname";
 
     @Override
     public Map<String, String> extractReportData(String report) {
@@ -47,16 +33,16 @@ public class MACReportAnalyzer implements ReportAnalyzer {
         log.trace("Input report:");
         log.trace(report);
         //[MAC]
-        int iRow = 0;
-        for (String row : rows) {
+        int iRow = 0; 
+        for(String row:rows){
             iRow++;
-            log.trace("row #" + iRow + " : " + row);
+            log.trace("row #" + iRow +" : " + row);
         }
         // extract message
         String reportMessage = "";
         for (String row : rows) {
             String currentRow = row.trim();
-            if (!currentRow.startsWith(MAC) && currentRow.startsWith("[")) {
+            if (!currentRow.startsWith(ReportAnalyzerKeys.MAC) && currentRow.startsWith("[")) {
                 break;
             }
             reportMessage = reportMessage + " " + currentRow;
@@ -72,49 +58,48 @@ public class MACReportAnalyzer implements ReportAnalyzer {
         return map;
     }
 
-    private String extractLog(String report) {
-        JsonParser parser = new JsonParser();
+    private String extractLog(String report){
+        JsonParser parser = new JsonParser(); 
         JsonObject mainObject = parser.parse(report).getAsJsonObject();
         JsonObject data = mainObject.get("data").getAsJsonObject();
         return data.get("log").getAsString();
     }
-
+    
     private void fillMap(String[] extractedData, Map<String, String> map) {
-        for (String data : extractedData) {
+        for(String data: extractedData){
             log.trace(data);
             String[] items = data.split("=");
-            if (items.length < 2) {
+            if(items.length < 2){
                 continue;
             }
             String key = items[0].trim();
-            StringBuilder value = new StringBuilder();
-            for (int i = 1; i < items.length; i++) {
-                value.append(items[i]).append("=");
+            String value = "";
+            for(int i = 1; i < items.length; i++){
+                value = value + items[i] + "=";
             }
-            value = new StringBuilder(value.substring(0, value.length() - 1).split("\\[")[0]);
+            value = value.substring(0, value.length()-1).split("\\[")[0];
             switch (key) {
-                case MAC_REPORT_LSM:
-                case MAC_REPORT_FN:
-                case MAC_REPORT_ACTION:
-                case MAC_REPORT_MODE:
-                case MAC_REPORT_WAIT:
-                case MAC_REPORT_SUBJECT:
-                case MAC_REPORT_OBJECT:
-                case MAC_REPORT_REQUESTED:
-                case MAC_REPORT_D_INST:
-                case MAC_REPORT_PPID:
-                case MAC_REPORT_PPID_COMM:
-                case MAC_REPORT_PID:
-                case MAC_REPORT_COMM:
-                case MAC_REPORT_PATH:
-                case MAC_REPORT_DEV:
-                case MAC_REPORT_INO:
-                case MAC_REPORT_USER_BT: {
-                    map.put(key, value.toString());
-                    break;
-                }
-                default:
-                    ;
+            case ReportAnalyzerKeys.MAC_REPORT_LSM:
+            case ReportAnalyzerKeys.MAC_REPORT_FN:
+            case ReportAnalyzerKeys.MAC_REPORT_ACTION:
+            case ReportAnalyzerKeys.MAC_REPORT_MODE:
+            case ReportAnalyzerKeys.MAC_REPORT_WAIT:
+            case ReportAnalyzerKeys.MAC_REPORT_SUBJECT:
+            case ReportAnalyzerKeys.MAC_REPORT_OBJECT:
+            case ReportAnalyzerKeys.MAC_REPORT_REQUESTED:
+            case ReportAnalyzerKeys.MAC_REPORT_D_INST:
+            case ReportAnalyzerKeys.MAC_REPORT_PPID:
+            case ReportAnalyzerKeys.MAC_REPORT_PPID_COMM:
+            case ReportAnalyzerKeys.MAC_REPORT_PID:
+            case ReportAnalyzerKeys.MAC_REPORT_COMM:
+            case ReportAnalyzerKeys.MAC_REPORT_PATH:
+            case ReportAnalyzerKeys.MAC_REPORT_DEV:
+            case ReportAnalyzerKeys.MAC_REPORT_INO:
+            case ReportAnalyzerKeys.MAC_REPORT_USER_BT: {
+                map.put(key, value);
+                break;
+            }
+            default:;
             }
         }
     }
@@ -136,25 +121,25 @@ public class MACReportAnalyzer implements ReportAnalyzer {
 
     @Override
     public void analyze(Map<String, String> map, GrantedApplicationService grantedApplicationService) {
-        String parentCommand = map.get(MAC_REPORT_PPID_COMM);
-        String command = map.get(MAC_REPORT_COMM);
-        String action = map.get(MAC_REPORT_ACTION);
-        String ppid = map.get(MAC_REPORT_PPID);
-        String pid = map.get(MAC_REPORT_PID);
-        String path = map.get(MAC_REPORT_PATH);
-        String permission = map.get(MAC_REPORT_REQUESTED);
-        String user = map.get(MAC_REPORT_OBJECT);
-        map.put(MAC_REPORT_APPNAME, command);
+        String parentCommand = map.get(ReportAnalyzerKeys.MAC_REPORT_PPID_COMM);
+        String command = map.get(ReportAnalyzerKeys.MAC_REPORT_COMM);
+        String action = map.get(ReportAnalyzerKeys.MAC_REPORT_ACTION);
+        String ppid = map.get(ReportAnalyzerKeys.MAC_REPORT_PPID);
+        String pid = map.get(ReportAnalyzerKeys.MAC_REPORT_PID);
+        String path = map.get(ReportAnalyzerKeys.MAC_REPORT_PATH);
+        String permission = map.get(ReportAnalyzerKeys.MAC_REPORT_REQUESTED);
+        String user = map.get(ReportAnalyzerKeys.MAC_REPORT_OBJECT);
+        map.put(ReportAnalyzerKeys.MAC_REPORT_APPNAME, command);
         /////////////////////////////////////////////////////FIXME Stub for demos
-        if (parentCommand.equalsIgnoreCase("smack_test") || command.equalsIgnoreCase("smack_test")) {
-            title = "Application is not granted";
-            message = "From the application " + parentCommand + " with pid = " + ppid + ", the user=" + user + " called a command=" + command + " with pid = " + pid + ",\n" +
+        if(parentCommand.equalsIgnoreCase("smack_test") || command.equalsIgnoreCase("smack_test")){
+            title = "Application is not granted"; 
+            message = "From the application " + parentCommand + " with pid = " + ppid +", the user=" + user + " called a command=" + command + " with pid = " + pid + ",\n" +
                     " but this application is not trusted by system. Remove this application";
             code = CODE_NOT_GRANTED;
             return;
         }
-        title = "Problem with permissions";
-        message = "From the application " + parentCommand + " with pid = " + ppid + ", the user=" + user + " called a command=" + command + " with pid = " + pid + " that has a permission = \"" + permission + "\"\n"
+        title = "Problem with permissions"; 
+        message = "From the application " + parentCommand + " with pid = " + ppid +", the user=" + user + " called a command=" + command + " with pid = " + pid +" that has a permission = \"" + permission + "\"\n"
                 + " for the given path = " + path + " . Action = " + action;
         code = CODE_GRANTED;
         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
index dfb4b55..32fd8a5 100644 (file)
@@ -75,7 +75,7 @@ public class AccessTokenApi {
         try {
             String email = accessTokenService.readAuthenticationByAccessToken(access_token).getName();
             log.debug("AccessTokenApi get user email = " + email + " from access token = " + access_token);
-            User user = userService.findUserByEmail(email);
+            User user = userService.getUserByEmail(email);
             log.debug("AccessTokenApi get user details: " + user);
             Gson gson = new Gson();
             return new ResponseEntity<>(gson.toJson(user), OK);
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/device/AgentIsNull.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/device/AgentIsNull.java
new file mode 100644 (file)
index 0000000..e51db13
--- /dev/null
@@ -0,0 +1,9 @@
+package com.samsung.dsm.rest.device;
+
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import static org.springframework.http.HttpStatus.BAD_REQUEST;
+
+@ResponseStatus(value = BAD_REQUEST, reason = "Agent is null")
+public class AgentIsNull extends RuntimeException {
+}
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesNotFound.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesNotFound.java
new file mode 100644 (file)
index 0000000..81fd12c
--- /dev/null
@@ -0,0 +1,9 @@
+package com.samsung.dsm.rest.device;
+
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import static org.springframework.http.HttpStatus.NOT_FOUND;
+
+@ResponseStatus(value = NOT_FOUND, reason = "Devices haven't been found (for user)")
+public class DevicesNotFound extends RuntimeException {
+}
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesOwnerNotFound.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/device/DevicesOwnerNotFound.java
new file mode 100644 (file)
index 0000000..a082e10
--- /dev/null
@@ -0,0 +1,9 @@
+package com.samsung.dsm.rest.device;
+
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import static org.springframework.http.HttpStatus.NOT_FOUND;
+
+@ResponseStatus(value = NOT_FOUND, reason = "No devices owner found")
+public class DevicesOwnerNotFound extends RuntimeException {
+}
diff --git a/servers/dsm/src/main/java/com/samsung/dsm/rest/device/UserNotFound.java b/servers/dsm/src/main/java/com/samsung/dsm/rest/device/UserNotFound.java
new file mode 100644 (file)
index 0000000..4407036
--- /dev/null
@@ -0,0 +1,9 @@
+package com.samsung.dsm.rest.device;
+
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import static org.springframework.http.HttpStatus.NOT_FOUND;
+
+@ResponseStatus(value = NOT_FOUND, reason = "User hasn't been found")
+public class UserNotFound extends RuntimeException {
+}
index 9105014..fead924 100644 (file)
@@ -9,4 +9,8 @@ public class IotCloudAssociatedUserNotExists extends RuntimeException {
     public IotCloudAssociatedUserNotExists() {
         super();
     }
+
+    public IotCloudAssociatedUserNotExists(Throwable cause) {
+        super(cause);
+    }
 }
index 88ceaa9..5711d0a 100644 (file)
@@ -21,50 +21,55 @@ public class MQSenderImpl implements MQSender {
     private static final Logger log = Logger.getLogger(MQSenderImpl.class);
     private static final String REST_FOR_POLICY = "/dsmmq/policy";
     private static final String REST_FOR_NOTIFICATION = "/dsmmq/notification";
-    private final URI notificationUri;
-    private final URI policyUri;
-    private RestTemplate restTemplate;
+    private String host;
 
-    public MQSenderImpl(String host) throws URISyntaxException {
+    public MQSenderImpl(String host) {
+        this.host = host;
         log.info("MQ Sender connect to : " + host);
-        restTemplate = new RestTemplate();
-
-        notificationUri = new URI(host + REST_FOR_NOTIFICATION);
-        policyUri = new URI(host + REST_FOR_POLICY);
-    }
-
-    void setRestTemplate(RestTemplate restTemplate) {
-        this.restTemplate = restTemplate;
     }
 
     @Override
     public boolean sendNotification(Notification notification) {
-        log.info("Send notification" + notification);
-        List<MediaType> acceptableMediaTypes = new ArrayList<>();
-        acceptableMediaTypes.add(MediaType.TEXT_PLAIN);
-        HttpHeaders headers = new HttpHeaders();
-        headers.setAccept(acceptableMediaTypes);
-        HttpEntity<Notification> entity = new HttpEntity<>(notification, headers);
-        log.info("Send to " + notificationUri.getHost());
-        ResponseEntity result = restTemplate.exchange(notificationUri, HttpMethod.POST, entity, ResponseEntity.class);
-        log.info("Response " + result);
-
-        return result.getStatusCode() == HttpStatus.OK;
+        try {
+            log.info("Send notification" + notification);
+            RestTemplate restTemplate = new RestTemplate();
+            List<MediaType> acceptableMediaTypes = new ArrayList<>();
+            acceptableMediaTypes.add(MediaType.TEXT_PLAIN);
+            HttpHeaders headers = new HttpHeaders();
+            headers.setAccept(acceptableMediaTypes);
+            HttpEntity<Notification> entity = new HttpEntity<>(notification, headers);
+            URI url = new URI(host + REST_FOR_NOTIFICATION);
+            log.info("Send to " + url);
+            @SuppressWarnings("rawtypes")
+            ResponseEntity result = restTemplate.exchange(url, HttpMethod.POST, entity, ResponseEntity.class);
+            log.info("Response " + result);
+            return result.getStatusCode() == HttpStatus.OK;
+        } catch (URISyntaxException e) {
+            log.error(e.getMessage(), e);
+        }
+        return false;
     }
 
     @Override
     public boolean sendPolicy(MQPolicy policy) {
-        log.info("Send policy" + policy);
-        List<MediaType> acceptableMediaTypes = new ArrayList<>();
-        acceptableMediaTypes.add(MediaType.TEXT_PLAIN);
-        HttpHeaders headers = new HttpHeaders();
-        headers.setAccept(acceptableMediaTypes);
-        HttpEntity<MQPolicy> entity = new HttpEntity<>(policy, headers);
-        log.info("Send to " + policyUri.getHost());
-        ResponseEntity result = restTemplate.exchange(policyUri, HttpMethod.POST, entity, ResponseEntity.class);
-        log.info("Response " + result);
-
-        return result.getStatusCode() == HttpStatus.OK;
+        try {
+            log.info("Send policy" + policy);
+            RestTemplate restTemplate = new RestTemplate();
+            List<MediaType> acceptableMediaTypes = new ArrayList<>();
+            acceptableMediaTypes.add(MediaType.TEXT_PLAIN);
+            HttpHeaders headers = new HttpHeaders();
+            headers.setAccept(acceptableMediaTypes);
+            HttpEntity<MQPolicy> entity = new HttpEntity<>(policy, headers);
+            URI url = new URI(host + REST_FOR_POLICY);
+            log.info("Send to " + url);
+            @SuppressWarnings("rawtypes")
+            ResponseEntity result = restTemplate.exchange(url, HttpMethod.POST, entity, ResponseEntity.class);
+            log.info("Response " + result);
+            return result.getStatusCode() == HttpStatus.OK;
+        } catch (URISyntaxException e) {
+            log.error(e.getMessage(), e);
+        }
+        return false;
     }
 
 }
index 3ed11a2..3636751 100644 (file)
@@ -7,7 +7,6 @@ package com.samsung.dsm.rest.policy;
 
 import static java.util.Optional.ofNullable;
 
-import com.samsung.commons.service.impl.PolicyServiceImpl;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -34,7 +33,7 @@ public class PolicyApi {
 
     private final static Logger log = Logger.getLogger(PolicyApi.class);
     @Autowired
-    private PolicyServiceImpl policyService;
+    private PolicyService policyService;
 
     @Autowired
     private AgentService agentService;
@@ -59,36 +58,15 @@ public class PolicyApi {
     @RequestMapping(value = "/request/{policyId}/device/{deviceId}")
     public void requestPolicy(@PathVariable Long policyId, @PathVariable String deviceId) {
         log.info("Request policy - " + policyId);
-
-        Policy policy = policyService.findOne(policyId);
-
-        if (policy == null) {
-            log.debug("No policy by policy ID");
-            return;
-        }
-
-        mqSender.sendPolicy(new MQPolicy(
-                null,
-                deviceId,
-                policy.getPolicy(),
-                policy.getRoute()));
+        //TODO add check for policy
+        Policy policy = policyService.findById(policyId);
+        mqSender.sendPolicy(new MQPolicy(null, deviceId, policy.getPolicy(), policy.getRoute()));
     }
 
-    @RequestMapping(value = "/request/{policyId}/agent/{agentUuidId}")
-    public void requestAgentPolicy(@PathVariable Long policyId, @PathVariable String agentUuidId) {
+    @RequestMapping(value = "/request/{policyId}/agent/{agentId}")
+    public void requestAgentPolicy(@PathVariable Long policyId, @PathVariable String agentId) {
         log.info("Request policy - " + policyId);
-
-        Agent agent = agentService.findByUUID(agentUuidId);
-
-        if (agent == null) {
-            log.debug("No agent by agent UUID");
-            return;
-        }
-
-        mqSender.sendPolicy(new MQPolicy(
-                agent.getUuid(),
-                agent.getDevice().getUuid(),
-                agent.getPolicy().getPolicy(),
-                agent.getPolicy().getRoute()));
+        Agent agent = agentService.findByUUID(agentId);
+        mqSender.sendPolicy(new MQPolicy(agent.getUuid(), agent.getDevice().getUuid(), agent.getPolicy().getPolicy(), agent.getPolicy().getRoute()));
     }
 }
index 6b9370b..31f2c37 100644 (file)
@@ -30,6 +30,7 @@ import com.samsung.commons.domain.Report;
 import com.samsung.commons.model.Notification;
 import com.samsung.commons.service.IotCloudService;
 import com.samsung.commons.service.ReportService;
+import com.samsung.dsm.report.analyzer.ReportAnalyzerKeys;
 import com.samsung.dsm.report.analyzer.impl.MACReportAnalyzer;
 import com.samsung.dsm.rest.mq.MQSenderImpl;
 import com.samsung.dsm.service.GrantedApplicationService;
@@ -108,18 +109,18 @@ public class ReportApi {
             notification.setCurrentTime(System.currentTimeMillis());
             
             ////////////////////////////////////////////////////////////////FIXME Stub for demo
-            String parentCommand = map.get(MACReportAnalyzer.MAC_REPORT_PPID_COMM);
-            String command = map.get(MACReportAnalyzer.MAC_REPORT_COMM);
-            String ppid = map.get(MACReportAnalyzer.MAC_REPORT_PPID);
-            String pid = map.get(MACReportAnalyzer.MAC_REPORT_PID);
+            String parentCommand = map.get(ReportAnalyzerKeys.MAC_REPORT_PPID_COMM);
+            String command = map.get(ReportAnalyzerKeys.MAC_REPORT_COMM);
+            String ppid = map.get(ReportAnalyzerKeys.MAC_REPORT_PPID);
+            String pid = map.get(ReportAnalyzerKeys.MAC_REPORT_PID);
             if(parentCommand.equalsIgnoreCase("smack_test") || command.equalsIgnoreCase("smack_test")){
                 Map<String, String> stubMap = new HashMap<>();
                 if(parentCommand.equalsIgnoreCase("smack_test")){
-                    stubMap.put(MACReportAnalyzer.MAC_REPORT_PID, ppid);
-                    stubMap.put(MACReportAnalyzer.MAC_REPORT_APPNAME, parentCommand);
+                    stubMap.put(ReportAnalyzerKeys.MAC_REPORT_PID, ppid);
+                    stubMap.put(ReportAnalyzerKeys.MAC_REPORT_APPNAME, parentCommand);
                 } else {
-                    stubMap.put(MACReportAnalyzer.MAC_REPORT_PID, pid);
-                    stubMap.put(MACReportAnalyzer.MAC_REPORT_APPNAME, command);
+                    stubMap.put(ReportAnalyzerKeys.MAC_REPORT_PID, pid);
+                    stubMap.put(ReportAnalyzerKeys.MAC_REPORT_APPNAME, command);
                 }
                 notification.setAdditionalMap(stubMap);
             ///////////////////////////////////////////////////////////////////////////
@@ -136,12 +137,12 @@ public class ReportApi {
             }
             if(find){
                 Map<String, String> stubMap = new HashMap<>();
-                stubMap.put(MACReportAnalyzer.MAC_REPORT_PID, pid);
-                String subject = map.get(MACReportAnalyzer.MAC_REPORT_SUBJECT);
+                stubMap.put(ReportAnalyzerKeys.MAC_REPORT_PID, pid);
+                String subject = map.get(ReportAnalyzerKeys.MAC_REPORT_SUBJECT);
                 String[] arr = subject.split(":");
                 log.info("=============================    subject          ==========================================");
                 log.info("=============================  Array:  "  + Arrays.toString(arr)+ "          ==========================================");
-                stubMap.put(MACReportAnalyzer.MAC_REPORT_APPNAME, arr[arr.length - 1]);
+                stubMap.put(ReportAnalyzerKeys.MAC_REPORT_APPNAME, arr[arr.length - 1]);
                 notification.setCode("2");//Not Granted
                 notification.setAdditionalMap(stubMap);
             } else {
index 4138c9e..4559373 100644 (file)
@@ -6,6 +6,8 @@ import com.samsung.commons.service.CommonService;
 import java.util.List;
 
 
-public interface GrantedApplicationService {
+public interface GrantedApplicationService extends CommonService<GrantedApplication> {
+
     List<GrantedApplication> findByParentCommandAndCommand(String parentCommand, String command);
+
 }
index fb18388..ed1981d 100644 (file)
@@ -2,7 +2,6 @@ package com.samsung.dsm.service.impl;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.security.oauth2.provider.token.TokenStore;
 import org.springframework.stereotype.Service;
 
@@ -12,10 +11,10 @@ import com.samsung.dsm.service.AccessTokenService;
 
 @Service("accessTokenService")
 public class AccessTokenServiceImpl implements AccessTokenService {
-
+       
        @Autowired
        private OAuthAccessTokenRepository accessTokenRepository;
-
+       
        @Autowired
        private TokenStore tokenStore;
 
@@ -30,10 +29,15 @@ public class AccessTokenServiceImpl implements AccessTokenService {
        }
 
        @Override
-       public OAuthAccessToken findById(Long id) {
+       @Deprecated
+       public OAuthAccessToken findById(Long id) {             
                return null;
        }
 
+       public OAuthAccessToken findById(String id) {           
+               return accessTokenRepository.findOne(id);
+       }
+
        @Override
        public long count() {
                return accessTokenRepository.count();
@@ -41,9 +45,7 @@ public class AccessTokenServiceImpl implements AccessTokenService {
 
        @Override
        public Authentication readAuthenticationByAccessToken(String accessToken)  throws Exception {
-        TokenStore tokenStore = getTokenStore();
-        OAuth2Authentication authentication = tokenStore.readAuthentication(accessToken);
-        return authentication.getUserAuthentication();
+               return  getTokenStore().readAuthentication(accessToken).getUserAuthentication();
        }
 
        @Override
@@ -55,5 +57,5 @@ public class AccessTokenServiceImpl implements AccessTokenService {
     public void setTokenStore(TokenStore tokenStore) {
         this.tokenStore = tokenStore;
     }
-
+       
 }
index 2b282b4..589ccc2 100644 (file)
@@ -5,31 +5,40 @@ import java.util.List;
 import com.samsung.commons.domain.GrantedApplication;
 import com.samsung.commons.repository.GrantedApplicationRepository;
 
-import com.samsung.commons.service.CommonCrudService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Service;
 
 import com.samsung.dsm.service.GrantedApplicationService;
 
 @Service("grantedApplicationService")
-public class GrantedApplicationServiceImpl extends CommonCrudService<GrantedApplication, Long> implements GrantedApplicationService {
+public class GrantedApplicationServiceImpl implements GrantedApplicationService {
 
-    private GrantedApplicationRepository repository;
+    @Autowired
+    GrantedApplicationRepository repository;
+    
+    @Override
+    public GrantedApplication save(GrantedApplication grantedApplication) {
+        return repository.save(grantedApplication);
+    }
 
-    /**
-     * Provide CRUD repository
-     *
-     * @param repository CRUD repo
-     */
-    public GrantedApplicationServiceImpl(GrantedApplicationRepository repository) {
-        super(repository);
+    @Override
+    public void remove(GrantedApplication grantedApplication) {
+        repository.delete(grantedApplication);
+    }
 
-        this.repository = repository;
+    @Override
+    public GrantedApplication findById(Long id) {
+        return repository.findOne(id);
+    }
+
+    @Override
+    public long count() {
+        return repository.count();
     }
 
     @Override
     public List<GrantedApplication> findByParentCommandAndCommand(String parentCommand, String command) {
         return repository.findByParentCommandAndCommand(parentCommand, command);
     }
-}
\ No newline at end of file
+
+}
index 826fdcb..32e2977 100644 (file)
@@ -85,7 +85,10 @@ public class OAuth2AuthorizationServiceImpl implements OAuth2AuthorizationServic
 
             return authorizationCodeServices.createAuthorizationCode(combinedAuth);
         } catch (OAuth2Exception e) {
-            log.warn("Error on create auth code", e);
+            if (authorizationRequest.getState() != null) {
+                log.warn(format("State %s", authorizationRequest.getState()));
+            }
+
             return null;
         }
     }
index 834275d..05b8f08 100644 (file)
@@ -1,9 +1,9 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-       http://www.springframework.org/schema/context
-       http://www.springframework.org/schema/context/spring-context-4.3.xsd">
+                        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+                        http://www.springframework.org/schema/context
+                        http://www.springframework.org/schema/context/spring-context-4.3.xsd ">
 
     <bean
         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
index 3546b51..cb3fceb 100644 (file)
@@ -3,11 +3,11 @@
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-       http://www.springframework.org/schema/data/jpa
-       http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
-       http://www.springframework.org/schema/tx
-       http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
+                           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+                           http://www.springframework.org/schema/data/jpa
+                           http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
+                           http://www.springframework.org/schema/tx
+                           http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
 
     <tx:annotation-driven transaction-manager="transactionManager"/>
 
index 39afdf1..83d0669 100644 (file)
             <security:hsts/>
         </security:headers>
     </security:http>
-
     <bean id="mqSender" class="com.samsung.dsm.rest.mq.MQSenderImpl">
         <constructor-arg name="host" value="http://localhost:8888"/>
     </bean>
index 9947c41..53a53ec 100644 (file)
@@ -14,7 +14,7 @@
     </context-param>
     <context-param>
         <param-name>log4jConfigLocation</param-name>
-        <param-value>classpath:log4j.properties</param-value>
+        <param-value>classpath:/log4j.properties</param-value>
     </context-param>
     <!-- filter for UTF-8 symbols -->
     <filter>
index 15f872a..9e6995d 100644 (file)
@@ -15,7 +15,6 @@ import com.samsung.commons.domain.Role;
 import com.samsung.commons.domain.User;
 import com.samsung.commons.service.RoleService;
 import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.UserServiceImpl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -26,7 +25,6 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -37,7 +35,6 @@ import org.springframework.web.context.WebApplicationContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class AccountControllerTest {
     private MockMvc mockMvc;
 
@@ -45,7 +42,7 @@ public class AccountControllerTest {
     private RoleService roleService;
 
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     private Role userRole;
 
@@ -111,7 +108,7 @@ public class AccountControllerTest {
                 .andReturn().getResponse().getContentAsString();
 
         assertEquals("", response);
-        User user = userService.findUserByEmail(email);
+        User user = userService.getUserByEmail(email);
         assertNotNull(user);
         userService.remove(user);
     }
index aeeab30..0748338 100644 (file)
@@ -16,7 +16,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 
 import com.samsung.commons.domain.CustomUserDetails;
 import com.samsung.commons.domain.Role;
@@ -25,8 +24,6 @@ import com.samsung.commons.repository.UserRepository;
 import com.samsung.commons.service.RoleService;
 import com.samsung.commons.service.UserDetailsService;
 import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.RoleServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -37,7 +34,6 @@ import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -52,20 +48,19 @@ import com.samsung.dsm.security.authentication.PasswordEncoder;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class AdminControllerTest {
     private MockMvc mockMvc;
     @Autowired
-    PasswordEncoder passEncoder;
+    PasswordEncoder             passEncoder;
 
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     @Autowired
     private UserDetailsService userDetailsService;
 
     @Autowired
-    private RoleServiceImpl roleService;
+    private RoleService roleService;
 
     @Autowired
     private UserRepository userRepository;
@@ -80,7 +75,7 @@ public class AdminControllerTest {
 
     @Before
     public void setUp() {
-        List<Role> roles = roleService.findAll();
+        ArrayList<Role> roles = roleService.getAll();
 
         for (Role role : roles) {
             if (role.getName().equals(Role.Type.ADMIN.toString())) {
@@ -104,8 +99,8 @@ public class AdminControllerTest {
     @Test
     public void adminTest() throws Exception {
         mockMvc.perform(get("/admin"))
-                .andExpect(status().is(302))
-                .andExpect(view().name("redirect:/dashboard"));
+            .andExpect(status().is(302))
+            .andExpect(view().name("redirect:/dashboard"));
     }
 
     @Test
@@ -115,11 +110,11 @@ public class AdminControllerTest {
         userService.save(user1);
         userService.save(user2);
         mockMvc.perform(get("/admin/users/"))
-                .andExpect(status().isOk())
-                .andExpect(view().name("users"))
-                .andExpect(forwardedUrl("users"))
-                .andExpect(model().attribute("users", hasSize(3)))
-                .andExpect(model().attribute("roles", hasSize(2)));
+            .andExpect(status().isOk())
+            .andExpect(view().name("users"))
+            .andExpect(forwardedUrl("users"))
+            .andExpect(model().attribute("users", hasSize(3)))
+            .andExpect(model().attribute("roles", hasSize(2)));
 
         userService.remove(user1);
         userService.remove(user2);
@@ -130,9 +125,9 @@ public class AdminControllerTest {
         User user = new User("admin", "admin@mail", false, new Date(), adminRole);
         userService.save(user);
         String response = mockMvc.perform(get("/admin/users/get/{id}", user.getId()))
-                .andExpect(status().isOk())
-                .andExpect(forwardedUrl(null))
-                .andReturn().getResponse().getContentAsString();
+            .andExpect(status().isOk())
+            .andExpect(forwardedUrl(null))
+            .andReturn().getResponse().getContentAsString();
 
         Gson gson = new Gson();
         assertEquals(gson.toJson(user), response);
@@ -143,7 +138,7 @@ public class AdminControllerTest {
      * New user negative test.
      * - Wrong request
      * - Email is occupied
-     *
+     * 
      * @throws Exception the exception
      */
     @Test
@@ -187,7 +182,7 @@ public class AdminControllerTest {
                 .andReturn().getResponse().getContentAsString();
 
         assertEquals("", response);
-        User user = userService.findUserByEmail(email);
+        User user = userService.getUserByEmail(email);
         assertNotNull(user);
         userService.remove(user);
     }
@@ -195,7 +190,7 @@ public class AdminControllerTest {
     /**
      * Edits the user negative test.
      * - Wrong request
-     *
+     * 
      * @throws Exception the exception
      */
     @Test
@@ -224,7 +219,7 @@ public class AdminControllerTest {
                 .andReturn().getResponse().getContentAsString();
 
         assertEquals("", response);
-        User updatedUser = userService.findOne(user.getId());
+        User updatedUser = userService.findById(user.getId());
         assertEquals(newName, updatedUser.getUsername());
         assertEquals(newEmail, updatedUser.getEmail());
         userService.remove(updatedUser);
@@ -239,29 +234,29 @@ public class AdminControllerTest {
      */
     @Test
     public void resetPasswordNegativeTest() throws Exception {
-        // Not enough parameters
         String res = mockMvc.perform(post("/admin/users/reset_pass"))
                 .andExpect(status().isOk())
                 .andReturn().getResponse().getContentAsString();
-        assertEquals("{\"repeatPassword\":\"passwords do not match\",\"id\":\"may not be null\"}", res);
 
+        assertNotEquals("", res);
 
-        // Repeat password do not the same as password
         String oldPass = "121212";
+        String newPass = "222222";
+        String repNewPass = "222221";
         User user = new User("user", "user@mail", false, new Date(), userRole);
-        user.setUserDetails(new CustomUserDetails(oldPass, "link", user));
         user = userService.save(user);
+        userDetailsService.save(new CustomUserDetails(oldPass, "link", user));
 
         res = mockMvc.perform(post("/admin/users/reset_pass")
                 .contentType(MediaType.APPLICATION_FORM_URLENCODED)
                 .param("id", user.getId().toString())
-                .param("password", "222222")
-                .param("repeatPassword", "222221"))
+                .param("password", newPass)
+                .param("repeatPassword", repNewPass))
                 .andExpect(status().isOk())
                 .andReturn().getResponse().getContentAsString();
 
-        assertEquals("{\"repeatPassword\":\"passwords do not match\"}", res);
-        assertFalse(passEncoder.isValid(userDetailsService.findByUserId(user.getId()).getPassword(), "222222"));
+        assertNotEquals("", res);
+        assertFalse(passEncoder.isValid(userDetailsService.findByUserId(user.getId()).getPassword(), newPass));
         userService.remove(user);
     }
 
@@ -271,8 +266,8 @@ public class AdminControllerTest {
         String newPass = "222222";
         String repNewPass = "222222";
         User user = new User("user", "user@mail", false, new Date(), userRole);
-        user.setUserDetails(new CustomUserDetails(oldPass, "link", user));
         user = userService.save(user);
+        userDetailsService.save(new CustomUserDetails(oldPass, "link", user));
 
         String res = mockMvc.perform(post("/admin/users/reset_pass")
                 .contentType(MediaType.APPLICATION_FORM_URLENCODED)
@@ -289,7 +284,7 @@ public class AdminControllerTest {
         userService.remove(user);
     }
 
-    @Test
+    @Test   
     public void switchLockStatusTest() throws Exception {
         User user = new User("user", "user@mail", false, new Date(), userRole);
         user = userService.save(user);
@@ -312,7 +307,7 @@ public class AdminControllerTest {
                 .andReturn().getResponse().getContentAsString());
 
         assertTrue(response);
-        assertNull(userService.findOne(user.getId()));
+        assertNull(userService.findById(user.getId()));
         userService.remove(user);
     }
 
@@ -326,7 +321,7 @@ public class AdminControllerTest {
                 .andReturn().getResponse().getContentAsString());
 
         assertFalse(response);
-        assertNotNull(userService.findOne(user.getId()));
+        assertNotNull(userService.findById(user.getId()));
 
         userRepository.delete(user);
     }
index a7623c4..8388864 100644 (file)
@@ -13,7 +13,6 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -24,7 +23,6 @@ import org.springframework.web.context.WebApplicationContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DashboardControllerTest {
     private MockMvc mockMvc;
 
index dc63de5..6eec35d 100644 (file)
@@ -8,7 +8,6 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -34,7 +33,6 @@ import java.security.Principal;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DashboardDevicesControllerTest {
     /** The mock mvc. */
     private MockMvc mockMvc;
index ab3edea..688df4d 100644 (file)
@@ -8,7 +8,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -19,7 +18,6 @@ import org.springframework.web.context.WebApplicationContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class HomeControllerTest {
     private MockMvc mockMvc;
 
index b1dbfa1..4178804 100644 (file)
@@ -8,7 +8,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -19,7 +18,6 @@ import org.springframework.web.context.WebApplicationContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class UserControllerTest {
     private MockMvc mockMvc;
 
index 6003ea8..1d6ba5e 100644 (file)
@@ -1,5 +1,12 @@
 package com.samsung.dsm.domain.oauth;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Arrays;
+import java.util.Collection;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -7,12 +14,7 @@ import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 import org.mockito.MockitoAnnotations;
 
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import com.samsung.dsm.domain.oauth.OAuthCode;
 
 /**
  * @author Mail to: <A HREF="mailto:y.zozulia@samsung.com">Yevhen Zozulia</A>
@@ -27,51 +29,74 @@ import static org.junit.Assert.*;
  */
 @RunWith(Parameterized.class)
 public class OAuthCodeTest {
-
+    
     private String code;
     private byte[] authentication;
-
+    
     @Parameters
     public static Collection<Object[]> data() {
-        Object[][] data = new Object[][]{
-                {"AuthCode = 1", "Authentication 1".getBytes()},
-                {"AuthCode = 2", "Authentication 2".getBytes()},
-                {"AuthCode = 3", "Authentication 3".getBytes()},
-                {"AuthCode = 4", "Authentication 4".getBytes()},
-                {"AuthCode = 5", "Authentication 5".getBytes()}
-        };
+        Object[][] data = new Object[][] { 
+            {"AuthCode = 1", "Authentication 1".getBytes()},
+            {"AuthCode = 2", "Authentication 2".getBytes()},
+            {"AuthCode = 3", "Authentication 3".getBytes()},
+            {"AuthCode = 4", "Authentication 4".getBytes()},
+            {"AuthCode = 5", "Authentication 5".getBytes()}             
+            };
         return Arrays.asList(data);
     }
-
+    
+    /**
+     * Public constructor for class OAuthCodeTest. Creates object OAuthCodeTest with
+     * parameters:
+     * 
+     * @param code - authorization code
+     * @param authentication - Authentication information
+     */
     public OAuthCodeTest(String code, byte[] authentication) {
         super();
         this.code = code;
         this.authentication = authentication;
     }
-
+    
     @Before
     public void initMocks() {
         MockitoAnnotations.initMocks(this);
     }
     
+    /**
+     * Checks default constructor
+     */
     @Test
-    public void testOAuthCode() {
+    public void testOAuthCode(){
         OAuthCode oAuthCode = new OAuthCode();
         assertNull(oAuthCode.getCode());
-        assertNull(oAuthCode.getAuthentication());
+        assertNull(oAuthCode.getAuthentication());      
         assertNull(oAuthCode.getCode());
     }
-
+    
+    /**
+    *
+    * Checks constructor with parameters:
+    *
+    * @param code - auth code
+    * @param token - refresh token
+    * @param authentication - authentication
+    */
     @Test
     public void testOAuthCodeWithParameters() {
         OAuthCode oAuthCode = new OAuthCode(code, authentication);
-        assertEquals(code, oAuthCode.getCode());
-        assertEquals(authentication, oAuthCode.getAuthentication());
-        assertNotNull(oAuthCode.getCode());
-        assertNotNull(oAuthCode.getAuthentication());
+        assertEquals(code, oAuthCode.getCode());       
+        assertEquals(authentication, oAuthCode.getAuthentication());        
+        assertNotNull(oAuthCode.getCode());       
+        assertNotNull(oAuthCode.getAuthentication());               
     }
-
-    @Test
+     
+    /**
+     * Checks setting auth code
+     * 
+     * @param code - auth code
+     */
+    @Test    
     public void testSetCode() {
         OAuthCode oAuthCode = new OAuthCode();
         oAuthCode.setCode(code);
@@ -79,6 +104,11 @@ public class OAuthCodeTest {
         assertEquals(code, oAuthCode.getCode());
     }
 
+    /**
+     * Checks setting authentication identifier.
+     * 
+     * @param authenticationId - authentication identifier.
+     */
     @Test
     public void testSetAuthentication() {
         OAuthCode OAuthCode = new OAuthCode();
@@ -87,9 +117,4 @@ public class OAuthCodeTest {
         assertEquals(authentication, OAuthCode.getAuthentication());
     }
 
-    @Test
-    public void toStringTest() {
-        assertThat(new OAuthCode("code", new byte[]{1, 2, 3, 4}).toString(), is("OAuthCode [code=code, authentication=[1, 2, 3, 4]]"));
-        assertThat(new OAuthCode().toString(), is("OAuthCode [code=null, authentication=null]"));
-    }
 }
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestAgentTest.java b/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestAgentTest.java
deleted file mode 100644 (file)
index 315db14..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.samsung.dsm.model.restapi;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-import static org.mockito.AdditionalMatchers.eq;
-
-public class RestAgentTest {
-    private RestAgent restAgent;
-
-    @Before
-    public void setUp() {
-        restAgent = new RestAgent("uuid", "name");
-    }
-
-    @Test
-    public void toStringTest() throws Exception {
-        assertThat(restAgent.toString(), is("RestAgent{uuid='uuid', name='name'}"));
-    }
-
-    @Test
-    public void hashCodeTest() throws Exception {
-        assertThat(restAgent.hashCode(), is(new RestAgent("uuid", "name").hashCode()));
-    }
-
-    @Test
-    public void equalsTest() throws Exception {
-        assertThat(restAgent, is(new RestAgent("uuid", "name")));
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestDeviceTest.java b/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/RestDeviceTest.java
deleted file mode 100644 (file)
index 7c8d60f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.samsung.dsm.model.restapi;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class RestDeviceTest {
-    private RestDevice restDevice;
-
-    @Before
-    public void setUp() {
-        restDevice = new RestDevice("uuid", "name", "type", "model", 1);
-    }
-
-    @Test
-    public void toStringTest() throws Exception {
-        assertThat(restDevice.toString(), is("RestDevice{uuid='uuid', name='name', type='type', model='model', status=1}"));
-    }
-
-    @Test
-    public void hashCodeTest() throws Exception {
-        assertThat(restDevice.hashCode(), is(new RestDevice("uuid", "name", "type", "model", 1).hashCode()));
-    }
-
-    @Test
-    public void equalsTest() throws Exception {
-        assertThat(restDevice, is(new RestDevice("uuid", "name", "type", "model", 1)));
-    }
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/AgentConverterTest.java b/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/AgentConverterTest.java
deleted file mode 100644 (file)
index ad1dd22..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.samsung.dsm.model.restapi.converter;
-
-import com.samsung.commons.domain.Agent;
-import com.samsung.dsm.model.restapi.RestAgent;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-public class AgentConverterTest {
-
-    private AgentConverter agentConverter;
-
-    @Before
-    public void setUp() {
-        agentConverter = new AgentConverter();
-    }
-
-    @Test
-    public void convert() {
-        Agent entity = new Agent();
-        entity.setUuid("uuid");
-        entity.setName("name");
-
-        RestAgent restAgent = agentConverter.convert(entity);
-
-        assertThat(restAgent.getUuid(), is("uuid"));
-        assertThat(restAgent.getName(), is("name"));
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DeviceConverterTest.java b/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DeviceConverterTest.java
deleted file mode 100644 (file)
index 79d1a9d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.samsung.dsm.model.restapi.converter;
-
-import com.samsung.commons.domain.Device;
-import com.samsung.dsm.model.restapi.RestDevice;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class DeviceConverterTest {
-
-    private DeviceConverter deviceConverter;
-
-    @Before
-    public void setUp() {
-        deviceConverter = new DeviceConverter();
-    }
-
-    @Test
-    public void convert() {
-        Device entity = new Device();
-        entity.setUuid("uuid");
-        entity.setName("name");
-        entity.setType("type");
-        entity.setModel("model");
-        entity.setStatus(42);
-
-        RestDevice restDevice = deviceConverter.convert(entity);
-
-        assertThat(restDevice.getUuid(), is("uuid"));
-        assertThat(restDevice.getName(), is("name"));
-        assertThat(restDevice.getType(), is("type"));
-        assertThat(restDevice.getModel(), is("model"));
-        assertThat(restDevice.getStatus(), is(42));
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DomainToRestConverterTest.java b/servers/dsm/src/test/java/com/samsung/dsm/model/restapi/converter/DomainToRestConverterTest.java
deleted file mode 100644 (file)
index bef4838..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.samsung.dsm.model.restapi.converter;
-
-import com.samsung.dsm.model.restapi.RestEntity;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-public class DomainToRestConverterTest {
-
-    private DomainToRestConverter converter;
-
-    @Before
-    public void setUp() {
-        initMocks(this);
-
-        converter = mock(DomainToRestConverter.class, CALLS_REAL_METHODS);
-    }
-
-    @Test
-    @SuppressWarnings(value = "unchecked")
-    public void convertList() {
-        Object first = new Object();
-        Object second = new Object();
-        Object third = new Object();
-
-        List list = new ArrayList();
-        list.add(first);
-        list.add(second);
-        list.add(third);
-
-        RestEntity firstConverted = mock(RestEntity.class);
-        RestEntity secondConverted = mock(RestEntity.class);
-        RestEntity thirdConverted = mock(RestEntity.class);
-
-        when(converter.convert(first)).thenReturn(firstConverted);
-        when(converter.convert(second)).thenReturn(secondConverted);
-        when(converter.convert(third)).thenReturn(thirdConverted);
-
-        List listConverted = converter.convert(list);
-        assertThat(listConverted.size(), is(3));
-        assertThat(listConverted.contains(firstConverted), is(true));
-        assertThat(listConverted.contains(secondConverted), is(true));
-        assertThat(listConverted.contains(thirdConverted), is(true));
-
-        verify(converter, times(1)).convert(first);
-        verify(converter, times(1)).convert(second);
-        verify(converter, times(1)).convert(third);
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/policy/parser/PolicyParserFactoryTest.java b/servers/dsm/src/test/java/com/samsung/dsm/policy/parser/PolicyParserFactoryTest.java
deleted file mode 100644 (file)
index eea93e3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.samsung.dsm.policy.parser;
-
-import org.junit.Test;
-
-import static com.samsung.dsm.policy.parser.PolicyParserFactory.getParser;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
-public class PolicyParserFactoryTest {
-
-    @Test
-    public void jsonType() {
-        assertThat(getParser(PolicyParserFactory.Type.JSON) instanceof JSONPolicyConfigParser, is(true));
-    }
-
-    @Test
-    public void nullType() {
-        assertThat(getParser(null), is(nullValue()));
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/report/ReportConfigTest.java b/servers/dsm/src/test/java/com/samsung/dsm/report/ReportConfigTest.java
deleted file mode 100644 (file)
index db5caae..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.samsung.dsm.report;
-
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class ReportConfigTest {
-
-    @Test
-    public void reportToString() {
-        assertThat(
-                new ReportConfig.Report("did", "date", "name", 0, "data").toString(),
-                is("Report [did=did, date=date, name=name, result=0, data=data]"));
-    }
-}
\ No newline at end of file
index 8cda3ab..946f511 100644 (file)
@@ -1,11 +1,9 @@
 package com.samsung.dsm.rest;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -24,7 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+
 public class AccessTokenApiTest {
 
     private final String ROOT_URL = "/restapi";
@@ -62,16 +60,4 @@ public class AccessTokenApiTest {
         String content = result.andReturn().getResponse().getContentAsString();
         assertThat(content, isEmptyString());
     }
-
-    @Test
-    @Ignore(value = "Complete test")
-    public void accessTokenOk() throws Exception {
-        ResultActions result =
-                mockMvc.perform(get(ROOT_URL + "/access_token")
-                        .param("access_token", "token"))
-                        .andExpect(status().isOk());
-
-        String content = result.andReturn().getResponse().getContentAsString();
-        assertThat(content, not(isEmptyString()));
-    }
 }
index 1333962..d50589d 100644 (file)
@@ -11,14 +11,12 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.samsung.commons.service.impl.RoleServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -41,7 +39,7 @@ import com.samsung.dsm.utils.JsonUtils;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+
 public class DeviceApiTest {
 
     private final String ROOT_URL = "/restapi";
@@ -52,7 +50,7 @@ public class DeviceApiTest {
     private WebApplicationContext webApplicationContext;
 
     @Autowired
-    private UserServiceImpl userService;
+    private UserService userService;
 
     @Autowired
     private IotCloudService iotCloudService;
@@ -64,16 +62,15 @@ public class DeviceApiTest {
     private PolicyService policyService;
 
     @Autowired
-    private RoleServiceImpl roleService;
+    private RoleService roleService;
 
     private Set<Device> devices = new HashSet<>();
 
     @Before
     public void before() {
         String route = "route";
-
-        User user = userService.save(new User("another1", "another1@samsung.com", false, new Date(), roleService.findOne(1L)));
-        iotCloudService.createAndSaveUser("another1@samsung.com", "1234");
+        iotCloudService.createAndSaveUser("admin@samsung.com", "1234");
+        User user = userService.getUserByEmail("admin@samsung.com");
 
         // Device with agent
         Device device = new Device("1234", "s8", "phone", "samsung s8 edge", 1, policyService.initPolicy(route), user);
@@ -91,7 +88,7 @@ public class DeviceApiTest {
         devices.add(deviceService.save(new Device("1237", "vacuum cleaner samsung", "vacuum cleaner", "FY128192JJJ", 1, policyService.initPolicy(route), user, true)));
 
         // User without devices
-        userService.save(new User("another", "another@samsung.com", false, new Date(), roleService.findOne(1L)));
+        userService.save(new User("another", "another@samsung.com", false, new Date(), roleService.findById(1L)));
         iotCloudService.createAndSaveUser("another@samsung.com", "1235");
 
         mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
@@ -100,7 +97,7 @@ public class DeviceApiTest {
     @After
     public void after() {
         deviceService.remove(devices);
-        userService.removeByUserName("another1");
+        iotCloudService.deleteAllUsers();
         userService.removeByUserName("another");
     }
 
@@ -157,19 +154,21 @@ public class DeviceApiTest {
     }
 
     @Test
+    @Ignore
     public void findPolicyByUuidOk() throws Exception {
         ResultActions result = mockMvc.perform(get(ROOT_URL + "/device/1234/policy")).andExpect(status().isOk());
         String content = result.andReturn().getResponse().getContentAsString();
 
-        assertEquals("[\t{\t\t\"group\": \"tv-extension\",\t\t\"policies\": [\t\t\t{\t\t\t\t\"name\": \"sound\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"bluetooth\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"wifi\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"usb\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"dtv-tunner\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"iptables\",\t\t\t\t\"state\": -1,\t\t\t\t\"items\": [\t\t\t\t\t\"tcp:192.168.0.0/24:* 192.169.0.0/24:100-200\"\t\t\t\t]\t\t\t}\t\t]\t}]", content);
+        assertEquals("[\t{\t\t\"group\": \"tv-extension\",\t\t\"policies\": [\t\t\t{\t\t\t\t\"name\": \"usb\",\t\t\t\t\"state\": 0,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"screen-capture\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"bluetooth\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"iptables\",\t\t\t\t\"state\": -1,\t\t\t\t\"items\": [\t\t\t\t\t\"127.0.0.0/24|UDP|10-1024\",\t\t\t\t\t\"1.1.1.1|TCP|80,443\",\t\t\t\t\t\"8.8.8.8\"\t\t\t\t]\t\t\t}\t\t]\t}]",content);
     }
 
     @Test
+    @Ignore
     public void findPolicyByUuidForRemovedDeviceOk() throws Exception {
         ResultActions result = mockMvc.perform(get(ROOT_URL + "/device/1237/policy")).andExpect(status().isOk());
         String content = result.andReturn().getResponse().getContentAsString();
 
-        assertEquals("[\t{\t\t\"group\": \"tv-extension\",\t\t\"policies\": [\t\t\t{\t\t\t\t\"name\": \"sound\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"bluetooth\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"wifi\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"usb\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"dtv-tunner\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"iptables\",\t\t\t\t\"state\": -1,\t\t\t\t\"items\": [\t\t\t\t\t\"tcp:192.168.0.0/24:* 192.169.0.0/24:100-200\"\t\t\t\t]\t\t\t}\t\t]\t}]", content);
+        assertEquals("[\t{\t\t\"group\": \"tv-extension\",\t\t\"policies\": [\t\t\t{\t\t\t\t\"name\": \"usb\",\t\t\t\t\"state\": 0,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"screen-capture\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"bluetooth\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"iptables\",\t\t\t\t\"state\": -1,\t\t\t\t\"items\": [\t\t\t\t\t\"127.0.0.0/24|UDP|10-1024\",\t\t\t\t\t\"1.1.1.1|TCP|80,443\",\t\t\t\t\t\"8.8.8.8\"\t\t\t\t]\t\t\t}\t\t]\t}]",content);
     }
 
     @Test
index 9047e70..8001c40 100644 (file)
@@ -1,19 +1,13 @@
 package com.samsung.dsm.rest;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
-import com.samsung.commons.domain.User;
-import com.samsung.commons.service.RoleService;
-import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.UserServiceImpl;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -28,7 +22,7 @@ import com.samsung.commons.service.IotCloudService;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+
 public class IotCloudApiTest {
 
     private final String ROOT_URL = "/restapi";
@@ -39,51 +33,31 @@ public class IotCloudApiTest {
     private WebApplicationContext webApplicationContext;
 
     @Autowired
-    private UserServiceImpl userService;
-
-    @Autowired
-    private RoleService roleService;
-
-    @Autowired
     private IotCloudService iotCloudService;
 
-    private User user;
-
     @Before
     public void before() {
-
-        User user = userService.findByUsername("username1");
-        if (user == null) {
-            this.user = userService.save(new User("username1", "email1", roleService.getByName("ROLE_ADMIN")));
-        }
-
         mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
     }
 
+    @After
+    public void after() {
+        iotCloudService.deleteAllUsers();
+    }
+
     @Test
     public void createAndSaveIotCloudUserOk() throws Exception {
-        mockMvc.perform(get(ROOT_URL + "/iotcloud/createUser")
-                .param("email", "email1")
-                .param("uuid", "1234567890"))
-                .andExpect(status().isOk());
-
-        assertThat(iotCloudService.usersCount(), is(1L));
-        userService.remove(userService.findOne(this.user.getId()));
+        normalUser();
     }
 
     @Test
     public void createAndSaveIotCloudUserConflict() throws Exception {
-        mockMvc.perform(get(ROOT_URL + "/iotcloud/createUser")
-                .param("email", "email1")
-                .param("uuid", "1234567890"))
-                .andExpect(status().isOk());
+        normalUser();
 
         mockMvc.perform(get(ROOT_URL + "/iotcloud/createUser")
-                .param("email", "email1")
+                .param("email", "admin@samsung.com")
                 .param("uuid", "1234567890"))
                 .andExpect(status().isConflict());
-
-        userService.remove(userService.findOne(this.user.getId()));
     }
 
     @Test
@@ -95,4 +69,12 @@ public class IotCloudApiTest {
                 .andExpect(status().isNotFound());
     }
 
+    private void normalUser() throws Exception {
+        @SuppressWarnings("unused")
+        ResultActions result = mockMvc.perform(get(ROOT_URL + "/iotcloud/createUser")
+                .param("email", "admin@samsung.com")
+                .param("uuid", "1234567890"))
+                .andExpect(status().isOk());
+
+    }
 }
\ No newline at end of file
index 1fccd77..aeafaa0 100644 (file)
@@ -2,19 +2,16 @@ package com.samsung.dsm.rest;
 
 import com.samsung.commons.domain.Agent;
 import com.samsung.commons.domain.Device;
-import com.samsung.commons.domain.Policy;
 import com.samsung.commons.domain.User;
 import com.samsung.commons.service.DeviceService;
 import com.samsung.commons.service.PolicyService;
 import com.samsung.commons.service.UserService;
-import com.samsung.commons.utils.UrlBuilder;
 import com.samsung.dsm.utils.JsonUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -36,9 +33,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+
 public class PolicyApiTest {
 
+    private final String ROOT_URL = "/restapi";
+
     private MockMvc mockMvc;
 
     @Autowired
@@ -55,19 +54,11 @@ public class PolicyApiTest {
 
     private Set<Device> devices = new HashSet<>();
 
-    private UrlBuilder builder;
-
-    private Policy policy;
-
     @Before
     public void before() {
-        builder = new UrlBuilder();
-        builder.add("policy");
-
         String route = "route";
-        User user = userService.findUserByEmail("admin@samsung.com");
-        policy = policyService.initPolicy(route);
-        Device device = new Device("1234", "s8", "phone", "samsung s8 edge", 1, policy, user);
+        User user = userService.getUserByEmail("admin@samsung.com");
+        Device device = new Device("1234", "s8", "phone", "samsung s8 edge", 1, policyService.initPolicy(route), user);
         List<Agent> agents = new ArrayList<>();
         Agent agent = new Agent("5678", "name1", policyService.initPolicy(route));
         agent.setDevice(device);
@@ -87,72 +78,17 @@ public class PolicyApiTest {
     }
 
     @Test
-    public void policyByDeviceUuidAndByAgentUuidNotFound() throws Exception {
-        String url = builder
-                .add("device", "dev-unexistent-uuid")
-                .add("agent", "agent-unexistent-uuid")
-                .build();
-
-        mockMvc.perform(get(url)).andExpect(status().isNotFound());
-    }
-
-    @Test
-    public void findPolicyByDeviceAndAgent() throws Exception {
-        String url = builder
-                .add("device", 1234)
-                .add("agent", 5678)
-                .build();
-
-        ResultActions result = mockMvc.perform(get(url)).andExpect(status().isOk());
+    public void policyByDeviceUuidAndByAgentUuidOk() throws Exception {
+        ResultActions result = mockMvc.perform(get(ROOT_URL + "/device/1234")).andExpect(status().isOk());
         String content = result.andReturn().getResponse().getContentAsString();
 
-        assertTrue(JsonUtils.equalJson(content, "[\t{\t\t\"group\": \"tv-extension\",\t\t\"policies\": " +
-                "[\t\t\t{\t\t\t\t\"name\": \"sound\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t" +
-                "{\t\t\t\t\"name\": \"bluetooth\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t" +
-                "\"name\": \"wifi\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": " +
-                "\"usb\",\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"dtv-tunner\"," +
-                "\t\t\t\t\"state\": 1,\t\t\t\t\"items\": []\t\t\t},\t\t\t{\t\t\t\t\"name\": \"iptables\",\t\t\t\t\"" +
-                "state\": -1,\t\t\t\t\"items\": [\t\t\t\t\t\"tcp:192.168.0.0/24:* 192.169.0.0/24:100-200\"\t\t\t\t]" +
-                "\t\t\t}\t\t]\t}]"));
+        assertTrue(JsonUtils.equalJson(content, "{\"uuid\":\"1234\",\"name\":\"s8\",\"type\":\"phone\",\"model\":\"samsung s8 edge\",\"status\":1}"));
     }
 
     @Test
-    public void requestPolicy() throws Exception {
-        String url = builder
-                .add("request", policy.getId())
-                .add("device", 1)
-                .build();
-
-        mockMvc.perform(get(url)).andExpect(status().isOk());
-    }
-
-    @Test
-    public void requestPolicyWrongPolicyId() throws Exception {
-        String url = builder
-                .add("request", 1)
-                .add("device", 1)
-                .build();
-
-        mockMvc.perform(get(url)).andExpect(status().isOk());
-    }
-
-    @Test
-    public void requestAgentPolicy() throws Exception {
-        String url = builder
-                .add("request", 1)
-                .add("agent", 5678)
-                .build();
-
-        mockMvc.perform(get(url)).andExpect(status().isOk());
+    public void policyByDeviceUuidAndByAgentUuidNotFound() throws Exception {
+        mockMvc.perform(get(ROOT_URL + "/policy/device/dev-unexistent-uuid/agent/agent-unexistent-uuid")).andExpect(status().isNotFound());
     }
 
-    @Test
-    public void requestAgentPolicyWrongPolicyId() throws Exception {
-        String url = builder
-                .add("request", 1)
-                .add("agent", 1)
-                .build();
 
-        mockMvc.perform(get(url)).andExpect(status().isOk());
-    }
 }
\ No newline at end of file
index b00b9eb..5d24d31 100644 (file)
@@ -1,19 +1,14 @@
 package com.samsung.dsm.rest;
 
-import com.samsung.commons.domain.Device;
-import com.samsung.commons.domain.Report;
-import com.samsung.commons.domain.ReportType;
-import com.samsung.commons.domain.User;
-import com.samsung.commons.repository.ReportTypeRepository;
-import com.samsung.commons.service.*;
-import com.samsung.dsm.utils.CloudUserBuilder;
-import com.samsung.dsm.utils.UserBuilder;
+import static org.junit.Assert.assertEquals;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -22,14 +17,21 @@ import org.springframework.test.web.servlet.ResultActions;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.web.context.WebApplicationContext;
 
-import static org.junit.Assert.assertEquals;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import com.samsung.commons.domain.Device;
+import com.samsung.commons.domain.Report;
+import com.samsung.commons.domain.ReportType;
+import com.samsung.commons.domain.User;
+import com.samsung.commons.repository.ReportTypeRepository;
+import com.samsung.commons.service.DeviceService;
+import com.samsung.commons.service.IotCloudService;
+import com.samsung.commons.service.PolicyService;
+import com.samsung.commons.service.ReportService;
+import com.samsung.commons.service.UserService;
+
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class ReportApiTest {
 
     private static final String testInputData = "{" + "\"did\": \"1234\"," + "\"date\": \"12:25 PM; May 08, 2017\","
@@ -50,31 +52,9 @@ public class ReportApiTest {
             "[23926][#6  0x00026e1b in yy_readline_get () from /usr/bin/bash]\n" +
             "[23926][#7  0x0002860d in shell_getc () from /usr/bin/bash]\n" + testInputDataEnd;
 
-    private static final String report2 = testInputDataBegin + "[MAC] audit(1500281614.841:722): lsm=SMACK fn=smack_inode_getattr action=denied mode=enforcing wait=no subject=User object=System requested=r d_inst=1 ppid=22847 ppid_comm=bash pid=23926 comm=smack_test path=/tmp/wm_start dev=tmpfs ino=18596 user_bt=23926\n" +
-            "[23926][#0  0x429b5e3c in ___xstat64 () from /usr/lib/libc-2.24.so]\n" +
-            "[23926][#1  0x0006b439 in append_to_match () from /usr/bin/bash]\n" +
-            "[23926][#2  0x0006cda9 in rl_complete_internal () from /usr/bin/bash]\n" +
-            "[23926][#3  0x00067385 in _rl_dispatch_subseq () from /usr/bin/bash]\n" +
-            "[23926][#4  0x00067543 in readline_internal_char () from /usr/bin/bash]\n" +
-            "[23926][#5  0x000679f7 in readline () from /usr/bin/bash]\n" +
-            "[23926][#6  0x00026e1b in yy_readline_get () from /usr/bin/bash]\n" +
-            "[23926][#7  0x0002860d in shell_getc () from /usr/bin/bash]\n" + testInputDataEnd;
-
-    private static final String report3 = testInputDataBegin + "[MAC] audit(1500281614.841:722): lsm=SMACK fn=smack_inode_getattr action=denied mode=enforcing wait=no subject=User object=System requested=r d_inst=1 ppid=22847 ppid_comm=smack_test pid=23926 comm=smack_test path=/tmp/wm_start dev=tmpfs ino=18596 user_bt=23926\n" +
-            "[23926][#0  0x429b5e3c in ___xstat64 () from /usr/lib/libc-2.24.so]\n" +
-            "[23926][#1  0x0006b439 in append_to_match () from /usr/bin/bash]\n" +
-            "[23926][#2  0x0006cda9 in rl_complete_internal () from /usr/bin/bash]\n" +
-            "[23926][#3  0x00067385 in _rl_dispatch_subseq () from /usr/bin/bash]\n" +
-            "[23926][#4  0x00067543 in readline_internal_char () from /usr/bin/bash]\n" +
-            "[23926][#5  0x000679f7 in readline () from /usr/bin/bash]\n" +
-            "[23926][#6  0x00026e1b in yy_readline_get () from /usr/bin/bash]\n" +
-            "[23926][#7  0x0002860d in shell_getc () from /usr/bin/bash]\n" + testInputDataEnd;
-
     private MockMvc mockMvc;
     private long reportId1;
     private long reportId2;
-    private long reportId3;
-    private long reportId4;
 
     @Autowired
     private WebApplicationContext webApplicationContext;
@@ -97,20 +77,13 @@ public class ReportApiTest {
     @Autowired
     private IotCloudService iotCloudService;
 
-    @Autowired
-    private UserBuilder userBuilder;
-
-    @Autowired
-    private CloudUserBuilder cloudUserBuilder;
-
     @Before
     public void before() {
-        userBuilder.withNameEmailRole("another1", "another1@samsung.com", "ROLE_ADMIN").build();
-        cloudUserBuilder.withEmail("another1@samsung.com").build();
+        String route = "route";
+        iotCloudService.createAndSaveUser("admin@samsung.com", "1234");
+        User user = userService.findByUsername("admin");
 
-        User user = userService.findByUsername("another1");
-
-        Device device = new Device("1234", "s4", "phone", "samsung s7 edge", 1, policyService.initPolicy("route"), user);
+        Device device = new Device("1234", "s4", "phone", "samsung s7 edge", 1, policyService.initPolicy(route), user);
         deviceService.save(device);
 
         ReportType reportType = reportTypeRepository.findByType(ReportType.Type.SIM.type);
@@ -119,8 +92,6 @@ public class ReportApiTest {
         reportService.save(new Report(reportType, "report2", "13/12/2017", 2, device));
         reportId1 = reportService.save(new Report(reportType, testInputData, "13/12/2017", 2, device)).getId();
         reportId2 = reportService.save(new Report(reportTypeRepository.findByType(ReportType.Type.SMACK.type), report, "13/12/2017", 2, device)).getId();
-        reportId3 = reportService.save(new Report(reportTypeRepository.findByType(ReportType.Type.SMACK.type), report2, "13/12/2017", 2, device)).getId();
-        reportId4 = reportService.save(new Report(reportTypeRepository.findByType(ReportType.Type.SMACK.type), report3, "13/12/2017", 2, device)).getId();
 
         mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
     }
@@ -129,9 +100,6 @@ public class ReportApiTest {
     public void after() {
         reportService.removeAll();
         deviceService.removeAll();
-
-        // userService.removeAll();
-        iotCloudService.deleteAllUsers();
     }
 
     @Test
@@ -139,44 +107,19 @@ public class ReportApiTest {
         ResultActions result = mockMvc.perform(get("/restapi/report/1234")).andExpect(status().isOk());
         String content = result.andReturn().getResponse().getContentAsString();
 
-        assertEquals("[report1,report2,{\"did\": \"1234\",\"date\": \"12:25 PM; May 08, 2017\"," +
-                "\"name\": \"sim\",\"result\": 0,\"data\": {}},{\"did\": \"1234\",\"date\": " +
-                "\"12:25 PM; May 08, 2017\",\"name\": \"smack\",\"result\": 0,\"data\": " +
-                "{log=\"[MAC] audit(1500281614.841:722): lsm=SMACK fn=smack_inode_getattr action=denied " +
-                "mode=enforcing wait=no subject=User object=System requested=r d_inst=1 ppid=22847 " +
-                "ppid_comm=bash pid=23926 comm=bash path=/tmp/wm_start dev=tmpfs ino=18596 " +
-                "user_bt=23926[23926][#0  0x429b5e3c in ___xstat64 () " +
-                "from /usr/lib/libc-2.24.so][23926][#1  0x0006b439 in append_to_match () " +
-                "from /usr/bin/bash][23926][#2  0x0006cda9 in rl_complete_internal () " +
-                "from /usr/bin/bash][23926][#3  0x00067385 in _rl_dispatch_subseq () " +
-                "from /usr/bin/bash][23926][#4  0x00067543 in readline_internal_char () " +
-                "from /usr/bin/bash][23926][#5  0x000679f7 in readline () from /usr/bin/bash][23926][#6  " +
-                "0x00026e1b in yy_readline_get () from /usr/bin/bash][23926][#7  0x0002860d in shell_getc () " +
-                "from /usr/bin/bash]\"}},{\"did\": \"1234\",\"date\": \"12:25 PM; May 08, 2017\",\"name\": " +
-                "\"smack\",\"result\": 0,\"data\": {log=\"[MAC] audit(1500281614.841:722): " +
-                "lsm=SMACK fn=smack_inode_getattr action=denied mode=enforcing wait=no subject=User " +
-                "object=System requested=r d_inst=1 ppid=22847 ppid_comm=bash pid=23926 " +
-                "comm=smack_test path=/tmp/wm_start dev=tmpfs ino=18596 user_bt=23926[23926][#0  " +
-                "0x429b5e3c in ___xstat64 () from /usr/lib/libc-2.24.so][23926][#1  0x0006b439 in " +
-                "append_to_match () from /usr/bin/bash][23926][#2  0x0006cda9 in rl_complete_internal " +
-                "() from /usr/bin/bash][23926][#3  0x00067385 in _rl_dispatch_subseq () " +
-                "from /usr/bin/bash][23926][#4  0x00067543 in readline_internal_char () " +
-                "from /usr/bin/bash][23926][#5  0x000679f7 in readline () from /usr/bin/bash][23926][#6  " +
-                "0x00026e1b in yy_readline_get () from /usr/bin/bash][23926][#7  0x0002860d in shell_getc " +
-                "() from /usr/bin/bash]\"}},{\"did\": \"1234\",\"date\": \"12:25 PM; May 08, 2017\",\"name\": " +
-                "\"smack\",\"result\": 0,\"data\": {log=\"[MAC] audit(1500281614.841:722): " +
-                "lsm=SMACK fn=smack_inode_getattr action=denied mode=enforcing wait=no subject=User " +
-                "object=System requested=r d_inst=1 ppid=22847 ppid_comm=smack_test pid=23926 " +
-                "comm=smack_test path=/tmp/wm_start dev=tmpfs ino=18596 user_bt=23926[23926][#0  " +
-                "0x429b5e3c in ___xstat64 () from /usr/lib/libc-2.24.so][23926][#1  0x0006b439 " +
-                "in append_to_match () from /usr/bin/bash][23926][#2  0x0006cda9 in rl_complete_internal " +
-                "() from /usr/bin/bash][23926][#3  0x00067385 in _rl_dispatch_subseq () from " +
-                "/usr/bin/bash][23926][#4  0x00067543 in readline_internal_char () from /usr/bin/bash][23926][#5 " +
-                " 0x000679f7 in readline () from /usr/bin/bash][23926][#6  0x00026e1b in yy_readline_get " +
-                "() from /usr/bin/bash][23926][#7  0x0002860d in shell_getc () from /usr/bin/bash]\"}}]", content);
+        assertEquals(strip("[report1,report2,{\"did\": \"1234\",\"date\": \"12:25 PM; May 08, 2017\",\"name\": \"sim\",\"result\": 0,\"data\": {}},{\"did\": \"1234\",\"date\": \"12:25 PM; May 08, 2017\",\"name\": \"smack\",\"result\": 0,\"data\": {log=\"[MAC] audit(1500281614.841:722): lsm=SMACK fn=smack_inode_getattr action=denied mode=enforcing wait=no subject=User object=System requested=r d_inst=1 ppid=22847 ppid_comm=bash pid=23926 comm=bash path=/tmp/wm_start dev=tmpfs ino=18596 user_bt=23926\n" +
+                "[23926][#0  0x429b5e3c in ___xstat64 () from /usr/lib/libc-2.24.so]\n" +
+                "[23926][#1  0x0006b439 in append_to_match () from /usr/bin/bash]\n" +
+                "[23926][#2  0x0006cda9 in rl_complete_internal () from /usr/bin/bash]\n" +
+                "[23926][#3  0x00067385 in _rl_dispatch_subseq () from /usr/bin/bash]\n" +
+                "[23926][#4  0x00067543 in readline_internal_char () from /usr/bin/bash]\n" +
+                "[23926][#5  0x000679f7 in readline () from /usr/bin/bash]\n" +
+                "[23926][#6  0x00026e1b in yy_readline_get () from /usr/bin/bash]\n" +
+                "[23926][#7  0x0002860d in shell_getc () from /usr/bin/bash]\n" +
+                "\"}}]"), content);
     }
 
-    private String strip(String str) {
+    private String strip(String str){
         return str.replace("\n", "").replace("\b", "").replace("\t", "").replace("\r", "");
     }
 
@@ -192,20 +135,10 @@ public class ReportApiTest {
     public void newReportNotificationWronReport() throws Exception {
         mockMvc.perform(get("/restapi/report/newreport/" + reportId1)).andExpect(status().isOk());
     }
-
+    
     @Test
     public void newReportNotification() throws Exception {
         mockMvc.perform(get("/restapi/report/newreport/" + reportId2)).andExpect(status().isOk());
     }
 
-    @Test
-    public void newReportNotificationSmackTest() throws Exception {
-        mockMvc.perform(get("/restapi/report/newreport/" + reportId3)).andExpect(status().isOk());
-    }
-
-    @Test
-    public void newReportNotificationSmackTestParentCommandSmackTest() throws Exception {
-        mockMvc.perform(get("/restapi/report/newreport/" + reportId4)).andExpect(status().isOk());
-    }
-
 }
\ No newline at end of file
index ecf2be2..3e4543b 100644 (file)
@@ -3,11 +3,9 @@ package com.samsung.dsm.rest.mq;
 import com.samsung.commons.model.MQPolicy;
 import com.samsung.commons.model.Notification;
 
-import java.net.URISyntaxException;
-
 public class MQSenderImplMock extends MQSenderImpl {
-
-    MQSenderImplMock(String host) throws URISyntaxException {
+    
+    MQSenderImplMock(String host){
         super(host);
     }
 
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/rest/mq/MQSenderTest.java b/servers/dsm/src/test/java/com/samsung/dsm/rest/mq/MQSenderTest.java
deleted file mode 100644 (file)
index 425185b..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.samsung.dsm.rest.mq;
-
-import com.samsung.commons.model.MQPolicy;
-import com.samsung.commons.model.Notification;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import java.net.URISyntaxException;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-import static org.springframework.http.HttpStatus.NOT_FOUND;
-import static org.springframework.http.HttpStatus.OK;
-
-public class MQSenderTest {
-
-    private MQSenderImpl sender;
-
-    @Mock
-    private RestTemplate restTemplate;
-
-    @Before
-    public void before() {
-        initMocks(this);
-
-        try {
-            sender = new MQSenderImpl("http://localhost");
-        } catch (URISyntaxException e) {
-            // ignore
-        }
-
-        sender.setRestTemplate(restTemplate);
-    }
-
-    @Test
-    public void sendNotificationOk() throws Exception {
-        when(restTemplate.exchange(any(), any(), any(), eq(ResponseEntity.class))).thenReturn(new ResponseEntity<>(OK));
-        assertThat(sender.sendNotification(new Notification()), is(true));
-    }
-
-    @Test
-    public void sendNotificationFail() throws Exception {
-        when(restTemplate.exchange(any(), any(), any(), eq(ResponseEntity.class))).thenReturn(new ResponseEntity<>(NOT_FOUND));
-        assertThat(sender.sendNotification(new Notification()), is(false));
-    }
-
-    @Test
-    public void sendPolicyOk() throws Exception {
-        when(restTemplate.exchange(any(), any(), any(), eq(ResponseEntity.class))).thenReturn(new ResponseEntity<>(OK));
-        assertThat(sender.sendPolicy(new MQPolicy()), is(true));
-    }
-
-    @Test
-    public void sendPolicyFail() throws Exception {
-        when(restTemplate.exchange(any(), any(), any(), eq(ResponseEntity.class))).thenReturn(new ResponseEntity<>(NOT_FOUND));
-        assertThat(sender.sendPolicy(new MQPolicy()), is(false));
-    }
-
-    @Test
-    public void badUrl() {
-        try {
-            new MQSenderImpl("bad_url");
-        } catch (URISyntaxException e) {
-            fail();
-        }
-    }
-}
\ No newline at end of file
index 0823326..6549d56 100644 (file)
@@ -13,12 +13,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
 
 import com.samsung.dsm.domain.oauth.OAuthAccessToken;
+import com.samsung.dsm.service.AccessTokenService;
 
 /**
  * @author Mail to: <A HREF="mailto:y.zozulia@samsung.com">Yevhen Zozulia</A>
@@ -33,8 +33,7 @@ import com.samsung.dsm.domain.oauth.OAuthAccessToken;
  */
 @RunWith(SpringJUnit4ClassRunner.class)
 @WebAppConfiguration
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
+@ContextConfiguration(locations = { "classpath:root-context.xml" })
 public class AccessTokenServiceTest {
     
     private static final String accessToken = "Access token";
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/service/GrantedApplicationServiceTest.java b/servers/dsm/src/test/java/com/samsung/dsm/service/GrantedApplicationServiceTest.java
deleted file mode 100644 (file)
index ac97aef..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.samsung.dsm.service;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class GrantedApplicationServiceTest {
-    @Test
-    public void findByParentCommandAndCommand() throws Exception {
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/service/impl/AccessTokenServiceImplTest.java b/servers/dsm/src/test/java/com/samsung/dsm/service/impl/AccessTokenServiceImplTest.java
deleted file mode 100644 (file)
index 48ff734..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.samsung.dsm.service.impl;
-
-import com.samsung.dsm.service.AccessTokenService;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-public class AccessTokenServiceImplTest {
-
-    @Autowired
-    private AccessTokenService accessTokenService;
-
-    @Test
-    public void findById() throws Exception {
-        assertThat(accessTokenService.findById(1L), is(nullValue()));
-    }
-
-}
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/service/impl/GrantedApplicationServiceImplTest.java b/servers/dsm/src/test/java/com/samsung/dsm/service/impl/GrantedApplicationServiceImplTest.java
deleted file mode 100644 (file)
index 3e0ab81..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.samsung.dsm.service.impl;
-
-import com.samsung.commons.domain.GrantedApplication;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-
-import java.util.List;
-
-import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
-import static org.junit.Assert.*;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration(locations = {"classpath:root-context.xml"})
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-public class GrantedApplicationServiceImplTest {
-
-    @Autowired
-    private GrantedApplicationServiceImpl service;
-
-    @Test
-    public void findByParentCommandAndCommand() {
-        GrantedApplication saved = service.save(new GrantedApplication("command", "parentCommand"));
-        List<GrantedApplication> grantedApplications = service.findByParentCommandAndCommand("parentCommand", "command");
-        assertThat(grantedApplications, hasSize(1));
-        service.delete(saved);
-    }
-
-    @Test
-    public void findByParentCommandAndCommandNegative() {
-        assertThat(service.findByParentCommandAndCommand("parentCommand", "command"), hasSize(0));
-    }
-
-}
\ No newline at end of file
index f8466c1..eaa2aa7 100644 (file)
@@ -7,7 +7,6 @@ import org.mockito.stubbing.OngoingStubbing;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
 import org.springframework.security.oauth2.provider.AuthorizationRequest;
 import org.springframework.security.oauth2.provider.ClientDetailsService;
 import org.springframework.security.oauth2.provider.OAuth2Authentication;
@@ -15,7 +14,6 @@ import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
 import org.springframework.security.oauth2.provider.code.AuthorizationCodeServices;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -77,16 +75,4 @@ public class OAuth2AuthorizationServiceTest {
         String code = service.generateAuthCode("clientId", "clientSecret", null);
         assertEquals(code, "code");
     }
-
-    @Test
-    public void generateAuthCodeThrowOnCreateAuthorizationCode() {
-        Authentication authentication = mock(Authentication.class);
-        AuthorizationRequest authorizationRequest = mock(AuthorizationRequest.class);
-
-        when(authenticationManager.authenticate(any())).thenReturn(authentication);
-        when(oauth2RequestFactory.createAuthorizationRequest(any())).thenReturn(authorizationRequest);
-        when(authCodeServices.createAuthorizationCode(any(OAuth2Authentication.class))).thenThrow(OAuth2Exception.class);
-
-        assertNull(service.generateAuthCode("clientId", "clientSecret", null));
-    }
 }
\ No newline at end of file
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/utils/CloudUserBuilder.java b/servers/dsm/src/test/java/com/samsung/dsm/utils/CloudUserBuilder.java
deleted file mode 100644 (file)
index e6eb9fe..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.samsung.dsm.utils;
-
-import com.samsung.commons.domain.IotCloudUser;
-import com.samsung.commons.domain.Role;
-import com.samsung.commons.domain.User;
-import com.samsung.commons.service.IotCloudService;
-import com.samsung.commons.service.RoleService;
-import com.samsung.commons.service.UserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class CloudUserBuilder {
-
-    @Autowired
-    private IotCloudService iotCloudService;
-
-    private String email = "email@samsung.com";
-    private String iotCloudUserUuid = "123456789";
-
-    public CloudUserBuilder withEmail(String email) {
-        this.email = email;
-
-        return this;
-    }
-
-    public CloudUserBuilder withCloudUserUuid(String iotCloudUserUuid) {
-        this.iotCloudUserUuid = iotCloudUserUuid;
-
-        return this;
-    }
-
-
-    /**
-     * Build Cloud User and return saved
-     *
-     * @return cloud user
-     */
-    public IotCloudUser build() {
-        return iotCloudService.createAndSaveUser(email, iotCloudUserUuid);
-    }
-}
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/utils/UserBuilder.java b/servers/dsm/src/test/java/com/samsung/dsm/utils/UserBuilder.java
deleted file mode 100644 (file)
index 929488a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.samsung.dsm.utils;
-
-import com.samsung.commons.domain.Role;
-import com.samsung.commons.domain.User;
-import com.samsung.commons.service.RoleService;
-import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.UserServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class UserBuilder {
-
-    @Autowired
-    private UserServiceImpl userService;
-
-    @Autowired
-    private RoleService roleService;
-
-    private String name = "username";
-    private String email = "username@samsung.com";
-    private String role;
-
-    public UserBuilder withNameEmailRole(String name, String email, String role) {
-        this.name = name;
-        this.email = email;
-        this.role = role;
-
-        return this;
-    }
-
-    /**
-     * Build User and return saved
-     *
-     * @return user
-     */
-    public User build() {
-
-        if (name == null) {
-            throw new IllegalStateException("No name");
-        }
-
-        if (email == null) {
-            throw new IllegalStateException("No email");
-        }
-
-        if (this.role == null) {
-            throw new IllegalStateException("No role");
-        }
-
-        Role role = roleService.getByName(this.role);
-
-        if (role == null) {
-            throw new IllegalStateException("Wrong role");
-        }
-
-        return userService.save(new User(name, email, role));
-    }
-}
diff --git a/servers/dsm/src/test/java/com/samsung/dsm/utils/UtilsTest.java b/servers/dsm/src/test/java/com/samsung/dsm/utils/UtilsTest.java
deleted file mode 100644 (file)
index 52b991e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.samsung.dsm.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-
-import javax.servlet.http.HttpServletRequest;
-
-import static com.samsung.dsm.utils.Utils.returnView;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-/**
- * Utils test
- * <p>
- * Created by o.abakumov on 6/30/2017.
- */
-public class UtilsTest {
-    @Mock
-    private HttpServletRequest request;
-
-    @Before
-    public void before() {
-        initMocks(this);
-    }
-
-    @Test
-    public void testAdminRedirect() throws Exception {
-        when(request.isUserInRole("ROLE_ADMIN")).thenReturn(true);
-        assertThat(returnView(request), equalTo("redirect:/admin"));
-    }
-
-    @Test
-    public void testUserRedirect() throws Exception {
-        when(request.isUserInRole("ROLE_USER")).thenReturn(true);
-        assertThat(returnView(request), equalTo("redirect:/user"));
-    }
-
-    @Test
-    public void testDefaultController() throws Exception {
-        when(request.isUserInRole(anyString())).thenReturn(false);
-        assertThat(returnView(request), equalTo("login"));
-    }
-}
\ No newline at end of file
index 8904700..57fbb20 100644 (file)
     <import resource="spring-database.xml"/>
     <import resource="spring-security.xml"/>
 
+    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
+        <property name="basename" value="i18n/messages"/>
+        <property name="useCodeAsDefaultMessage" value="true"/>
+    </bean>
+
     <context:component-scan base-package="com.samsung"/>
 
     <mvc:annotation-driven/>
     <mvc:default-servlet-handler/>
+    <mvc:resources mapping="/resources/**" location="/resources/"/>
 </beans>
\ No newline at end of file
index 0102972..12d03cb 100644 (file)
@@ -3,7 +3,7 @@
        xmlns:jpa="http://www.springframework.org/schema/data/jpa"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
-       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+       http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
 
@@ -15,7 +15,9 @@
 
     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
         <property name="driverClass" value="org.h2.Driver" />
-        <property name="jdbcUrl" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" />
+        <property name="jdbcUrl" value="jdbc:h2:~/test" />
+        <property name="user" value="sa" />
+        <property name="password" value="" />
 
         <!-- C3P0 properties -->
         <property name="acquireIncrement" value="1" />
index 3963875..a7934a3 100644 (file)
             <security:hsts/>
         </security:headers>
     </security:http>
-
     <bean id="mqSender" class="com.samsung.dsm.rest.mq.MQSenderImplMock">
         <constructor-arg name="host" value="http://localhost:8888"/>
     </bean>
index a283dfe..8372c2a 100644 (file)
@@ -11,8 +11,6 @@ import com.samsung.servermq.iotivity.extractor.PostDataExtractor;
 import com.samsung.servermq.utils.MessageQueueKeys;
 import com.samsung.servermq.utils.MessageQueueUtils;
 
-import static com.samsung.servermq.utils.MessageQueueKeys.*;
-
 public class DeviceRegistrationPostDataExtractor implements PostDataExtractor {
 
     private static final Logger log = Logger.getLogger(DeviceRegistrationPostDataExtractor.class);
@@ -26,12 +24,12 @@ public class DeviceRegistrationPostDataExtractor implements PostDataExtractor {
     @Override
     public void extract(byte[] data) {
         try {
-            String did = MessageQueueUtils.extractDataFromPayload(data, DUID.getKey());
-            String uid = MessageQueueUtils.extractDataFromPayload(data, UUID.getKey());
-            String name = MessageQueueUtils.extractDataFromPayload(data, DEVICE_NAME.getKey());
-            String type = MessageQueueUtils.extractDataFromPayload(data, DEVICE_TYPE.getKey());
-            String model = MessageQueueUtils.extractDataFromPayload(data, DEVICE_MODEL.getKey());
-            String route = MessageQueueUtils.extractDataFromPayload(data, ROUTE.getKey());
+            String did = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.DUID.getKey());
+            String uid = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.UUID.getKey());
+            String name = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.DEVICE_NAME.getKey());
+            String type = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.DEVICE_TYPE.getKey());
+            String model = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.DEVICE_MODEL.getKey());
+            String route = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.ROUTE.getKey());
             log.debug("New device with params : did = " + did + ", uid =  " + uid + ", device type = " + name + ", model = " + model + ", route = " + route);
             User user = iotCloudService.findAssociatedUserByUuid(uid);
             Device device = deviceService.init(did, name, type, model, 1, user, route);
index 74f0989..3b1d03f 100644 (file)
@@ -5,8 +5,6 @@ import com.samsung.commons.domain.Policy;
 import com.samsung.commons.service.DeviceService;
 import com.samsung.commons.service.PolicyService;
 
-import com.samsung.commons.service.impl.DeviceServiceImpl;
-import com.samsung.commons.service.impl.PolicyServiceImpl;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -14,33 +12,31 @@ import com.samsung.servermq.iotivity.extractor.PostDataExtractor;
 import com.samsung.servermq.utils.MessageQueueKeys;
 import com.samsung.servermq.utils.MessageQueueUtils;
 
-import static com.samsung.servermq.utils.MessageQueueKeys.*;
-
 public class DeviceUnRegistrationPostDataExtractor implements PostDataExtractor {
 
     private static final Logger log = Logger.getLogger(DeviceUnRegistrationPostDataExtractor.class);
 
     @Autowired
-    DeviceServiceImpl deviceService;
+    DeviceService deviceService;
 
     @Autowired
-    PolicyServiceImpl policyService;
+    PolicyService policyService;
 
     @Override
     public void extract(byte[] data) {
         try {
-            String did = MessageQueueUtils.extractDataFromPayload(data, DUID.getKey());
-            String action = MessageQueueUtils.extractDataFromPayload(data, ACTION.getKey());
+            String did = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.DUID.getKey());
+            String action = MessageQueueUtils.extractDataFromPayload(data, MessageQueueKeys.ACTION.getKey());
             Device device = deviceService.findByUUID(did);
-            log.debug("Unregister device [" + did + "] : " + device + " with action = " + action);
+            log.debug("Unregistere device ["+ did+"] : " + device + " with action = " + action);
             if (device != null) {
-                if (action.equalsIgnoreCase(UNREGISTER.getKey())) {
+                if(action.equalsIgnoreCase(MessageQueueKeys.UNREGISTER.getKey())){
                     Policy policy = policyService.findByDeviceId(device.getId());
-                    policyService.delete(policy);
+                    policyService.remove(policy);
                     deviceService.remove(device);
                     log.info("Unregistered device: " + device);
                 }
-                if (action.equalsIgnoreCase(DELETE.getKey())) {
+                if(action.equalsIgnoreCase(MessageQueueKeys.DELETE.getKey())){
                     device.setRemoved(true);
                     deviceService.save(device);
                     log.info("Device mark like removed: " + device);
index 77626e2..f8b3255 100644 (file)
@@ -37,7 +37,7 @@ public class ReportPostDataExtractor implements PostDataExtractor {
             Gson gson = new Gson();
             PrepareReport report = gson.fromJson(reportData, PrepareReport.class);
             Device device = deviceService.findByUUID(did);
-            Report savedReport = reportService.saveReport(device.getId(), report.getName(), report.getDate(), report.getResult(), reportData);
+            Report savedReport = reportService.setReport(device.getId(), report.getName(), report.getDate(), report.getResult(), reportData);
             log.info("Saved report: " + report);
 
             // Notify about new report
@@ -1,12 +1,24 @@
-package com.samsung.dsm.utils;
+/*
+ * In Samsung Ukraine R&D Center (SRK under a contract between)
+ * LLC "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
+ * Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
+ */
+package com.samsung.servermq.utils;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
 import org.springframework.validation.FieldError;
 import org.springframework.validation.ObjectError;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 /**
  * <h1>Utils</h1>
@@ -17,6 +29,9 @@ import java.util.Map;
  * @since 2016-09-01
  */
 public class Utils {
+    
+    private Utils(){
+    }
     /**
      * Parse validation object into the new format Map&#60;key,value&#62;.
      *
@@ -34,6 +49,15 @@ public class Utils {
         return map;
     }
 
+    public static String readAllFile(String path, Charset encoding) throws IOException {
+        Resource resource = new ClassPathResource(path);
+        InputStream resourceInputStream = resource.getInputStream();
+
+        try (Scanner s = new java.util.Scanner(resourceInputStream, encoding.name())) {
+            return s.useDelimiter("\\A").hasNext() ? s.next() : "";
+        }
+    }
+
     public static String returnView(HttpServletRequest request) {
         if (request.isUserInRole("ROLE_ADMIN")) {
             return "redirect:/admin";
index 98f9ede..a31ecc9 100644 (file)
@@ -4,22 +4,15 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.HashMap;
 
-import com.samsung.commons.domain.IotCloudUser;
-import com.samsung.commons.domain.User;
 import com.samsung.commons.service.DeviceService;
 import com.samsung.commons.service.IotCloudService;
-
-import com.samsung.commons.service.RoleService;
-import com.samsung.commons.service.impl.IotCloudServiceImpl;
-import com.samsung.commons.service.impl.UserServiceImpl;
-import org.junit.Before;
+       
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.ImportResource;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import com.samsung.servermq.utils.Cbor;
@@ -31,15 +24,13 @@ import com.samsung.servermq.utils.MessageQueueUtils;
 @SpringBootTest
 @ImportResource("classpath:root-context.xml")
 @EnableAutoConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DeviceRegistrationPostDataExtractorTest {
-
+    
     private static final String DUID = "testduid";
     private static final String UUID = "testuuid";
     private static final String NAME = "testDevice";
     private static final String TYPE = "tv";
     private static final String MODEL = "MySmartTV";
-    private static final String ROUTE = "route";
 
     @Autowired
     private DeviceService deviceService;
@@ -47,26 +38,9 @@ public class DeviceRegistrationPostDataExtractorTest {
     @Autowired
     private IotCloudService iotCloudService;
 
-    @Autowired
-    private UserServiceImpl userService;
-
-    @Autowired
-    private RoleService roleService;
-
-    private DeviceRegistrationPostDataExtractor extractor;
-
-    @Before
-    public void setUp() {
-        extractor = new DeviceRegistrationPostDataExtractor();
-        extractor.deviceService = deviceService;
-        extractor.iotCloudService = iotCloudService;
-    }
-
     @Test
     public void testExtractor() throws Exception {
-        User user = userService.save(new User("username", "some-email@samsung.com", roleService.getByName("ROLE_USER")));
-        iotCloudService.createAndSaveUser("some-email@samsung.com", UUID);
-
+        iotCloudService.createAndSaveUser("admin@samsung.com", UUID);
         Cbor<HashMap<String, String>> cbor = new Cbor<>();
         HashMap<String, String> map = new HashMap<>();
         map.put(MessageQueueKeys.DUID.getKey(), DUID);
@@ -74,18 +48,16 @@ public class DeviceRegistrationPostDataExtractorTest {
         map.put(MessageQueueKeys.DEVICE_NAME.getKey(), NAME);
         map.put(MessageQueueKeys.DEVICE_TYPE.getKey(), TYPE);
         map.put(MessageQueueKeys.DEVICE_MODEL.getKey(), MODEL);
-        map.put(MessageQueueKeys.ROUTE.getKey(), ROUTE);
-
         byte[] data = cbor.encodingPayloadToCbor(map);
-
+        DeviceRegistrationPostDataExtractor extractor = new DeviceRegistrationPostDataExtractor();
+        extractor.deviceService = deviceService;
+        extractor.iotCloudService = iotCloudService;
         extractor.extract(data);
-
         assertNotNull(deviceService.findByUUID(DUID));
         deviceService.remove(deviceService.findByUUID(DUID));
-        userService.delete(user.getId());
     }
 
-    public void testFailedExtractor() throws Exception {
+    public void testFaildExtractor() throws Exception {
         byte[] data = MessageQueueUtils.buildPayload(MessageQueueKeys.DUID.getKey(), UUID);
         DeviceRegistrationPostDataExtractor extractor = new DeviceRegistrationPostDataExtractor();
         extractor.extract(data);
index 97cfb5f..e294f3f 100644 (file)
@@ -1,13 +1,12 @@
 package com.samsung.servermq.iotivity.extractor.impl;
 
-import com.samsung.commons.domain.Device;
-import com.samsung.commons.domain.Policy;
-import com.samsung.commons.domain.User;
-import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.DeviceServiceImpl;
-import com.samsung.commons.service.impl.PolicyServiceImpl;
-import com.samsung.servermq.utils.MessageQueueKeys;
-import com.samsung.servermq.utils.MessageQueueUtils;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+
 import org.iotivity.cloud.util.Cbor;
 import org.junit.Before;
 import org.junit.Test;
@@ -17,19 +16,21 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.ImportResource;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.util.HashMap;
-import java.util.List;
-
-import static org.junit.Assert.*;
+import com.samsung.commons.domain.Device;
+import com.samsung.commons.domain.Policy;
+import com.samsung.commons.domain.User;
+import com.samsung.commons.service.DeviceService;
+import com.samsung.commons.service.PolicyService;
+import com.samsung.commons.service.UserService;
+import com.samsung.servermq.utils.MessageQueueKeys;
+import com.samsung.servermq.utils.MessageQueueUtils;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
 @ImportResource("classpath:root-context.xml")
 @EnableAutoConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class DeviceUnRegistrationPostDataExtractorTest {
 
     private static final String DUID = "testuuid";
@@ -39,13 +40,13 @@ public class DeviceUnRegistrationPostDataExtractorTest {
     private static final Integer STATUS = 1;
 
     @Autowired
-    private DeviceServiceImpl deviceService;
+    private DeviceService deviceService;
 
     @Autowired
     private UserService userService;
 
     @Autowired
-    private PolicyServiceImpl policyService;
+    private PolicyService policyService;
 
     @Before
     public void setUp() {
@@ -53,7 +54,7 @@ public class DeviceUnRegistrationPostDataExtractorTest {
         for (Device device : list) {
             Policy policy = policyService.findByDeviceId(device.getId());
             if (policy != null) {
-                policyService.delete(policy);
+                policyService.remove(policy);
             }
             deviceService.remove(device);
         }
@@ -64,7 +65,7 @@ public class DeviceUnRegistrationPostDataExtractorTest {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
         policy = policyService.save(policy);
-        User user = userService.findUserByEmail("admin@samsung.com");
+        User user = userService.getUserByEmail("admin@samsung.com");
         Device device = new Device(DUID, NAME, TYPE, MODEL, STATUS, policy, user);
         deviceService.save(device);
         Cbor<HashMap<String, String>> cbor = new Cbor<>();
@@ -86,7 +87,7 @@ public class DeviceUnRegistrationPostDataExtractorTest {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
         policy = policyService.save(policy);
-        User user = userService.findUserByEmail("admin@samsung.com");
+        User user = userService.getUserByEmail("admin@samsung.com");
         Device device = new Device(DUID, NAME, TYPE, MODEL, STATUS, policy, user);
         deviceService.save(device);
         Cbor<HashMap<String, String>> cbor = new Cbor<>();
@@ -104,8 +105,8 @@ public class DeviceUnRegistrationPostDataExtractorTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testFailedExtractor() throws Exception {
-        DeviceServiceImpl mockDeviceService = Mockito.mock(DeviceServiceImpl.class);
+    public void testFaildExtractor() throws Exception {
+        DeviceService mockDeviceService = Mockito.mock(DeviceService.class);
         Mockito.when(mockDeviceService.findByUUID(DUID)).thenThrow(Exception.class);
         byte[] data = MessageQueueUtils.buildPayload(MessageQueueKeys.DUID.getKey(), DUID);
         DeviceUnRegistrationPostDataExtractor extractor = new DeviceUnRegistrationPostDataExtractor();
index b35ccf4..dc424e8 100644 (file)
@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.ImportResource;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import com.samsung.commons.domain.Device;
@@ -26,7 +25,6 @@ import com.samsung.servermq.utils.MessageQueueKeys;
 @SpringBootTest
 @ImportResource("classpath:root-context.xml")
 @EnableAutoConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class PolicyPostDataExtractorTest {
 
     private static final String DUID = "testuuid";
@@ -55,7 +53,7 @@ public class PolicyPostDataExtractorTest {
     public void testExtractor() {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
-        User user = userService.findUserByEmail("admin@samsung.com");
+        User user = userService.getUserByEmail("admin@samsung.com");
         Device device = new Device(DUID, NAME, TYPE, MODEL, STATUS, policy, user);
         deviceService.save(device);
         assertNotNull(deviceService.findByUUID(DUID));
index 54f4461..51bd8f6 100644 (file)
@@ -1,36 +1,35 @@
 package com.samsung.servermq.iotivity.extractor.impl;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ImportResource;
+import org.springframework.test.context.junit4.SpringRunner;
+
 import com.samsung.commons.domain.Device;
 import com.samsung.commons.domain.Policy;
 import com.samsung.commons.domain.Report;
 import com.samsung.commons.domain.User;
+import com.samsung.commons.service.DeviceService;
+import com.samsung.commons.service.PolicyService;
 import com.samsung.commons.service.ReportService;
 import com.samsung.commons.service.UserService;
-import com.samsung.commons.service.impl.DeviceServiceImpl;
-import com.samsung.commons.service.impl.PolicyServiceImpl;
 import com.samsung.servermq.utils.Cbor;
 import com.samsung.servermq.utils.MessageQueueKeys;
 import com.samsung.servermq.utils.rest.ServerSender;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.ImportResource;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.util.HashMap;
-import java.util.List;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
 @ImportResource("classpath:root-context.xml")
 @EnableAutoConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class ReportPostDataExtractorTest {
 
     private static final String DUID = "testuuid";
@@ -46,10 +45,10 @@ public class ReportPostDataExtractorTest {
     private ReportService reportService;
 
     @Autowired
-    private DeviceServiceImpl deviceService;
+    private DeviceService deviceService;
 
     @Autowired
-    private PolicyServiceImpl policyService;
+    private PolicyService policyService;
 
     @Autowired
     private UserService userService;
@@ -61,7 +60,7 @@ public class ReportPostDataExtractorTest {
     public void testExtractor() throws Exception {
         String route = "route";
         Policy policy = policyService.initPolicy(route);
-        User user = userService.findUserByEmail("admin@samsung.com");
+        User user = userService.getUserByEmail("admin@samsung.com");
         Device device = deviceService.save(new Device(DUID, NAME, TYPE, MODEL, STATUS, policy, user));
         assertNotNull(deviceService.findByUUID(DUID));
         Cbor<HashMap<String, String>> cbor = new Cbor<>();
@@ -76,7 +75,7 @@ public class ReportPostDataExtractorTest {
         List<Report> list = reportService.findReportsByDeviceId(device.getId());
         assertTrue(list.size() == 1);
         reportService.removeAll();
-        policyService.delete(policy);
+        policyService.remove(policy);
         deviceService.remove(device);
     }
 
index 47894ff..9d90f71 100644 (file)
@@ -12,7 +12,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
-import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.test.context.web.WebAppConfiguration;
@@ -24,8 +23,6 @@ import org.springframework.web.context.WebApplicationContext;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:root-context.xml"})
 @WebAppConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
-
 @Ignore
 public class DSMRestControllerTest {
 
index d4b2a16..918d2e2 100644 (file)
@@ -16,7 +16,9 @@
 
     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
         <property name="driverClass" value="org.h2.Driver" />
-        <property name="jdbcUrl" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" />
+        <property name="jdbcUrl" value="jdbc:h2:~/test" />
+        <property name="user" value="sa" />
+        <property name="password" value="" />
 
         <!-- C3P0 properties -->
         <property name="acquireIncrement" value="1" />