Package org.japprove.repositories
Class BaselineRepositoryImpl
java.lang.Object
org.japprove.repositories.BaselineRepositoryImpl
- All Implemented Interfaces:
BaselineRepository
public class BaselineRepositoryImpl extends java.lang.Object implements BaselineRepository
An implementation of the
BaselineRepository with a text file based approach.-
Constructor Summary
Constructors Constructor Description BaselineRepositoryImpl(ApprovalTestingConfiguration config) -
Method Summary
Modifier and Type Method Description booleanbaselineExists(java.lang.String baselineCandidateName)Returns true if the baseline exists and false otherwise.voidcopyBaselineCandidateToBaseline(java.lang.String baselineCandidateName)Copies the content of the baseline candidate to the baseline.voidcreateBaselineCandidate(com.fasterxml.jackson.databind.JsonNode data, java.lang.String name)Creates a newJsonFileand writes the data into this file.voidcreateBaselineCandidate(java.lang.String data, java.lang.String name)Creates a newTextFileand writes the data into this file.java.io.FilegetBaselineAsFile(java.lang.String name)Returns the content of the baseline in a file.java.io.FilegetBaselineCandidateAsFile(java.lang.String name)Returns the content of the baseline candidate in a file.java.util.List<java.lang.String>getBaselineCandidateNames()Returns a list of all baseline candidates names.com.fasterxml.jackson.databind.JsonNodegetContentOfJsonBaseline(java.lang.String baseline)Returns the content of the requested baseline.java.lang.StringgetContentOfTextBaseline(java.lang.String baseline)Returns the content of the requested baseline.java.lang.StringgetDifferences(java.lang.String baselineCandidateName)Computes differences of the baseline candidate and the baseline.booleanremoveBaselineCandidate(java.lang.String name)Removes an baseline candidate by its name.
-
Constructor Details
-
Method Details
-
createBaselineCandidate
public void createBaselineCandidate(java.lang.String data, java.lang.String name) throws BaselineCandidateCreationFailedExceptionDescription copied from interface:BaselineRepositoryCreates a newTextFileand writes the data into this file.- Specified by:
createBaselineCandidatein interfaceBaselineRepository- Parameters:
data- The data that should be stored in theTextFilename- The name of the current baseline- Throws:
BaselineCandidateCreationFailedException- if the baseline candidate cannot be created
-
createBaselineCandidate
public void createBaselineCandidate(com.fasterxml.jackson.databind.JsonNode data, java.lang.String name) throws BaselineCandidateCreationFailedExceptionDescription copied from interface:BaselineRepositoryCreates a newJsonFileand writes the data into this file.- Specified by:
createBaselineCandidatein interfaceBaselineRepository- Parameters:
data- The data that should be stored in theJsonFilename- The name of the current baseline- Throws:
BaselineCandidateCreationFailedException- if the baseline candidate cannot be created
-
removeBaselineCandidate
public boolean removeBaselineCandidate(java.lang.String name)Description copied from interface:BaselineRepositoryRemoves an baseline candidate by its name.- Specified by:
removeBaselineCandidatein interfaceBaselineRepository- Parameters:
name- the name of the baseline candidate that should be removed- Returns:
- true if the baseline candidate has successfully been removed, false otherwise.
-
getBaselineCandidateNames
public java.util.List<java.lang.String> getBaselineCandidateNames()Description copied from interface:BaselineRepositoryReturns a list of all baseline candidates names.- Specified by:
getBaselineCandidateNamesin interfaceBaselineRepository- Returns:
- a list of all baseline candidates names.
-
getContentOfJsonBaseline
public com.fasterxml.jackson.databind.JsonNode getContentOfJsonBaseline(java.lang.String baseline) throws BaselineNotFoundExceptionDescription copied from interface:BaselineRepositoryReturns the content of the requested baseline.- Specified by:
getContentOfJsonBaselinein interfaceBaselineRepository- Parameters:
baseline- the baseline for which the content should be returned- Returns:
- the content of the baseline
- Throws:
BaselineNotFoundException- if the baseline cannot be found
-
getContentOfTextBaseline
public java.lang.String getContentOfTextBaseline(java.lang.String baseline) throws BaselineNotFoundExceptionDescription copied from interface:BaselineRepositoryReturns the content of the requested baseline.- Specified by:
getContentOfTextBaselinein interfaceBaselineRepository- Parameters:
baseline- the baseline for which the content should be returned- Returns:
- the content of the baseline
- Throws:
BaselineNotFoundException- if the baseline cannot be found
-
copyBaselineCandidateToBaseline
public void copyBaselineCandidateToBaseline(java.lang.String baselineCandidateName) throws BaselineCandidateNotFoundException, BaselineCreationFailedException, CopyingFailedExceptionDescription copied from interface:BaselineRepositoryCopies the content of the baseline candidate to the baseline.- Specified by:
copyBaselineCandidateToBaselinein interfaceBaselineRepository- Parameters:
baselineCandidateName- the name of the baseline candidate- Throws:
BaselineCandidateNotFoundException- if the candidate of the baseline cannot be foundBaselineCreationFailedException- if the baseline cannot be createdCopyingFailedException- in the case the content of the baseline candidate cannot be copied to the baseline
-
getDifferences
public java.lang.String getDifferences(java.lang.String baselineCandidateName) throws BaselineCandidateNotFoundException, BaselineNotFoundExceptionDescription copied from interface:BaselineRepositoryComputes differences of the baseline candidate and the baseline.- Specified by:
getDifferencesin interfaceBaselineRepository- Parameters:
baselineCandidateName- the name of the baseline candidate- Returns:
- a string with the differences
- Throws:
BaselineCandidateNotFoundException- if the candidate of the baseline cannot be foundBaselineNotFoundException- if the baseline cannot be found
-
baselineExists
public boolean baselineExists(java.lang.String baselineCandidateName)Description copied from interface:BaselineRepositoryReturns true if the baseline exists and false otherwise.- Specified by:
baselineExistsin interfaceBaselineRepository- Parameters:
baselineCandidateName- the baseline candidate for which the baseline should be found.- Returns:
- true if the baseline exists and false otherwise.
-
getBaselineCandidateAsFile
public java.io.File getBaselineCandidateAsFile(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:BaselineRepositoryReturns the content of the baseline candidate in a file.- Specified by:
getBaselineCandidateAsFilein interfaceBaselineRepository- Parameters:
name- the name of the baseline candidate.- Returns:
- the content of the baseline candidate in a file.
- Throws:
java.io.IOException- in the case of problems with the created file.
-
getBaselineAsFile
public java.io.File getBaselineAsFile(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:BaselineRepositoryReturns the content of the baseline in a file.- Specified by:
getBaselineAsFilein interfaceBaselineRepository- Parameters:
name- the name of the baseline.- Returns:
- the content of the baseline in a file.
- Throws:
java.io.IOException- in the case of problems with the created file.
-