Skip to content

Commit

Permalink
Merge pull request #14 from nfl/Added_test_sources_and_output_to_chec…
Browse files Browse the repository at this point in the history
…k_with_Sonar

Added test sources and output to check with sonar
  • Loading branch information
sdemchenko authored Jan 10, 2018
2 parents ecf6a4a + 00e5b56 commit fb57cec
Show file tree
Hide file tree
Showing 28 changed files with 54 additions and 118 deletions.
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ publishing {
artifact javadocJar {
classifier "javadoc"
}
artifact testJar {
classifier "tests"
}

pom.withXml {
asNode().children().last() + {
Expand Down Expand Up @@ -157,9 +160,15 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}

task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output+sourceSets.test.allSource
}

artifacts {
archives sourcesJar
archives javadocJar
archives testJar
}

jar {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ maven.central.sync=false
sonatype.username=DUMMY_SONATYPE_USER
sonatype.password=DUMMY_SONATYPE_PASSWORD

PROJECT_VERSION=1.0.6
PROJECT_VERSION=1.0.7
PROJECT_GITHUB_REPO_URL=https://github.com/nfl/gold
PROJECT_LICENSE_URL=https://github.com/nfl/gold/blob/master/LICENSE
4 changes: 2 additions & 2 deletions src/test/java/com/nfl/dm/shield/dynamic/BaseBeanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ protected void assertResult(GraphQLResult actual, String expectedData) {
}
}

protected void assertSuccess(GraphQLResult actual) throws Exception {
protected void assertSuccess(GraphQLResult actual) {
Assert.assertNotNull(actual, "Actual GraphQLResult should not be null.");
Assert.assertTrue(actual.isSuccessful());
}


protected GraphQLResult executeSchemaQuery(String query) throws Exception {
protected GraphQLResult executeSchemaQuery(String query) {
GraphQLResult graphQLResult = schemaService.executeQuery(query,
buildSchemaVariableMap(), buildSchemaWriteAccess());
if (log.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nfl.dm.shield.dynamic.referencedby;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import com.nfl.dm.shield.dynamic.service.CacheService;
Expand All @@ -10,7 +9,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -21,7 +19,6 @@


@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class ReferencedByTest extends BaseBeanTest {
// Variables to contain queries for the Schema Definitions used for the tests
private final String videoSchema;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.nfl.dm.shield.dynamic.security;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.exception.UnauthorizedException;
import com.nfl.dm.shield.dynamic.service.GraphQLInstanceService;
import com.nfl.dm.shield.dynamic.service.GraphQLResult;
import com.nfl.dm.shield.dynamic.service.GraphQLSchemaService;
import graphql.ExceptionWhileDataFetching;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

Expand All @@ -18,7 +16,6 @@
import static org.testng.Assert.*;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class InstanceMutatorPermissionsTest extends BaseBeanTest {

private static final String PAINT_SCHEMA_NAME = "Paint";
Expand Down Expand Up @@ -103,7 +100,7 @@ public void truncatePerm() {
}

@Test
public void removeExistingPaintInstanceWithoutPermissions() throws Exception {
public void removeExistingPaintInstanceWithoutPermissions() {
SchemaWriteAccess perms = new SchemaWriteAccess();
perms.addPermission(SCHEMA_NAME_SPACE, SchemaWriteAccess.SCHEMA_MODIFY);
perms.addPermission(MUTATOR_NAME_SPACE, SchemaWriteAccess.INSTANCE_MODIFY);
Expand All @@ -125,7 +122,7 @@ public void removeExistingPaintInstanceWithoutPermissions() throws Exception {
}

@Test
public void upsertPaintInstanceWithoutPermissions() throws Exception {
public void upsertPaintInstanceWithoutPermissions() {
SchemaWriteAccess perms = new SchemaWriteAccess();
perms.addPermission(SCHEMA_NAME_SPACE, SchemaWriteAccess.SCHEMA_MODIFY);

Expand All @@ -143,7 +140,7 @@ public void upsertPaintInstanceWithoutPermissions() throws Exception {
}

@Test
public void removeAllPaintInstancesWithoutPetitions() throws Exception {
public void removeAllPaintInstancesWithoutPetitions() {
SchemaWriteAccess perms = new SchemaWriteAccess();
perms.addPermission(SCHEMA_NAME_SPACE, SchemaWriteAccess.SCHEMA_MODIFY);
perms.addPermission(MUTATOR_NAME_SPACE, SchemaWriteAccess.INSTANCE_MODIFY);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.nfl.dm.shield.dynamic.security;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.service.GraphQLInstanceService;
import com.nfl.dm.shield.dynamic.service.GraphQLResult;
import com.nfl.dm.shield.dynamic.service.GraphQLSchemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

Expand All @@ -16,7 +14,6 @@
import static org.testng.Assert.assertTrue;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class NameSpaceTest extends BaseBeanTest {

private static final String PAINT_SCHEMA_NAME = "Paint";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.InstanceBaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.*;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class ConstraintTest extends InstanceBaseBeanTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -15,7 +13,6 @@
import static org.testng.Assert.assertTrue;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class DepthCheckSelfTest extends BaseBeanTest {

private static final String SCHEMA_NAME = "Deep_Thought";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


import java.util.Map;

import static org.testng.Assert.*;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class DepthCheckTest extends BaseBeanTest {

private static final String SCHEMA_NAME = "Depth_Check_First";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

Expand All @@ -13,7 +11,6 @@

@SuppressWarnings("unused")
@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class EnclosedValueTest extends BaseBeanTest {


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class ExternalReferenceArrayTest extends BaseExternalReferenceTest {

private static final String SIMON = "Simon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import static org.testng.Assert.assertFalse;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class ExternalReferenceTest extends BaseExternalReferenceTest {

private static final String SIMON = "Simon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.InstanceBaseBeanTest;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import java.util.Map;

import static org.testng.Assert.*;

@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class FindSchemaTest extends InstanceBaseBeanTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.InstanceBaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import graphql.ErrorType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import java.time.Instant;
Expand All @@ -20,7 +18,6 @@

@SuppressWarnings("unused")
@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class GraphQLInstanceServiceTest extends InstanceBaseBeanTest {

private static final Map<String, Object> VARIABLE_MAP = buildVariableMap(INSTANCE_NAME_SPACE, JOHN_CARTER_SCHEMA);
Expand Down Expand Up @@ -120,7 +117,7 @@ private void addInstance(String query, String expectedResult) {
assertEquals(result.getData().toString(), expectedResult);
}

public void instanceCanReferArrayOfInstancesOfTheSameType() throws Exception {
public void instanceCanReferArrayOfInstancesOfTheSameType() {
addInstance(addJohnCarterInstance, addJohnCarterInstanceResults);
addInstance(addJohnCarterInstanceReferringJohnCarter, viewJohnCarterInstanceReferringJohnCarter);
}
Expand Down Expand Up @@ -228,14 +225,14 @@ public void deleteAllInstances() {
addInstance("mutation { removeAllInstances { count }}", "{removeAllInstances={count=1}}");
}

public void findSchemaInstanceWithSchemaInstanceKey() throws Exception{
public void findSchemaInstanceWithSchemaInstanceKey() {
GraphQLResult result = instanceService.executeQuery(viewSkibobWithSchemaInstanceKey, buildVariableMap("skibob"),
buildSchemaWriteAccess(), DEFAULT_MAX_RECURSE_DEPTH);
assertTrue(result.isSuccessful());
assertEquals(result.getData().toString(), viewSkibobWithSchemaInstanceKeyResult);
}

public void testUpdatedDate() throws Exception {
public void testUpdatedDate() {
String baldy = "{viewer={instances={edges=[{node={id=ski_ski_ski, resort=baldy}}]}}}";
Map<String, Object> variableMap = buildVariableMap("skibob");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.domain.schema.SchemaDescription;
import graphql.ErrorType;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -13,7 +11,6 @@

import static org.testng.Assert.*;

@ContextConfiguration(classes = ApplicationTestConfig.class)
public class GraphQLSchemaRelationTest extends BaseBeanTest {

private final String addElementSchemaOne;
Expand Down Expand Up @@ -199,7 +196,7 @@ private SchemaDescription buildSchemaDescriptionForSearch(String name) {
}

@AfterMethod
public void tearDown() throws Exception {
public void tearDown() {
inMemorySchemaRepository.clearForSchemaTesting();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.nfl.dm.shield.dynamic.service;

import com.nfl.dm.shield.dynamic.ApplicationTestConfig;
import com.nfl.dm.shield.dynamic.BaseBeanTest;
import com.nfl.dm.shield.dynamic.security.SchemaWriteAccess;
import graphql.ExceptionWhileDataFetching;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

Expand All @@ -16,7 +14,6 @@

@SuppressWarnings("unused")
@Test
@ContextConfiguration(classes = {ApplicationTestConfig.class})
public class GraphQLSchemaServiceTest extends BaseBeanTest {

@Autowired
Expand Down
Loading

0 comments on commit fb57cec

Please sign in to comment.