Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions generator-assertions-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@
<artifactId>podam</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.stubbs.truth.generator.testing.legacy.NonBeanLegacySubject;
import io.stubbs.truth.tests.ManagedTruth;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import uk.co.jemos.podam.api.PodamFactoryImpl;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.stubbs.truth.generator.testModel.MyEmployee;
import io.stubbs.truth.generator.testModel.MyEmployeeSubject;
import io.stubbs.truth.tests.ManagedTruth;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
Expand Down
14 changes: 0 additions & 14 deletions generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
<version>1.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- Used to generate Java 8 chains for users that use them -->
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -80,10 +74,6 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.flogger</groupId>
<artifactId>flogger</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down Expand Up @@ -135,10 +125,6 @@
</dependency>

<!-- Test -->
<dependency>
<groupId>com.google.flogger</groupId>
<artifactId>flogger-slf4j-backend</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.stubbs.truth.generator.internal;

import com.google.common.flogger.FluentLogger;
import com.google.common.truth.BooleanSubject;
import io.stubbs.truth.generator.internal.model.ThreeSystem;
import lombok.RequiredArgsConstructor;
Expand All @@ -13,7 +12,6 @@

import static io.stubbs.truth.generator.internal.Utils.msg;
import static java.lang.String.format;
import static java.util.logging.Level.WARNING;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.apache.commons.lang3.StringUtils.removeStart;

Expand All @@ -25,8 +23,6 @@
@Slf4j
public class ChainStrategy extends AssertionMethodStrategy {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();

private final Options options = Options.get();

private final GeneratedSubjectTypeStore subjects;
Expand All @@ -48,7 +44,7 @@ public MethodSource<JavaClassSource> addChainStrategy(ThreeSystem<?> threeSystem

// no subject to chain
if (subjectForType.isEmpty()) {
logger.at(WARNING).log("Cant find subject for " + resolvedPair);
log.warn("Cant find subject for " + resolvedPair);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.stubbs.truth.generator.internal;

import com.google.common.flogger.FluentLogger;
import com.google.common.truth.ObjectArraySubject;
import com.google.common.truth.Subject;
import io.stubbs.truth.generator.internal.model.ThreeSystem;
Expand Down Expand Up @@ -33,8 +32,6 @@
@Slf4j
public class GeneratedSubjectTypeStore {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();

private final Map<String, ThreeSystem<?>> generatedSubjects;

@Delegate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.stubbs.truth.generator.internal;

import com.google.common.flogger.FluentLogger;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import io.stubbs.truth.generator.UserManagedTruth;
import io.stubbs.truth.generator.internal.model.*;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.JavaClassSource;
import org.jboss.forge.roaster.model.source.JavaDocSource;
Expand All @@ -23,9 +23,9 @@
* @author Antony Stubbs
* @see SubjectMethodGenerator
*/
@Slf4j
public class SkeletonGenerator implements SkeletonGeneratorAPI {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String BACKUP_PACKAGE = "io.stubbs.common.truth.extension.generator";

/**
Expand Down Expand Up @@ -272,7 +272,7 @@ private <T> MiddleClass createMiddleUserTemplateClass(JavaClassSource parent, Cl

Optional<Class<? extends Subject>> compiledMiddleClass = findCompiledMiddleIfExists(parent, middleClassName, classUnderTest);
if (compiledMiddleClass.isPresent()) {
logger.atInfo().log("Skipping middle class Template creation as class already exists: %s", middleClassName);
log.info("Skipping middle class Template creation as class already exists: %s", middleClassName);
return new UserSuppliedMiddleClass(compiledMiddleClass.get(), classUnderTest);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package io.stubbs.truth.generator.internal;

import com.google.common.flogger.FluentLogger;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.reflections.ReflectionUtils;

import java.lang.module.ModuleDescriptor;
import java.util.Arrays;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Level;

/**
* @author Antony Stubbs
*/
@Slf4j
public class SourceChecking {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();

static boolean checkSource(Class<?> source, Optional<String> targetPackage) {
if (isAnonymous(source))
return true;
Expand All @@ -27,15 +25,12 @@ static boolean checkSource(Class<?> source, Optional<String> targetPackage) {
if (isTestClass(source))
return true;

if (BuiltInSubjectTypeStore.getNativeTypes().contains(source))
return true;

return false;
return BuiltInSubjectTypeStore.getNativeTypes().contains(source);
}

private static boolean isAnonymous(Class<?> source) {
if (source.isAnonymousClass()) {
logger.at(Level.FINE).log("Skipping anonymous class %s", source);
log.debug("Skipping anonymous class %s", source);
return true;
}
return false;
Expand All @@ -44,7 +39,7 @@ private static boolean isAnonymous(Class<?> source) {
private static boolean isBuilder(Class<?> source) {
String simpleName = source.getSimpleName();
if (simpleName.contains("Builder")) {
logger.at(Level.FINE).log("Skipping builder class %s", source);
log.debug("Skipping builder class %s", source);
return true;
}
return false;
Expand All @@ -61,7 +56,7 @@ private static boolean isTestClass(Class<?> source) {
boolean nameEndsInTest = source.getSimpleName().endsWith("Test");
boolean isIndeed = hasTestAnnotatedMethod || nameEndsInTest;
if (isIndeed) {
logger.at(Level.FINE).log("Skipping a test class %s", source);
log.debug("Skipping a test class %s", source);
}
return isIndeed;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.stubbs.truth.generator.internal;

import com.google.common.flogger.FluentLogger;
import com.google.common.truth.Subject;
import io.stubbs.truth.generator.SourceClassSets;
import io.stubbs.truth.generator.TruthGeneratorAPI;
Expand All @@ -13,7 +12,6 @@

import java.nio.file.Path;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;

import static java.util.Arrays.stream;
Expand All @@ -26,7 +24,6 @@
@Slf4j
public class TruthGenerator implements TruthGeneratorAPI {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Path testOutputDir;
private final Options options;
private final ClassUtils classUtils = new ClassUtils();
Expand Down Expand Up @@ -130,7 +127,7 @@ private Set<Class<?>> filterSubjects(Set<Class<?>> classes) {
return !isASubject && !alreadyExists;
}).collect(toSet());

logger.at(Level.FINE).log("Removed %s Subjects from inbound", classes.size() - filtered.size());
log.debug("Removed %s Subjects from inbound", classes.size() - filtered.size());
return classes;
}

Expand Down Expand Up @@ -164,11 +161,10 @@ public Result generate(SourceClassSets ss) {
Set<Class<?>> missing = rc.findReferencedNotIncluded(ss);
if (!missing.isEmpty()) {
results.referencedNotBuild(missing);
logger.at(Level.WARNING)
.log("Some referenced classes in the tree are not in the list of Subjects to be generated. " +
"Consider using automatic recursive generation, or add the missing classes. " +
"Otherwise your experience will be limited in places." +
"Missing classes %s", missing);
log.debug("Some referenced classes in the tree are not in the list of Subjects to be generated. " +
"Consider using automatic recursive generation, or add the missing classes. " +
"Otherwise your experience will be limited in places." +
"Missing classes %s", missing);
}
}

Expand Down Expand Up @@ -223,7 +219,7 @@ public Result generate(SourceClassSets ss) {
union.addAll(fromLegacyPackageSet);

if (union.isEmpty())
logger.atWarning().log("Nothing generated. Check your settings.");
log.warn("Nothing generated. Check your settings.");

//
addTests(union);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.stubbs.truth.generator;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author Antony Stubbs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.stubbs.truth.generator.internal;

import io.stubbs.truth.generator.TestModelUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.stubbs.truth.generator.testModel.Project;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.time.Instant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.stubbs.truth.generator.testModel.MyEmployee;
import io.stubbs.truth.generator.testModel.Project;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import one.util.streamex.StreamEx;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.net.http.HttpRequest;
Expand All @@ -31,7 +31,7 @@ public class JDKOverrideAnalyserTest {

JDKOverrideAnalyser jdkOverrideAnalyser;

@Before
@BeforeEach
public void setup() {
jdkOverrideAnalyser = new JDKOverrideAnalyser(Options.builder().build());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.stubbs.truth.generator.internal;

import io.stubbs.truth.generator.testModel.MyEmployee;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.stubbs.truth.generator.internal;

import com.google.common.truth.IntegerSubject;
import com.google.common.truth.OptionalSubject;
import com.google.common.truth.Subject;
import com.google.common.truth.Truth8;
import io.stubbs.truth.generator.TestModelUtils;
Expand All @@ -11,7 +10,7 @@
import io.stubbs.truth.generator.testModel.MyEmployee;
import io.stubbs.truth.generator.testModel.Person;
import lombok.SneakyThrows;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.util.Map;
Expand Down Expand Up @@ -107,7 +106,7 @@ public void wildCardTypeFromSubtype() {
public void wildCardTypeDirectUpperBoundGeneric() {
var resolvedPair = testResolution(Person.class, "getMyWildcardTypeWithLowerAndUpperBoundsGeneric", Optional.class);
Truth8.assertThat(resolvedPair.getSubject()).isPresent();
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(OptionalSubject.class);
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(io.stubbs.truth.autoShaded.java.util.OptionalSubject.class);
}


Expand All @@ -118,7 +117,7 @@ public void wildCardTypeDirectUpperBoundGeneric() {
public void wildCardTypeFromSubtypeUpperBoundGeneric() {
var resolvedPair = testResolution(MyEmployee.class, "getMyWildcardTypeWithLowerAndUpperBoundsGeneric", Optional.class);
Truth8.assertThat(resolvedPair.getSubject()).isPresent();
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(OptionalSubject.class);
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(io.stubbs.truth.autoShaded.java.util.OptionalSubject.class);
}

/**
Expand All @@ -128,7 +127,7 @@ public void wildCardTypeFromSubtypeUpperBoundGeneric() {
public void wildCardTypeDirectUpperBoundIdCard() {
var resolvedPair = testResolution(Person.class, "getMyWildcardTypeWithLowerAndUpperBoundsIdCard", Optional.class);
Truth8.assertThat(resolvedPair.getSubject()).isPresent();
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(OptionalSubject.class);
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(io.stubbs.truth.autoShaded.java.util.OptionalSubject.class);
}


Expand All @@ -139,7 +138,7 @@ public void wildCardTypeDirectUpperBoundIdCard() {
public void wildCardTypeFromSubtypeUpperBoundIdCard() {
var resolvedPair = testResolution(MyEmployee.class, "getMyWildcardTypeWithLowerAndUpperBoundsIdCard", Optional.class);
Truth8.assertThat(resolvedPair.getSubject()).isPresent();
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(OptionalSubject.class);
assertThat(resolvedPair.getSubject().get().getClazz()).isEqualTo(io.stubbs.truth.autoShaded.java.util.OptionalSubject.class);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.stubbs.truth.generator.TruthGeneratorAPI;
import io.stubbs.truth.generator.internal.model.ThreeSystem;
import io.stubbs.truth.generator.testModel.MyEmployee;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.time.Instant;

Expand Down
Loading