Commit ffa655be authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'release-1.4' into 'master'

Release 1.4

See merge request genesys-pgr/application-blocks!34
parents cabd3831 149f457d
/* /*
* 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.
...@@ -18,6 +18,9 @@ package org.genesys.blocks.model; ...@@ -18,6 +18,9 @@ package org.genesys.blocks.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
/**
* The Class UuidEntity.
*/
@Entity @Entity
public class UuidEntity extends UuidModel { public class UuidEntity extends UuidModel {
...@@ -26,10 +29,20 @@ public class UuidEntity extends UuidModel { ...@@ -26,10 +29,20 @@ public class UuidEntity extends UuidModel {
@Column(nullable = false) @Column(nullable = false)
private String name; private String name;
/**
* 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;
} }
......
/* /*
* 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.
...@@ -18,6 +18,9 @@ package org.genesys.blocks.model; ...@@ -18,6 +18,9 @@ package org.genesys.blocks.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
/**
* The Class VersionedEntity.
*/
@Entity @Entity
public class VersionedEntity extends VersionedModel { public class VersionedEntity extends VersionedModel {
...@@ -26,10 +29,20 @@ public class VersionedEntity extends VersionedModel { ...@@ -26,10 +29,20 @@ public class VersionedEntity extends VersionedModel {
@Column(nullable = false) @Column(nullable = false)
private String name; private String name;
/**
* 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;
} }
......
/* /*
* 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.
...@@ -18,6 +18,9 @@ package org.genesys.blocks.persistence; ...@@ -18,6 +18,9 @@ package org.genesys.blocks.persistence;
import org.genesys.blocks.model.UuidEntity; import org.genesys.blocks.model.UuidEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
/**
* The Interface UuidEntityRepository.
*/
public interface UuidEntityRepository extends JpaRepository<UuidEntity, Long> { public interface UuidEntityRepository extends JpaRepository<UuidEntity, Long> {
} }
/* /*
* 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.
...@@ -18,6 +18,9 @@ package org.genesys.blocks.persistence; ...@@ -18,6 +18,9 @@ package org.genesys.blocks.persistence;
import org.genesys.blocks.model.VersionedEntity; import org.genesys.blocks.model.VersionedEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
/**
* The Interface VersionedEntityRepository.
*/
public interface VersionedEntityRepository extends JpaRepository<VersionedEntity, Long> { public interface VersionedEntityRepository extends JpaRepository<VersionedEntity, Long> {
} }
/* /*
* 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.
...@@ -32,6 +32,8 @@ import org.springframework.test.context.transaction.AfterTransaction; ...@@ -32,6 +32,8 @@ import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**
* The Class BaseTest.
*
* @author Matija Obreza * @author Matija Obreza
* @author Maxym Borodenko * @author Maxym Borodenko
*/ */
...@@ -39,14 +41,21 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -39,14 +41,21 @@ import org.springframework.transaction.annotation.Transactional;
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@ContextConfiguration(name = "root", classes = { ApplicationConfig.class }) @ContextConfiguration(name = "root", classes = { ApplicationConfig.class })
public abstract class BaseTest { public abstract class BaseTest {
/** The log. */
protected final Logger LOG = LoggerFactory.getLogger(getClass()); protected final Logger LOG = LoggerFactory.getLogger(getClass());
/** The versioned entity repository. */
@Autowired @Autowired
protected VersionedEntityRepository versionedEntityRepository; protected VersionedEntityRepository versionedEntityRepository;
/** The uuid entity repository. */
@Autowired @Autowired
protected UuidEntityRepository uuidEntityRepository; protected UuidEntityRepository uuidEntityRepository;
/**
* Cleanup.
*/
@AfterTransaction @AfterTransaction
@Transactional @Transactional
public void cleanup() { public void cleanup() {
......
/* /*
* 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.
...@@ -20,10 +20,15 @@ import org.junit.Before; ...@@ -20,10 +20,15 @@ import org.junit.Before;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/** /**
* The Class ServiceTest.
*
* @author Matija Obreza * @author Matija Obreza
*/ */
public abstract class ServiceTest extends BaseTest { public abstract class ServiceTest extends BaseTest {
/**
* Before test.
*/
@Before @Before
@Transactional @Transactional
public void beforeTest() { 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"); * 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.
...@@ -32,6 +32,9 @@ import java.util.Set; ...@@ -32,6 +32,9 @@ import java.util.Set;
import org.genesys.blocks.model.Copyable; import org.genesys.blocks.model.Copyable;
import org.junit.Test; import org.junit.Test;
/**
* The Class CopyableTest.
*/
public class CopyableTest { public class CopyableTest {
private static class Parent { private static class Parent {
...@@ -93,6 +96,9 @@ public class CopyableTest { ...@@ -93,6 +96,9 @@ public class CopyableTest {
} }
} }
/**
* Test copy.
*/
@Test @Test
public void testCopy() { public void testCopy() {
final Child source = new Child(); final Child source = new Child();
......
/* /*
* 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.
...@@ -27,11 +27,17 @@ import org.genesys.blocks.tests.ServiceTest; ...@@ -27,11 +27,17 @@ import org.genesys.blocks.tests.ServiceTest;
import org.junit.Test; import org.junit.Test;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/**
* The Class UuidModelTest.
*/
@Transactional @Transactional
public class UuidModelTest extends ServiceTest { public class UuidModelTest extends ServiceTest {
private static final String ENTITY_NAME = "Entity"; private static final String ENTITY_NAME = "Entity";
/**
* Test constructor.
*/
@Test @Test
public void testConstructor() { public void testConstructor() {
UuidEntity entity = new UuidEntity(); UuidEntity entity = new UuidEntity();
...@@ -40,6 +46,9 @@ public class UuidModelTest extends ServiceTest { ...@@ -40,6 +46,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getVersion(), nullValue()); assertThat(entity.getVersion(), nullValue());
} }
/**
* Version is 1 on persist.
*/
@Test @Test
public void versionIs1OnPersist() { public void versionIs1OnPersist() {
UuidEntity entity = createEntity(); UuidEntity entity = createEntity();
...@@ -48,6 +57,9 @@ public class UuidModelTest extends ServiceTest { ...@@ -48,6 +57,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getVersion(), is(1)); assertThat(entity.getVersion(), is(1));
} }
/**
* Uuid is assigned on persist.
*/
@Test @Test
public void uuidIsAssignedOnPersist() { public void uuidIsAssignedOnPersist() {
UuidEntity entity = createEntity(); UuidEntity entity = createEntity();
...@@ -56,6 +68,9 @@ public class UuidModelTest extends ServiceTest { ...@@ -56,6 +68,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getUuid(), not(nullValue())); assertThat(entity.getUuid(), not(nullValue()));
} }
/**
* Uuid assigned is persisted.
*/
@Test @Test
public void uuidAssignedIsPersisted() { public void uuidAssignedIsPersisted() {
UuidEntity entity = createEntity(); UuidEntity entity = createEntity();
...@@ -65,6 +80,11 @@ public class UuidModelTest extends ServiceTest { ...@@ -65,6 +80,11 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getUuid(), is(uuid)); assertThat(entity.getUuid(), is(uuid));
} }
/**
* Creates the entity.
*
* @return the uuid entity
*/
public UuidEntity createEntity() { public UuidEntity createEntity() {
UuidEntity entity = new UuidEntity(); UuidEntity entity = new UuidEntity();
entity.setName(ENTITY_NAME); entity.setName(ENTITY_NAME);
......
/* /*
* 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.
...@@ -25,11 +25,17 @@ import org.genesys.blocks.tests.ServiceTest; ...@@ -25,11 +25,17 @@ import org.genesys.blocks.tests.ServiceTest;
import org.junit.Test; import org.junit.Test;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
/**
* The Class VersionedModelTest.
*/
@Transactional @Transactional
public class VersionedModelTest extends ServiceTest { public class VersionedModelTest extends ServiceTest {
private static final String ENTITY_NAME = "Entity"; private static final String ENTITY_NAME = "Entity";
/**
* Test constructor.
*/
@Test @Test
public void testConstructor() { public void testConstructor() {
VersionedEntity entity = new VersionedEntity(); VersionedEntity entity = new VersionedEntity();
...@@ -38,6 +44,9 @@ public class VersionedModelTest extends ServiceTest { ...@@ -38,6 +44,9 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.isActive(), is(true)); assertThat(entity.isActive(), is(true));
} }
/**
* Version is 1 on persist.
*/
@Test @Test
public void versionIs1OnPersist() { public void versionIs1OnPersist() {
VersionedEntity entity = createEntity(); VersionedEntity entity = createEntity();
...@@ -46,12 +55,18 @@ public class VersionedModelTest extends ServiceTest { ...@@ -46,12 +55,18 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.getVersion(), is(1)); assertThat(entity.getVersion(), is(1));
} }
/**
* Active is on.
*/
@Test @Test
public void activeIsOn() { public void activeIsOn() {
VersionedEntity entity = versionedEntityRepository.save(createEntity()); VersionedEntity entity = versionedEntityRepository.save(createEntity());
assertThat(entity.getVersion(), is(1)); assertThat(entity.getVersion(), is(1));
} }
/**
* Active is off.
*/
@Test @Test
public void activeIsOff() { public void activeIsOff() {
VersionedEntity entity = versionedEntityRepository.save(createEntity()); VersionedEntity entity = versionedEntityRepository.save(createEntity());
...@@ -60,6 +75,11 @@ public class VersionedModelTest extends ServiceTest { ...@@ -60,6 +75,11 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.isActive(), is(false)); assertThat(entity.isActive(), is(false));
} }
/**
* Creates the entity.
*
* @return the versioned entity
*/
public VersionedEntity createEntity() { public VersionedEntity createEntity() {
VersionedEntity entity = new VersionedEntity(); VersionedEntity entity = new VersionedEntity();
entity.setName(ENTITY_NAME); entity.setName(ENTITY_NAME);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId> <artifactId>application-blocks</artifactId>
<version>1.4-SNAPSHOT</version> <version>1.5-SNAPSHOT</version>
</parent> </parent>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
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.
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId> <artifactId>application-blocks</artifactId>
<version>1.4-SNAPSHOT</version> <version>1.5-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Application Building Blocks</name> <name>Application Building Blocks</name>
<description>This is the shared project pom.</description> <description>This is the shared project pom.</description>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<parent> <parent>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId> <artifactId>application-blocks-parent</artifactId>
<version>1.4-SNAPSHOT</version> <version>1.5-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath> <relativePath>../parent/pom.xml</relativePath>
</parent> </parent>
<artifactId>application-blocks-security</artifactId> <artifactId>application-blocks-security</artifactId>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<dependency> <dependency>
<groupId>org.genesys-pgr</groupId> <groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId> <artifactId>application-blocks-core</artifactId>
<version>1.4-SNAPSHOT</version> <version>1.5-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
......
/* /*
* 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.
...@@ -152,6 +152,9 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth ...@@ -152,6 +152,9 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
private String description; private String description;
/**
* Instantiates a new o auth client.
*/
public OAuthClient() { public OAuthClient() {
setPrincipal(true); setPrincipal(true);
} }
...@@ -361,6 +364,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth ...@@ -361,6 +364,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return autoApproveScopes; return autoApproveScopes;
} }
/**
* Sets the auto approve scopes.
*
* @param autoApproveScopes the new auto approve scopes
*/
public void setAutoApproveScopes(Set<String> autoApproveScopes) { public void setAutoApproveScopes(Set<String> autoApproveScopes) {
this.autoApproveScopes = autoApproveScopes; this.autoApproveScopes = autoApproveScopes;
} }
...@@ -375,6 +383,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth ...@@ -375,6 +383,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return resourceIds; return resourceIds;
} }
/**
* Sets the resource ids.
*
* @param resourceIds the new resource ids
*/
public void setResourceIds(Set<String> resourceIds) { public void setResourceIds(Set<String> resourceIds) {