Package com.hybris.datahub.core.facades
Class ImportTestUtils
- java.lang.Object
-
- com.hybris.datahub.core.facades.ImportTestUtils
-
public class ImportTestUtils extends java.lang.ObjectUtilities to help with testing.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ImportErrorerror(ErrorCode code, java.lang.String msg)Simulates an import error with the specified error code and the message.static ImportErrorerror(java.lang.String msg)Simulates an import error with the specified message.static java.util.Collection<ImportError>errors(java.lang.String... messages)Simulates an import error for each message submitted.static ImpExErrorimpExError(java.lang.String msg)Simulates an impex error with the specified error message.static ImportResultimportResultWithLogErrors(java.lang.String impexFileLoc, java.lang.String errLogText)Mocks an import result with errors present in the error log.static ImportResultimportResultWithUnresolvedLineErrors(java.lang.String impexFileLoc, java.lang.String errLogText, java.io.InputStream mediaStream)Mocks an import result with errors present in the unresolved lines.static voidmakeResultSuccessful(ImportResult result)Takes mock of anImportResultand finishes stubbing to simulate success import result.static voidmakeResultWithErrors(ImportResult res, java.lang.String errLogText)Takes mock of anImportResultand finishes stubbing to simulate errors present in the result.static voidmakeResultWithErrors(ImportResult res, java.lang.String errLogText, MediaService mediaService, java.io.InputStream mediaStream)Takes mock of anImportResultand finishes stubbing to simulate errors present in the result.static voidmakeResultWithMediaServiceException(ImportResult res, MediaService mediaService)Takes mock of anImportResultand throws an IOException when calling the mediaServicestatic java.io.InputStreamtoInputStream(java.lang.String... lines)static java.lang.StringtoText(java.lang.String... lines)Converts separate strings into a multi-line text, where each string becomes a separate line.
-
-
-
Method Detail
-
error
public static ImportError error(java.lang.String msg)
Simulates an import error with the specified message.- Parameters:
msg- an error message for the error.- Returns:
- an import error
-
error
public static ImportError error(ErrorCode code, java.lang.String msg)
Simulates an import error with the specified error code and the message.- Parameters:
code- an error code to use for the error.msg- an error message for the error.- Returns:
- an import error
-
errors
public static java.util.Collection<ImportError> errors(java.lang.String... messages)
Simulates an import error for each message submitted.- Parameters:
messages- an array of messages to convert to import errors- Returns:
- a collection of import errors with the specified messages.
-
impExError
public static ImpExError impExError(java.lang.String msg)
Simulates an impex error with the specified error message.- Parameters:
msg- an error message for the error.- Returns:
- an ImpExError
-
makeResultSuccessful
public static void makeResultSuccessful(ImportResult result)
Takes mock of anImportResultand finishes stubbing to simulate success import result.- Parameters:
result- a result mock to stub.
-
importResultWithLogErrors
public static ImportResult importResultWithLogErrors(java.lang.String impexFileLoc, java.lang.String errLogText)
Mocks an import result with errors present in the error log.- Parameters:
impexFileLoc- location of the impex source file being imported.errLogText- content of the error log to mock in the result.- Returns:
- the mocked result
-
importResultWithUnresolvedLineErrors
public static ImportResult importResultWithUnresolvedLineErrors(java.lang.String impexFileLoc, java.lang.String errLogText, java.io.InputStream mediaStream)
Mocks an import result with errors present in the unresolved lines. Whenever reference violations are reported in the import result, the error log contains a generic error about reference violation. Therefore the error log content should passed too.- Parameters:
impexFileLoc- location of the impex source file being imported.errLogText- content of the error log to mock in the result.mediaStream- content of the unresolved lines to mock in the result.- Returns:
- the mocked result
-
makeResultWithErrors
public static void makeResultWithErrors(ImportResult res, java.lang.String errLogText)
Takes mock of anImportResultand finishes stubbing to simulate errors present in the result.- Parameters:
res- a mock of theImportResultto finish stubbing.errLogText- content of the error log to mock in the import result.
-
makeResultWithErrors
public static void makeResultWithErrors(ImportResult res, java.lang.String errLogText, MediaService mediaService, java.io.InputStream mediaStream)
Takes mock of anImportResultand finishes stubbing to simulate errors present in the result.- Parameters:
res- a mock of theImportResultto finish stubbing.errLogText- content of the error log to mock in the import result.mediaService- the mediaServicemediaStream- c should be simulated.
-
makeResultWithMediaServiceException
public static void makeResultWithMediaServiceException(ImportResult res, MediaService mediaService)
Takes mock of anImportResultand throws an IOException when calling the mediaService- Parameters:
res- a mock of theImportResultto finish stubbing.mediaService- a mock of theImportResultto finish stubbing.
-
toText
public static java.lang.String toText(java.lang.String... lines)
Converts separate strings into a multi-line text, where each string becomes a separate line.- Parameters:
lines- lines of text to merge together. Pass empty strings for empty (blank) lines in the resulting text.- Returns:
- text consisting of the lines combined together.
-
toInputStream
public static java.io.InputStream toInputStream(java.lang.String... lines)
-
-