pavel-avilov commented on a change in pull request #16172:
URL: https://github.com/apache/beam/pull/16172#discussion_r765923927



##########
File path: playground/backend/internal/validators/java_validators_test.go
##########
@@ -56,12 +56,14 @@ func writeFile(path string, code string) {
        }
 }
 
-func TestCheckIsUnitTests(t *testing.T) {
-       testValidatorArgs := make([]interface{}, 1)
+func TestCheckPipelineType(t *testing.T) {
+       testValidatorArgs := make([]interface{}, 3)
        testValidatorArgs[0] = unitTestFilePath
+       testValidatorArgs[2] = javaUnitTestPattern

Review comment:
       Done.

##########
File path: playground/backend/internal/validators/java_validators.go
##########
@@ -39,21 +40,26 @@ func GetJavaValidators(filePath string) *[]Validator {
                Name:      "Valid path",
        }
        unitTestValidator := Validator{
-               Validator: CheckIsUnitTests,
-               Args:      validatorArgs,
+               Validator: CheckPipelineType,
+               Args:      append(validatorArgs, javaUnitTestPattern),
                Name:      UnitTestValidatorName,
        }
-       validators := []Validator{pathCheckerValidator, unitTestValidator}
+       katasValidator := Validator{
+               Validator: CheckPipelineType,
+               Args:      append(validatorArgs, javaKatasPattern),
+               Name:      KatasValidatorName,
+       }
+       validators := []Validator{pathCheckerValidator, unitTestValidator, 
katasValidator}
        return &validators
 }
 
-func CheckIsUnitTests(args ...interface{}) (bool, error) {
+func CheckPipelineType(args ...interface{}) (bool, error) {
        filePath := args[0].(string)
        code, err := ioutil.ReadFile(filePath)
        if err != nil {
                logger.Errorf("Validation: Error during open file: %s, err: 
%s\n", filePath, err.Error())
                return false, err
        }
-       // check whether s contains substring unit test
-       return strings.Contains(string(code), javaUnitTestPattern), nil
+       // check whether s contains substring unit test or katas
+       return strings.Contains(string(code), args[2].(string)), nil

Review comment:
       Done.

##########
File path: playground/backend/internal/executors/executor.go
##########
@@ -76,8 +76,12 @@ func (ex *Executor) Validate() func(chan bool, chan error, 
*sync.Map) {
 }
 
 // Prepare returns the function that applies all preparations of executor
-func (ex *Executor) Prepare() func(chan bool, chan error) {
-       return func(doneCh chan bool, errCh chan error) {
+func (ex *Executor) Prepare() func(chan bool, chan error, *sync.Map, string) {
+       return func(doneCh chan bool, errCh chan error, valRes *sync.Map, 
filePath string) {
+               isKata, ok := valRes.Load(validators.KatasValidatorName)
+               if ok && isKata.(bool) {
+                       ex.preparators = 
*preparators.GetJavaPreparatorsForKatas(filePath)
+               }

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to