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");
* you may not use this file except in compliance with the License.
......@@ -18,6 +18,9 @@ package org.genesys.blocks.model;
import javax.persistence.Column;
import javax.persistence.Entity;
/**
* The Class UuidEntity.
*/
@Entity
public class UuidEntity extends UuidModel {
......@@ -26,10 +29,20 @@ public class UuidEntity extends UuidModel {
@Column(nullable = false)
private String name;
/**
* 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;
}
......
/*
* 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,6 +18,9 @@ package org.genesys.blocks.model;
import javax.persistence.Column;
import javax.persistence.Entity;
/**
* The Class VersionedEntity.
*/
@Entity
public class VersionedEntity extends VersionedModel {
......@@ -26,10 +29,20 @@ public class VersionedEntity extends VersionedModel {
@Column(nullable = false)
private String name;
/**
* 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;
}
......
/*
* 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,6 +18,9 @@ package org.genesys.blocks.persistence;
import org.genesys.blocks.model.UuidEntity;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* The Interface UuidEntityRepository.
*/
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");
* you may not use this file except in compliance with the License.
......@@ -18,6 +18,9 @@ package org.genesys.blocks.persistence;
import org.genesys.blocks.model.VersionedEntity;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* The Interface VersionedEntityRepository.
*/
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");
* you may not use this file except in compliance with the License.
......@@ -32,6 +32,8 @@ import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class BaseTest.
*
* @author Matija Obreza
* @author Maxym Borodenko
*/
......@@ -39,14 +41,21 @@ import org.springframework.transaction.annotation.Transactional;
@EnableAspectJAutoProxy
@ContextConfiguration(name = "root", classes = { ApplicationConfig.class })
public abstract class BaseTest {
/** The log. */
protected final Logger LOG = LoggerFactory.getLogger(getClass());
/** The versioned entity repository. */
@Autowired
protected VersionedEntityRepository versionedEntityRepository;
/** The uuid entity repository. */
@Autowired
protected UuidEntityRepository uuidEntityRepository;
/**
* Cleanup.
*/
@AfterTransaction
@Transactional
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");
* you may not use this file except in compliance with the License.
......@@ -20,10 +20,15 @@ import org.junit.Before;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class ServiceTest.
*
* @author Matija Obreza
*/
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.
......@@ -32,6 +32,9 @@ import java.util.Set;
import org.genesys.blocks.model.Copyable;
import org.junit.Test;
/**
* The Class CopyableTest.
*/
public class CopyableTest {
private static class Parent {
......@@ -93,6 +96,9 @@ public class CopyableTest {
}
}
/**
* Test copy.
*/
@Test
public void testCopy() {
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");
* you may not use this file except in compliance with the License.
......@@ -27,11 +27,17 @@ import org.genesys.blocks.tests.ServiceTest;
import org.junit.Test;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class UuidModelTest.
*/
@Transactional
public class UuidModelTest extends ServiceTest {
private static final String ENTITY_NAME = "Entity";
/**
* Test constructor.
*/
@Test
public void testConstructor() {
UuidEntity entity = new UuidEntity();
......@@ -40,6 +46,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getVersion(), nullValue());
}
/**
* Version is 1 on persist.
*/
@Test
public void versionIs1OnPersist() {
UuidEntity entity = createEntity();
......@@ -48,6 +57,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getVersion(), is(1));
}
/**
* Uuid is assigned on persist.
*/
@Test
public void uuidIsAssignedOnPersist() {
UuidEntity entity = createEntity();
......@@ -56,6 +68,9 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getUuid(), not(nullValue()));
}
/**
* Uuid assigned is persisted.
*/
@Test
public void uuidAssignedIsPersisted() {
UuidEntity entity = createEntity();
......@@ -65,6 +80,11 @@ public class UuidModelTest extends ServiceTest {
assertThat(entity.getUuid(), is(uuid));
}
/**
* Creates the entity.
*
* @return the uuid entity
*/
public UuidEntity createEntity() {
UuidEntity entity = new UuidEntity();
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");
* you may not use this file except in compliance with the License.
......@@ -25,11 +25,17 @@ import org.genesys.blocks.tests.ServiceTest;
import org.junit.Test;
import org.springframework.transaction.annotation.Transactional;
/**
* The Class VersionedModelTest.
*/
@Transactional
public class VersionedModelTest extends ServiceTest {
private static final String ENTITY_NAME = "Entity";
/**
* Test constructor.
*/
@Test
public void testConstructor() {
VersionedEntity entity = new VersionedEntity();
......@@ -38,6 +44,9 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.isActive(), is(true));
}
/**
* Version is 1 on persist.
*/
@Test
public void versionIs1OnPersist() {
VersionedEntity entity = createEntity();
......@@ -46,12 +55,18 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.getVersion(), is(1));
}
/**
* Active is on.
*/
@Test
public void activeIsOn() {
VersionedEntity entity = versionedEntityRepository.save(createEntity());
assertThat(entity.getVersion(), is(1));
}
/**
* Active is off.
*/
@Test
public void activeIsOff() {
VersionedEntity entity = versionedEntityRepository.save(createEntity());
......@@ -60,6 +75,11 @@ public class VersionedModelTest extends ServiceTest {
assertThat(entity.isActive(), is(false));
}
/**
* Creates the entity.
*
* @return the versioned entity
*/
public VersionedEntity createEntity() {
VersionedEntity entity = new VersionedEntity();
entity.setName(ENTITY_NAME);
......
......@@ -19,7 +19,7 @@
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.5-SNAPSHOT</version>
</parent>
<artifactId>application-blocks-parent</artifactId>
<packaging>pom</packaging>
......
<?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");
you may not use this file except in compliance with the License.
......@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.5-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Application Building Blocks</name>
<description>This is the shared project pom.</description>
......
......@@ -19,7 +19,7 @@
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.5-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>application-blocks-security</artifactId>
......@@ -80,7 +80,7 @@
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.5-SNAPSHOT</version>
</dependency>
<dependency>
......
/*
* 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.
......@@ -152,6 +152,9 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
@Type(type = "org.hibernate.type.TextType")
private String description;
/**
* Instantiates a new o auth client.
*/
public OAuthClient() {
setPrincipal(true);
}
......@@ -361,6 +364,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return autoApproveScopes;
}
/**
* Sets the auto approve scopes.
*
* @param autoApproveScopes the new auto approve scopes
*/
public void setAutoApproveScopes(Set<String> autoApproveScopes) {
this.autoApproveScopes = autoApproveScopes;
}
......@@ -375,6 +383,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return resourceIds;
}
/**
* Sets the resource ids.
*
* @param resourceIds the new resource ids
*/
public void setResourceIds(Set<String> resourceIds) {
this.resourceIds = resourceIds;
}
......@@ -407,6 +420,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return scopes;
}
/**
* Sets the scopes.
*
* @param scopes the new scopes
*/
public void setScopes(Set<String> scopes) {
this.scopes = scopes;
}
......@@ -421,6 +439,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return grantTypes;
}
/**
* Sets the grant types.
*
* @param grantTypes the new grant types
*/
public void setGrantTypes(Set<String> grantTypes) {
this.grantTypes = grantTypes;
}
......@@ -435,6 +458,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return redirectUris;
}
/**
* Sets the redirect uris.
*
* @param redirectUris the new redirect uris
*/
public void setRedirectUris(Set<String> redirectUris) {
this.redirectUris = redirectUris;
}
......@@ -527,6 +555,11 @@ public class OAuthClient extends AclSid implements ClientDetails, Copyable<OAuth
return additionalInformation;
}
/**
* Sets the additional information.
*
* @param additionalInformation the additional information
*/
public void setAdditionalInformation(Map<String, Object> additionalInformation) {
this.additionalInformation = additionalInformation;
}
......
/*
* 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.
......@@ -28,7 +28,8 @@ public enum OAuthRole implements GrantedAuthority {
CLIENT,
/** The trusted client. */
TRUSTED_CLIENT,
/** Everyone */
/** Everyone. */
EVERYONE;
/**
......
/*
* 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.
......@@ -85,6 +85,7 @@ public class OAuthServiceImpl implements OAuthClientDetailsService, OAuthTokenSt
@Autowired
private AccessTokenRepository accessTokenRepository;
/** The password encoder. */
@Autowired
public PasswordEncoder passwordEncoder;
......
/*
* 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