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

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.
......
/*
* 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.
......@@ -771,6 +771,16 @@ public class AuditTrailInterceptor extends EmptyInterceptor implements Initializ
}
}
/**
* Try method.
*
* @param entity the entity
* @param methodName the method name
* @return the boolean
* @throws NoSuchMethodException the no such method exception
* @throws IllegalAccessException the illegal access exception
* @throws InvocationTargetException the invocation target exception
*/
public Boolean tryMethod(final Object entity, final String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Method getter = entity.getClass().getMethod(methodName);
if (getter != null) {
......
/*
* 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.
......@@ -64,8 +64,8 @@ public interface AuditLogCustomRepository {
Page<AuditLog> listAuditLogs(AuditLogFilter filters, Pageable page);
/**
* Load entity from database by classname and id
*
* Load entity from database by classname and id.
*
* @param classPk classPK of the entity
* @param id the internal database id of the entity
* @return the persisted entity of type classPk
......
/*
* 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.
......@@ -26,7 +26,12 @@ import java.util.stream.Stream;
import org.genesys.blocks.auditlog.annotations.Audited;
import org.junit.Test;
/**
* The Class AuditTrailInterceptorTest.
*/
public class AuditTrailInterceptorTest {
/** The audit trail interceptor. */
AuditTrailInterceptor auditTrailInterceptor = new AuditTrailInterceptor();
private abstract class AbstractSuperClass {
......@@ -61,6 +66,9 @@ public class AuditTrailInterceptorTest {
auditTrailInterceptor.setAuditedClasses(Stream.of(AbstractSuperClass.class, SuperInterface.class, StandaloneClass.class).collect(Collectors.toSet()));
}
/**
* Test primitive types.
*/
@Test
public void testPrimitiveTypes() {
assertThat(auditTrailInterceptor.isPrimitiveType(Long.class), is(true));
......@@ -80,6 +88,9 @@ public class AuditTrailInterceptorTest {
assertThat(auditTrailInterceptor.isPrimitiveType(UUID.class), is(true));
}
/**
* Test audited.
*/
@Test
public void testAudited() {
for (int i = 0; i < 10; i++) {
......
/*
* 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.
......@@ -31,6 +31,9 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class AuditLogEntityTest.
*/
public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository> {
@Autowired
......@@ -44,11 +47,17 @@ public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository>
assertThat(repository.count(), is(0l));
}
/**
* Fail persist.
*/
@Test(expected = DataIntegrityViolationException.class)
public void failPersist() {
repository.save(new AuditLog());
}
/**
* Successful persist.
*/
@Test
public void successfulPersist() {
final AuditLog log = 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.
......@@ -24,6 +24,9 @@ import org.genesys.blocks.persistence.ClassPKRepository;
import org.junit.Test;
import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class ClassPKEntityTest.
*/
public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> {
@Override
......@@ -33,17 +36,26 @@ public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> {
repository.deleteAll();
}
/**
* Fail persist.
*/
@Test(expected = DataIntegrityViolationException.class)
public void failPersist() {
repository.save(new ClassPK());
}
/**
* Fail duplicate.
*/
@Test(expected = DataIntegrityViolationException.class)
public void failDuplicate() {
repository.save(makeClassPK(Long.class));
repository.save(makeClassPK(Long.class));
}
/**
* Successful persist.
*/
@Test
public void successfulPersist() {
final ClassPK cpk = repository.save(makeClassPK(Long.class));
......
/*
* 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.
......@@ -31,6 +31,9 @@ import javax.persistence.Table;
import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.BasicModel;
/**
* The Class ExampleAuditedEntity.
*/
@Entity
@Table(name = "exampleauditedentity")
@Audited
......@@ -54,34 +57,74 @@ public class ExampleAuditedEntity extends BasicModel {
@CollectionTable(name = "entity_set", joinColumns = @JoinColumn(name = "entityId", referencedColumnName = "id"))
private Set<String> set;
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the reference.
*
* @param refEntity the new reference
*/
public void setReference(ExampleAuditedEntity refEntity) {
this.reference = refEntity;
}
/**
* Gets the reference.
*
* @return the reference
*/
public ExampleAuditedEntity getReference() {
return reference;
}
/**
* Gets the list.
*
* @return the list
*/
public List<Long> getList() {
return list;
}
/**
* Sets the list.
*
* @param list the new list
*/
public void setList(List<Long> list) {
this.list = list;
}
/**
* Gets the sets the.
*
* @return the sets the
*/
public Set<String> getSet() {
return set;
}
/**
* Sets the sets the.
*
* @param set the new sets the
*/
public void setSet(Set<String> set) {
this.set = set;
}
......
/*
* 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.
......@@ -37,6 +37,9 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class AuditTrailServiceTest.
*/
public class AuditTrailServiceTest extends ServiceTest {
@Autowired
......@@ -57,6 +60,9 @@ public class AuditTrailServiceTest extends ServiceTest {
auditLogRepository.deleteAll();
}
/**
* Save 1.
*/
@Test
public void save1() {
final Long entity = new Long(42);
......@@ -71,6 +77,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(log.getReferencedEntity(), nullValue());
}
/**
* Save ref ent.
*/
@Test
public void saveRefEnt() {
final Long entity = new Long(42);
......@@ -86,6 +95,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(log.getReferencedEntity(), equalTo(classPkService.getClassPk(AuditLog.class)));
}
/**
* Test example audited entity.
*/
@Test
public void testExampleAuditedEntity() {
ExampleAuditedEntity entity = new ExampleAuditedEntity();
......@@ -100,6 +112,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(listAuditLogs(entity), hasSize(1));
}
/**
* Test transactional list query.
*/
@Test
public void testTransactionalListQuery() {
ExampleAuditedEntity entity = exampleAuditedEntityService.testList();
......@@ -115,6 +130,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(lastLog.getNewState(), is(entity.getName()));
}
/**
* Test delete.
*/
@Test
public void testDelete() {
ExampleAuditedEntity entity = exampleAuditedEntityService.testList();
......@@ -131,6 +149,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(lastLog.getPreviousState(), is(entity.getName()));
}
/**
* Test rollback.
*/
@Test
public void testRollback() {
ExampleAuditedEntity entity = new ExampleAuditedEntity();
......@@ -153,6 +174,9 @@ public class AuditTrailServiceTest extends ServiceTest {
}
}
/**
* Test load referenced entity.
*/
@Test
public void testLoadReferencedEntity() {
ExampleAuditedEntity entity = new ExampleAuditedEntity();
......@@ -169,6 +193,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(((ExampleAuditedEntity) lookup).getId(), is(entity.getId()));
}
/**
* Test referenced entity audit log.
*/
@Test
public void testReferencedEntityAuditLog() {
ExampleAuditedEntity refEntity = new ExampleAuditedEntity();
......@@ -191,6 +218,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(((ExampleAuditedEntity) listAuditLogs(entity).get(0).getNewEntity()).getId(), is(refEntity.getId()));
}
/**
* Test embedded collections.
*/
@Test
public void testEmbeddedCollections() {
ExampleAuditedEntity entity = new ExampleAuditedEntity();
......
/*
* 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();
......