Commit 6f8adc31 authored by Matija Obreza's avatar Matija Obreza
Browse files

Update javadoc

- JAutodoc headers and members
parent cabd3831
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -24,6 +24,9 @@ import org.genesys.blocks.auditlog.test.ServiceTest;
import org.genesys.blocks.model.ClassPK;
import org.junit.Test;
/**
* The Class ClassPKServiceTest.
*/
public class ClassPKServiceTest extends ServiceTest {
@Override
......@@ -33,6 +36,9 @@ public class ClassPKServiceTest extends ServiceTest {
classPkRepository.deleteAll();
}
/**
* Auto create.
*/
@Test
public void autoCreate() {
final ClassPK cpk = classPkService.getClassPk(Long.class);
......@@ -40,6 +46,11 @@ public class ClassPKServiceTest extends ServiceTest {
assertThat(cpk.getClassname(), equalTo(Long.class.getName()));
}
/**
* Gets the existing.
*
* @return the existing
*/
@Test
public void getExisting() {
final ClassPK cpk = classPkService.getClassPk(Long.class);
......@@ -51,6 +62,9 @@ public class ClassPKServiceTest extends ServiceTest {
assertThat(cpk.getId(), equalTo(cpk2.getId()));
}
/**
* Test get class pk id.
*/
@Test
public void testGetClassPkId() {
final ClassPK cpk = classPkService.getClassPk(Long.class);
......@@ -61,6 +75,9 @@ public class ClassPKServiceTest extends ServiceTest {
assertThat(id, equalTo(cpk.getId()));
}
/**
* Test create class pk id.
*/
@Test
public void testCreateClassPkId() {
final Long id = classPkService.getClassPkId(Long.class.getName());
......@@ -73,7 +90,7 @@ public class ClassPKServiceTest extends ServiceTest {
}
/**
* Test that classPk is not created for classnames that don't exist
* Test that classPk is not created for classnames that don't exist.
*/
@Test
public void testNoCreateClassPkForCNFE() {
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -18,11 +18,39 @@ package org.genesys.blocks.auditlog.service;
import org.genesys.blocks.auditlog.model.ExampleAuditedEntity;
/**
* The Interface ExampleAuditedEntityService.
*/
public interface ExampleAuditedEntityService {
/**
* Gets the.
*
* @param id the id
* @return the example audited entity
*/
ExampleAuditedEntity get(Long id);
/**
* Save.
*
* @param entity the entity
* @return the example audited entity
*/
ExampleAuditedEntity save(ExampleAuditedEntity entity);
/**
* Delete.
*
* @param entity the entity
* @return the example audited entity
*/
ExampleAuditedEntity delete(ExampleAuditedEntity entity);
/**
* Test list.
*
* @return the example audited entity
*/
ExampleAuditedEntity testList();
}
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,6 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class ExampleAuditedEntityServiceImpl.
*/
@Service
@Transactional(readOnly = true)
public class ExampleAuditedEntityServiceImpl implements ExampleAuditedEntityService {
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -34,6 +34,9 @@ import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* The Class ApplicationConfig.
*/
@Configuration
@EnableScheduling
@EnableAspectJAutoProxy
......@@ -43,6 +46,11 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@ComponentScan(basePackages = { "org.genesys.blocks.auditlog.service" })
public class ApplicationConfig {
/**
* Property placeholder configurer.
*
* @return the property placeholder configurer
*/
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
......@@ -58,6 +66,11 @@ public class ApplicationConfig {
return propertyPlaceholderConfigurer;
}
/**
* Cache manager.
*
* @return the cache manager
*/
@Bean
public CacheManager cacheManager() {
final SimpleCacheManager cacheManager = new SimpleCacheManager();
......@@ -65,11 +78,21 @@ public class ApplicationConfig {
return cacheManager;
}
/**
* Acl service.
*
* @return the custom acl service
*/
@Bean
public CustomAclService aclService() {
return new CustomAclServiceImpl();
}
/**
* Acl assigner aspect.
*
* @return the acl assigner aspect
*/
@Bean
public AclAssignerAspect aclAssignerAspect() {
return new AclAssignerAspect();
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -37,26 +37,39 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class BaseTest.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@EnableAspectJAutoProxy
@ContextConfiguration(name = "root", classes = { ApplicationConfig.class })
public abstract class BaseTest {
/** The log. */
protected final Logger LOG = LoggerFactory.getLogger(getClass());
/** The Constant CURENT_YEAR. */
protected static final int CURENT_YEAR = Calendar.getInstance().get(Calendar.YEAR);
/** The audit log repository. */
@Autowired
protected AuditLogRepository auditLogRepository;
/** The audit trail service. */
@Autowired
protected AuditTrailService auditTrailService;
/** The class pk repository. */
@Autowired
protected ClassPKRepository classPkRepository;
/** The class pk service. */
@Autowired
protected ClassPKService classPkService;
/**
* Cleanup.
*/
@AfterTransaction
@Transactional
public void cleanup() {
......@@ -67,22 +80,51 @@ public abstract class BaseTest {
classPkRepository.deleteAllInBatch();
}
/**
* Last audit log.
*
* @param entity the entity
* @return the audit log
*/
protected AuditLog lastAuditLog(final EntityId entity) {
return auditLogRepository.getLastAuditLog(entity);
}
/**
* Last audit log.
*
* @param entity the entity
* @param propertyName the property name
* @return the audit log
*/
protected AuditLog lastAuditLog(final EntityId entity, final String propertyName) {
return auditLogRepository.getLastAuditLog(entity, propertyName);
}
/**
* List audit logs.
*
* @param entity the entity
* @return the list
*/
protected List<AuditLog> listAuditLogs(final EntityId entity) {
return auditTrailService.listAuditLogs(entity);
}
/**
* Prints the audit logs.
*
* @param entity the entity
*/
protected void printAuditLogs(final EntityId entity) {
printAuditLogs(listAuditLogs(entity));
}
/**
* Prints the audit logs.
*
* @param auditLogs the audit logs
*/
protected void printAuditLogs(final List<AuditLog> auditLogs) {
for (final AuditLog auditLog : auditLogs) {
LOG.debug(auditLog.getId() + " " + auditLog.getAction() + " " + auditLog.getLogDate() + " " + auditLog.getClassPk().getClassname() + "<" + auditLog.getEntityId() + ">."
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -44,6 +44,9 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* The Class DatabaseConfig.
*/
@Configuration
@EnableJpaRepositories(basePackages = { "org.genesys.blocks.persistence", "org.genesys.blocks.security.persistence",
"org.genesys.blocks.auditlog.persistence" }, repositoryImplementationPostfix = "CustomImpl", entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager")
......@@ -79,6 +82,12 @@ public class DatabaseConfig {
@Value("${db.pool.initialSize}")
private int dbPoolInitialSize;
/**
* Data source.
*
* @return the data source
* @throws Exception the exception
*/
@Bean(name = "dataSource")
public DataSource dataSource() throws Exception {
final DataSource dataSource = new DataSource();
......@@ -96,11 +105,23 @@ public class DatabaseConfig {
return dataSource;
}
/**
* Jdbc template.
*
* @param dataSource the data source
* @return the jdbc template
*/
@Bean
public JdbcTemplate jdbcTemplate(final DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
/**
* Entity manager factory.
*
* @return the local container entity manager factory bean
* @throws Exception the exception
*/
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception {
final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
......@@ -195,12 +216,24 @@ public class DatabaseConfig {
return bean;
}
/**
* Audit trail interceptor.
*
* @return the interceptor
*/
@Bean
public Interceptor auditTrailInterceptor() {
// Has to stay here so the code in JPA Hibernate setup above can pick it up!
return new AuditTrailInterceptor();
}
/**
* Jpa transaction manager.
*
* @param entityManagerFactory the entity manager factory
* @return the platform transaction manager
* @throws Exception the exception
*/
@Bean(name = "transactionManager")
public PlatformTransactionManager jpaTransactionManager(final EntityManagerFactory entityManagerFactory) throws Exception {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
......@@ -209,6 +242,11 @@ public class DatabaseConfig {
return transactionManager;
}
/**
* Hibernate exception translator.
*
* @return the persistence exception translator
*/
@Bean
public PersistenceExceptionTranslator hibernateExceptionTranslator() {
return new HibernateExceptionTranslator();
......@@ -221,6 +259,11 @@ public class DatabaseConfig {
return jpaProp;
}
/**
* Auditor aware.
*
* @return the spring security auditor aware
*/
@Bean
public SpringSecurityAuditorAware auditorAware() {
return new SpringSecurityAuditorAware();
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,12 +23,22 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class EntityTest.
*
* @param <T> the generic type
* @param <R> the generic type
*/
@Transactional
public abstract class EntityTest<T, R extends JpaRepository<T, Long>> extends BaseTest {
/** The repository. */
@Autowired
protected R repository;
/**
* Before test.
*/
@Before
public void beforeTest() {
cleanup();
......@@ -41,5 +51,10 @@ public abstract class EntityTest<T, R extends JpaRepository<T, Long>> extends Ba
super.cleanup();
}
/**
* Make default.
*
* @return the t
*/
protected abstract T makeDefault();
}
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -19,8 +19,14 @@ import org.junit.After;
import org.junit.Before;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class ServiceTest.
*/
public abstract class ServiceTest extends BaseTest {
/**
* Before test.
*/
@Before
@Transactional
public void beforeTest() {
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -65,8 +65,8 @@ public class JsonViews {
}
/**
* Marks fields that may not be serialized by default (in lieu of {@link JsonIgnore})
* TBD: check {@link Root}
* Marks fields that may not be serialized by default (in lieu of
* {@link JsonIgnore}) TBD: check {@link Root}.
*/
public static interface Indexed extends Internal {
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment