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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 ...@@ -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 { public Boolean tryMethod(final Object entity, final String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Method getter = entity.getClass().getMethod(methodName); final Method getter = entity.getClass().getMethod(methodName);
if (getter != null) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -64,8 +64,8 @@ public interface AuditLogCustomRepository { ...@@ -64,8 +64,8 @@ public interface AuditLogCustomRepository {
Page<AuditLog> listAuditLogs(AuditLogFilter filters, Pageable page); 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 classPk classPK of the entity
* @param id the internal database id of the entity * @param id the internal database id of the entity
* @return the persisted entity of type classPk * @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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,7 +26,12 @@ import java.util.stream.Stream; ...@@ -26,7 +26,12 @@ import java.util.stream.Stream;
import org.genesys.blocks.auditlog.annotations.Audited; import org.genesys.blocks.auditlog.annotations.Audited;
import org.junit.Test; import org.junit.Test;
/**
* The Class AuditTrailInterceptorTest.
*/
public class AuditTrailInterceptorTest { public class AuditTrailInterceptorTest {
/** The audit trail interceptor. */
AuditTrailInterceptor auditTrailInterceptor = new AuditTrailInterceptor(); AuditTrailInterceptor auditTrailInterceptor = new AuditTrailInterceptor();
private abstract class AbstractSuperClass { private abstract class AbstractSuperClass {
...@@ -61,6 +66,9 @@ public class AuditTrailInterceptorTest { ...@@ -61,6 +66,9 @@ public class AuditTrailInterceptorTest {
auditTrailInterceptor.setAuditedClasses(Stream.of(AbstractSuperClass.class, SuperInterface.class, StandaloneClass.class).collect(Collectors.toSet())); auditTrailInterceptor.setAuditedClasses(Stream.of(AbstractSuperClass.class, SuperInterface.class, StandaloneClass.class).collect(Collectors.toSet()));
} }
/**
* Test primitive types.
*/
@Test @Test
public void testPrimitiveTypes() { public void testPrimitiveTypes() {
assertThat(auditTrailInterceptor.isPrimitiveType(Long.class), is(true)); assertThat(auditTrailInterceptor.isPrimitiveType(Long.class), is(true));
...@@ -80,6 +88,9 @@ public class AuditTrailInterceptorTest { ...@@ -80,6 +88,9 @@ public class AuditTrailInterceptorTest {
assertThat(auditTrailInterceptor.isPrimitiveType(UUID.class), is(true)); assertThat(auditTrailInterceptor.isPrimitiveType(UUID.class), is(true));
} }
/**
* Test audited.
*/
@Test @Test
public void testAudited() { public void testAudited() {
for (int i = 0; i < 10; i++) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,6 +31,9 @@ import org.junit.Test; ...@@ -31,6 +31,9 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class AuditLogEntityTest.
*/
public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository> { public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository> {
@Autowired @Autowired
...@@ -44,11 +47,17 @@ public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository> ...@@ -44,11 +47,17 @@ public class AuditLogEntityTest extends EntityTest<AuditLog, AuditLogRepository>
assertThat(repository.count(), is(0l)); assertThat(repository.count(), is(0l));
} }
/**
* Fail persist.
*/
@Test(expected = DataIntegrityViolationException.class) @Test(expected = DataIntegrityViolationException.class)
public void failPersist() { public void failPersist() {
repository.save(new AuditLog()); repository.save(new AuditLog());
} }
/**
* Successful persist.
*/
@Test @Test
public void successfulPersist() { public void successfulPersist() {
final AuditLog log = makeDefault(); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,6 +24,9 @@ import org.genesys.blocks.persistence.ClassPKRepository; ...@@ -24,6 +24,9 @@ import org.genesys.blocks.persistence.ClassPKRepository;
import org.junit.Test; import org.junit.Test;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class ClassPKEntityTest.
*/
public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> { public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> {
@Override @Override
...@@ -33,17 +36,26 @@ public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> { ...@@ -33,17 +36,26 @@ public class ClassPKEntityTest extends EntityTest<ClassPK, ClassPKRepository> {
repository.deleteAll(); repository.deleteAll();
} }
/**
* Fail persist.
*/
@Test(expected = DataIntegrityViolationException.class) @Test(expected = DataIntegrityViolationException.class)
public void failPersist() { public void failPersist() {
repository.save(new ClassPK()); repository.save(new ClassPK());
} }
/**
* Fail duplicate.
*/
@Test(expected = DataIntegrityViolationException.class) @Test(expected = DataIntegrityViolationException.class)
public void failDuplicate() { public void failDuplicate() {
repository.save(makeClassPK(Long.class)); repository.save(makeClassPK(Long.class));
repository.save(makeClassPK(Long.class)); repository.save(makeClassPK(Long.class));
} }
/**
* Successful persist.
*/
@Test @Test
public void successfulPersist() { public void successfulPersist() {
final ClassPK cpk = repository.save(makeClassPK(Long.class)); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,6 +31,9 @@ import javax.persistence.Table; ...@@ -31,6 +31,9 @@ import javax.persistence.Table;
import org.genesys.blocks.auditlog.annotations.Audited; import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.BasicModel; import org.genesys.blocks.model.BasicModel;
/**
* The Class ExampleAuditedEntity.
*/
@Entity @Entity
@Table(name = "exampleauditedentity") @Table(name = "exampleauditedentity")
@Audited @Audited
...@@ -54,34 +57,74 @@ public class ExampleAuditedEntity extends BasicModel { ...@@ -54,34 +57,74 @@ public class ExampleAuditedEntity extends BasicModel {
@CollectionTable(name = "entity_set", joinColumns = @JoinColumn(name = "entityId", referencedColumnName = "id")) @CollectionTable(name = "entity_set", joinColumns = @JoinColumn(name = "entityId", referencedColumnName = "id"))
private Set<String> set; private Set<String> set;
/**
* Gets the name.
*
* @return the name
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* Sets the reference.
*
* @param refEntity the new reference
*/
public void setReference(ExampleAuditedEntity refEntity) { public void setReference(ExampleAuditedEntity refEntity) {
this.reference = refEntity; this.reference = refEntity;
} }
/**
* Gets the reference.
*
* @return the reference
*/
public ExampleAuditedEntity getReference() { public ExampleAuditedEntity getReference() {
return reference; return reference;
} }
/**
* Gets the list.
*
* @return the list
*/
public List<Long> getList() { public List<Long> getList() {
return list; return list;
} }
/**
* Sets the list.
*
* @param list the new list
*/
public void setList(List<Long> list) { public void setList(List<Long> list) {
this.list = list; this.list = list;
} }
/**
* Gets the sets the.
*
* @return the sets the
*/
public Set<String> getSet() { public Set<String> getSet() {
return set; return set;
} }
/**
* Sets the sets the.
*
* @param set the new sets the
*/
public void setSet(Set<String> set) { public void setSet(Set<String> set) {
this.set = 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -37,6 +37,9 @@ import org.junit.Test; ...@@ -37,6 +37,9 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
/**
* The Class AuditTrailServiceTest.
*/
public class AuditTrailServiceTest extends ServiceTest { public class AuditTrailServiceTest extends ServiceTest {
@Autowired @Autowired
...@@ -57,6 +60,9 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -57,6 +60,9 @@ public class AuditTrailServiceTest extends ServiceTest {
auditLogRepository.deleteAll(); auditLogRepository.deleteAll();
} }
/**
* Save 1.
*/
@Test @Test
public void save1() { public void save1() {
final Long entity = new Long(42); final Long entity = new Long(42);
...@@ -71,6 +77,9 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -71,6 +77,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(log.getReferencedEntity(), nullValue()); assertThat(log.getReferencedEntity(), nullValue());
} }
/**
* Save ref ent.
*/
@Test @Test
public void saveRefEnt() { public void saveRefEnt() {
final Long entity = new Long(42); final Long entity = new Long(42);
...@@ -86,6 +95,9 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -86,6 +95,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(log.getReferencedEntity(), equalTo(classPkService.getClassPk(AuditLog.class))); assertThat(log.getReferencedEntity(), equalTo(classPkService.getClassPk(AuditLog.class)));
} }
/**
* Test example audited entity.
*/
@Test @Test
public void testExampleAuditedEntity() { public void testExampleAuditedEntity() {
ExampleAuditedEntity entity = new ExampleAuditedEntity(); ExampleAuditedEntity entity = new ExampleAuditedEntity();
...@@ -100,6 +112,9 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -100,6 +112,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(listAuditLogs(entity), hasSize(1)); assertThat(listAuditLogs(entity), hasSize(1));
} }
/**
* Test transactional list query.
*/
@Test @Test
public void testTransactionalListQuery() { public void testTransactionalListQuery() {
ExampleAuditedEntity entity = exampleAuditedEntityService.testList(); ExampleAuditedEntity entity = exampleAuditedEntityService.testList();
...@@ -115,6 +130,9 @@ public class AuditTrailServiceTest extends ServiceTest { ...@@ -115,6 +130,9 @@ public class AuditTrailServiceTest extends ServiceTest {
assertThat(lastLog.getNewState(), is(entity.getName())); assertThat(lastLog.getNewState(), is(entity.getName()));
} }