Skip to content

Commit

Permalink
Merge branch 'develop' into gh-2421-BugHunt
Browse files Browse the repository at this point in the history
  • Loading branch information
t92549 committed Sep 17, 2021
2 parents fe31015 + 491522f commit 4733dbf
Show file tree
Hide file tree
Showing 576 changed files with 7,930 additions and 5,932 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
git config user.email github-actions@github.com
- name: Merge develop into master
if: ${{ ! contains(github.event.milestone.description, 'hotfix') }}
run: |
git remote set-branches --add origin develop
git pull
Expand Down Expand Up @@ -145,7 +146,7 @@ jobs:
run: |
git remote set-branches --add origin master
git pull
git merge origin/master
git merge origin/master --strategy-option theirs -m "Hotfix: Merge master into develop"
mvn release:update-versions -B
NEW_GAFFER_VERSION=$(mvn -q help:evaluate -DforceStdout -Dexpression=pom.version)
sed -i'' -e "s/^gaffer.version=.*/gaffer.version=$NEW_GAFFER_VERSION/" rest-api/common-rest/src/main/resources/version.properties
Expand All @@ -163,14 +164,6 @@ jobs:
with:
java-version: 1.8

- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/uk
key: gaffer-dependencies

- name: Checkout master
uses: actions/checkout@v2
with:
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/release_standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ jobs:
with:
java-version: 1.8

- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/uk
key: gaffer-dependencies

- name: Checkout Branch
uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and their licenses, below. For information on the dependencies of these dependen
projects below.


Koryphe (uk.gov.gchq.koryphe:koryphe:1.12.0):
Koryphe (uk.gov.gchq.koryphe:koryphe:1.13.0):

- Apache License, Version 2.0

Expand Down
2 changes: 1 addition & 1 deletion core/access/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>uk.gov.gchq.gaffer</groupId>
<version>1.16.1-SNAPSHOT</version>
<version>1.18.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,6 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,6 +50,7 @@ public void shouldReturnTrueForEqualObjectComparisonWhenEqual() {
assertEquals(new NoAccessPredicate(), new NoAccessPredicate());
}

@Test
@Override
public void shouldReturnFalseForEqualObjectComparisonWhenNotEqual() {
/* not possible */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,6 +50,7 @@ public void shouldReturnTrueForEqualObjectComparisonWhenEqual() {
assertEquals(new UnrestrictedAccessPredicate(), new UnrestrictedAccessPredicate());
}

@Test
@Override
public void shouldReturnFalseForEqualObjectComparisonWhenNotEqual() {
/* not possible */
Expand Down
88 changes: 33 additions & 55 deletions core/access/src/test/java/uk/gov/gchq/gaffer/user/UserTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Crown Copyright
* Copyright 2016-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,16 +16,12 @@

package uk.gov.gchq.gaffer.user;

import org.hamcrest.core.IsCollectionContaining;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class UserTest {
@Test
Expand All @@ -47,15 +43,13 @@ public void shouldBuildUser() {
.build();

// Then
assertEquals(userId, user.getUserId());
assertEquals(2, user.getDataAuths().size());
assertThat(user.getDataAuths(), IsCollectionContaining.hasItems(
dataAuth1, dataAuth2
));
assertEquals(2, user.getOpAuths().size());
assertThat(user.getOpAuths(), IsCollectionContaining.hasItems(
opAuth1, opAuth1
));
assertThat(user.getUserId()).isEqualTo(userId);
assertThat(user.getDataAuths())
.hasSize(2)
.contains(dataAuth1, dataAuth2);
assertThat(user.getOpAuths())
.hasSize(2)
.contains(opAuth1, opAuth1);
}

@Test
Expand All @@ -69,7 +63,7 @@ public void shouldReplaceNullIdWithUnknownIdWhenBuildingUser() {
.build();

// Then
assertEquals(User.UNKNOWN_USER_ID, user.getUserId());
assertThat(user.getUserId()).isEqualTo(User.UNKNOWN_USER_ID);
}

@Test
Expand All @@ -83,7 +77,7 @@ public void shouldReplaceEmptyIdWithUnknownIdWhenBuildingUser() {
.build();

// Then
assertEquals(User.UNKNOWN_USER_ID, user.getUserId());
assertThat(user.getUserId()).isEqualTo(User.UNKNOWN_USER_ID);
}

@Test
Expand All @@ -94,7 +88,7 @@ public void shouldSetUnknownIdWhenBuildingUser() {
.build();

// Then
assertEquals(User.UNKNOWN_USER_ID, user.getUserId());
assertThat(user.getUserId()).isEqualTo(User.UNKNOWN_USER_ID);
}

@Test
Expand All @@ -111,15 +105,11 @@ public void shouldNotAllowChangingDataAuths() {
.build();

// When
try {
user.getDataAuths().add(newDataAuth);
fail("Exception expected");
} catch (final UnsupportedOperationException e) {
assertNotNull(e);
}
final Set<String> dataAuths = user.getDataAuths();

// Then
assertFalse(user.getDataAuths().contains(newDataAuth));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> dataAuths.add(newDataAuth));
assertThat(dataAuths).doesNotContain(newDataAuth);
}

@Test
Expand All @@ -136,15 +126,11 @@ public void shouldNotAllowChangingOpAuths() {
.build();

// When
try {
user.getOpAuths().add(newOpAuth);
fail("Exception expected");
} catch (final UnsupportedOperationException e) {
assertNotNull(e);
}
final Set<String> opAuths = user.getOpAuths();

// Then
assertFalse(user.getOpAuths().contains(newOpAuth));
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> opAuths.add(newOpAuth));
assertThat(opAuths).doesNotContain(newOpAuth);
}

@Test
Expand Down Expand Up @@ -172,12 +158,10 @@ public void shouldBeEqualWhen2UsersHaveSameFields() {
.opAuth(opAuth2)
.build();

// When
final boolean isEqual = userLocked.equals(userUnlocked);

// Then
assertTrue(isEqual);
assertEquals(userLocked.hashCode(), userUnlocked.hashCode());
assertThat(userLocked)
.isEqualTo(userUnlocked)
.hasSameHashCodeAs(userUnlocked);
}

@Test
Expand Down Expand Up @@ -206,12 +190,10 @@ public void shouldNotBeEqualWhen2UsersHaveDifferentUserIds() {
.opAuth(opAuth2)
.build();

// When
final boolean isEqual = user1.equals(user2);

// Then
assertFalse(isEqual);
assertNotEquals(user1.hashCode(), user2.hashCode());
assertThat(user1)
.isNotEqualTo(user2)
.doesNotHaveSameHashCodeAs(user2);
}

@Test
Expand All @@ -233,12 +215,10 @@ public void shouldNotBeEqualWhen2UsersHaveDifferentDataAuths() {
.dataAuth(dataAuth2b)
.build();

// When
final boolean isEqual = user1.equals(user2);

// Then
assertFalse(isEqual);
assertNotEquals(user1.hashCode(), user2.hashCode());
assertThat(user1)
.isNotEqualTo(user2)
.doesNotHaveSameHashCodeAs(user2);
}

@Test
Expand All @@ -260,11 +240,9 @@ public void shouldNotBeEqualWhen2UsersHaveDifferentOpAuths() {
.opAuth(opAuth2b)
.build();

// When
final boolean isEqual = user1.equals(user2);

// Then
assertFalse(isEqual);
assertNotEquals(user1.hashCode(), user2.hashCode());
assertThat(user1)
.isNotEqualTo(user2)
.doesNotHaveSameHashCodeAs(user2);
}
}
2 changes: 1 addition & 1 deletion core/cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>uk.gov.gchq.gaffer</groupId>
<version>1.16.1-SNAPSHOT</version>
<version>1.18.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Crown Copyright
* Copyright 2017-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,10 +25,10 @@

import java.util.Properties;

import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CacheServiceLoaderTest {

Expand All @@ -52,20 +52,17 @@ public void shouldLoadServiceFromSystemVariable() {

final ICacheService service = CacheServiceLoader.getService();

assertTrue(service instanceof EmptyCacheService);
assertThat(service).isInstanceOf(EmptyCacheService.class);
}

@Test
public void shouldThrowAnExceptionWhenSystemVariableIsInvalid() {
final String invalidClassName = "invalid.cache.name";
serviceLoaderProperties.setProperty(CacheProperties.CACHE_SERVICE_CLASS, invalidClassName);

final Exception exception = assertThrows(IllegalArgumentException.class, () -> {
CacheServiceLoader.initialise(serviceLoaderProperties);
});

final String expected = "Failed to instantiate cache using class invalid.cache.name";
assertEquals(expected, exception.getMessage());
assertThatIllegalArgumentException()
.isThrownBy(() -> CacheServiceLoader.initialise(serviceLoaderProperties))
.withMessage("Failed to instantiate cache using class invalid.cache.name");
}

@Test
Expand Down
11 changes: 5 additions & 6 deletions core/cache/src/test/java/uk/gov/gchq/gaffer/cache/CacheTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 Crown Copyright
* Copyright 2018-2021 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,9 +26,9 @@

import java.util.Properties;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CacheTest {

Expand Down Expand Up @@ -68,11 +68,10 @@ public void shouldAddAndGetCacheOverwrite() throws CacheOperationException {
public void shouldAddAndGetCacheNoOverwrite() throws CacheOperationException {
cache.addToCache("key1", 1, true);

final Exception exception = assertThrows(OverwritingException.class, () -> {
cache.addToCache("key1", 2, false);
});
assertThatExceptionOfType(OverwritingException.class)
.isThrownBy(() -> cache.addToCache("key1", 2, false))
.withMessage("Cache entry already exists for key: key1");

assertEquals("Cache entry already exists for key: key1", exception.getMessage());
assertEquals(1, cache.getFromCache("key1").intValue());
}

Expand Down
Loading

0 comments on commit 4733dbf

Please sign in to comment.