package com.rubix.execution;

import java.util.concurrent.CompletableFuture;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import com.rubix.constant.CubeConstants;
import com.rubix.dto.CubeDTO;
import com.rubix.entity.CubeEntity;
import com.rubix.repository.CubeCustomRepository;
import com.rubix.service.impl.CubeCheckerServiceImpl;

@Component
public class CubeCheckerTask {

    private final static Logger LOGGER = Logger.getLogger(CubeCheckerServiceImpl.class);

    @Autowired
    private CubeCustomRepository cubeRepository;

    @Async
    public CompletableFuture<CubeEntity> check(final CubeDTO cube, String label, String permutation) {
        LOGGER.debug("Checking combination: " + label + " (label) " + permutation + " (permutation)");
        final CubeDTO alternate = cube.transform(label, permutation);
        String state = alternate.toString();
        String collection = CubeConstants.getCollection(alternate.getSize());
        final CubeEntity result = cubeRepository.findByKey(state, collection);
        LOGGER.debug("Finished combination: " + label + " (label) " + permutation + " (permutation)." + " State: "
                + state + (result == null ? " not " : " ") + "found");
        return CompletableFuture.completedFuture(result);
    }
}

@@ -1372,16 +1372,25 @@
 ot %22 : %22
+ has been
  %22) + %22f
@@ -1394,24 +1394,78 @@
  %22found%22);%0D%0A
+        LOGGER.debug(%22FOUNDED: %22 + result.getKey());%0D%0A
         retu

debug info correction