This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from tobiasgindler/master
[#22] Added unit tests to increase test coverage.
- Loading branch information
Showing
12 changed files
with
581 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/src/main/java/io/tracee/contextlogger/api/WrappedContextLoggerOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
core/src/test/java/io/tracee/contextlogger/AbstractToStringBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package io.tracee.contextlogger; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import io.tracee.contextlogger.api.TraceeContextStringRepresentationBuilder; | ||
import io.tracee.contextlogger.impl.ContextLoggerConfiguration; | ||
import io.tracee.contextlogger.outputgenerator.writer.OutputWriterConfiguration; | ||
import io.tracee.contextlogger.profile.Profile; | ||
|
||
/** | ||
* Unit test for {@link AbstractToStringBuilder}. | ||
*/ | ||
public class AbstractToStringBuilderTest { | ||
|
||
public static class TestToStringBuilder extends AbstractToStringBuilder<TestToStringBuilder> { | ||
|
||
protected TestToStringBuilder() { | ||
super((ContextLoggerConfiguration)null); | ||
} | ||
|
||
protected TestToStringBuilder(final AbstractToStringBuilder instanceToClone) { | ||
super(instanceToClone); | ||
} | ||
|
||
@Override | ||
public void log(final Object... instancesToLog) { | ||
|
||
} | ||
|
||
@Override | ||
public void logWithPrefixedMessage(final String prefixedMessage, final Object... instancesToLog) { | ||
|
||
} | ||
} | ||
|
||
public TraceeContextStringRepresentationBuilder traceeContextLogBuilder = new TraceeContextStringRepresentationBuilder() { | ||
|
||
@Override | ||
public Set<Class> getWrapperClasses() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setWrapperClasses(final Set<Class> wrapperClasses) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean getEnforceOrder() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setEnforceOrder(final boolean keepOrder) { | ||
|
||
} | ||
|
||
@Override | ||
public String createStringRepresentation(final Object... instancesToLog) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setOutputWriterConfiguration(final OutputWriterConfiguration outputWriterConfiguration) { | ||
|
||
} | ||
|
||
@Override | ||
public void setManualContextOverrides(final Map<String, Boolean> manualContextOverrides) { | ||
|
||
} | ||
|
||
@Override | ||
public Map<String, Boolean> getManualContextOverrides() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public TraceeContextStringRepresentationBuilder cloneStringRepresentationBuilder() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setProfile(final Profile profile) { | ||
|
||
} | ||
|
||
@Override | ||
public Profile getProfile() { | ||
return null; | ||
} | ||
}; | ||
|
||
@Test | ||
public void should_use_constructor_correctly() { | ||
|
||
TestToStringBuilder source = new TestToStringBuilder(); | ||
source.setStringRepresentationBuilder(traceeContextLogBuilder); | ||
|
||
final Object[] objArray = { "ABC", "DEF" }; | ||
source.setObjectsToProcess(objArray); | ||
|
||
TestToStringBuilder unit = new TestToStringBuilder(source); | ||
|
||
MatcherAssert.assertThat(unit.getStringRepresentationBuilder(), Matchers.equalTo(source.getStringRepresentationBuilder())); | ||
MatcherAssert.assertThat(unit.getObjectsToProcess(), Matchers.equalTo(objArray)); | ||
MatcherAssert.assertThat(unit.getContextLoggerConfiguration(), Matchers.nullValue()); | ||
|
||
} | ||
|
||
@Test | ||
public void toString_should_be_forwarded_to_tracee_context_log_builder_correctly() { | ||
|
||
TestToStringBuilder unit = new TestToStringBuilder(); | ||
|
||
TraceeContextStringRepresentationBuilder spy = Mockito.spy(traceeContextLogBuilder); | ||
|
||
unit.setStringRepresentationBuilder(spy); | ||
|
||
unit.toString("ABC", "DEF"); | ||
Mockito.verify(spy).createStringRepresentation("ABC", "DEF"); | ||
|
||
unit.create("DEF", "GHI"); | ||
Mockito.verify(spy).createStringRepresentation("DEF", "GHI"); | ||
} | ||
} |
Oops, something went wrong.