// Path: src/de/neuland/firefly/migration/MigrationRepository.java
// @Repository
// @Scope("prototype")
// public class MigrationRepository {
//     @Autowired private ModelService modelService;
// 
//     public FireflyMigrationModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyMigrationModel create() {
//         return modelService.create(FireflyMigrationModel.class);
//     }
// 
//     public void save(FireflyMigrationModel migration) {
//         modelService.save(migration);
//     }
// }
// 
// Path: testsrc/de/neuland/firefly/TestUtils.java
// public static void unwrapException(RuntimeException e) throws Throwable {
//     if (e.getCause() != null) {
//         throw e.getCause();
//     } else {
//         throw e;
//     }
// }
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_HMC_XML_MD5 = "NO_HMC_XML";
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_ITEMS_XML_MD5 = "NO_ITEMS_XML";
// 
// Path: src/de/neuland/firefly/utils/MD5Util.java
// public static String generateMD5(String baseValue) {
//     return generateMD5(baseValue, "UTF-8", "MD5");
// }


import de.hybris.platform.core.PK;
import de.neuland.firefly.migration.MigrationRepository;
import de.neuland.firefly.model.FireflyExtensionModel;
import de.neuland.firefly.model.FireflyExtensionStateModel;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.xml.sax.SAXException;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import static de.neuland.firefly.TestUtils.unwrapException;
import static de.neuland.firefly.constants.FireflyConstants.NO_HMC_XML_MD5;
import static de.neuland.firefly.constants.FireflyConstants.NO_ITEMS_XML_MD5;
import static de.neuland.firefly.utils.MD5Util.generateMD5;
import static java.util.Arrays.asList;
import static org.apache.commons.io.FileUtils.getTempDirectory;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
        boolean updateRequired = fireflyExtension.isUpdateRequired();
        // then
        assertTrue(updateRequired);
    }

    @Test
    public void shouldRequireHmcResetForNewExtension() throws Exception {
        // given
        givenExtensionIsNotInRepository(EXTENSION_WITH_ITEMS_XML);
        // when
        boolean hmcResetRequired = fireflyExtension.isHmcResetRequired();
        // then
        assertTrue(hmcResetRequired);
    }

    @Test
    public void shouldRequireUpdateIfDefinitionHashIsChanged() throws Exception {
        // given
        FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState("SOME_VALUE", null));
        given(fireflyExtensionRepository.findByName(EXTENSION_WITH_ITEMS_XML)).willReturn(fireflyExtensionModel);
        // when
        boolean updateRequired = fireflyExtension.isUpdateRequired();
        // then
        assertTrue(updateRequired);
    }

    @Test
    public void shouldNotRequireUpdateIfDefinitionHashIsInHistory() throws Exception {
        // given
        fireflyExtension = createExtension(EXTENSION_WITH_ITEMS_XML, true);
// Path: src/de/neuland/firefly/migration/MigrationRepository.java
// @Repository
// @Scope("prototype")
// public class MigrationRepository {
//     @Autowired private ModelService modelService;
// 
//     public FireflyMigrationModel findByPk(PK pk) {
//         return modelService.get(pk);
//     }
// 
//     public FireflyMigrationModel create() {
//         return modelService.create(FireflyMigrationModel.class);
//     }
// 
//     public void save(FireflyMigrationModel migration) {
//         modelService.save(migration);
//     }
// }
// 
// Path: testsrc/de/neuland/firefly/TestUtils.java
// public static void unwrapException(RuntimeException e) throws Throwable {
//     if (e.getCause() != null) {
//         throw e.getCause();
//     } else {
//         throw e;
//     }
// }
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_HMC_XML_MD5 = "NO_HMC_XML";
// 
// Path: src/de/neuland/firefly/constants/FireflyConstants.java
// public static final String NO_ITEMS_XML_MD5 = "NO_ITEMS_XML";
// 
// Path: src/de/neuland/firefly/utils/MD5Util.java
// public static String generateMD5(String baseValue) {
//     return generateMD5(baseValue, "UTF-8", "MD5");
// }


// Path: testsrc/de/neuland/firefly/extensionfinder/FireflyExtensionTest.java
import de.hybris.platform.core.PK;
import de.neuland.firefly.migration.MigrationRepository;
import de.neuland.firefly.model.FireflyExtensionModel;
import de.neuland.firefly.model.FireflyExtensionStateModel;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.xml.sax.SAXException;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import static de.neuland.firefly.TestUtils.unwrapException;
import static de.neuland.firefly.constants.FireflyConstants.NO_HMC_XML_MD5;
import static de.neuland.firefly.constants.FireflyConstants.NO_ITEMS_XML_MD5;
import static de.neuland.firefly.utils.MD5Util.generateMD5;
import static java.util.Arrays.asList;
import static org.apache.commons.io.FileUtils.getTempDirectory;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

        boolean updateRequired = fireflyExtension.isUpdateRequired();
        // then
        assertTrue(updateRequired);
    }

    @Test
    public void shouldRequireHmcResetForNewExtension() throws Exception {
        // given
        givenExtensionIsNotInRepository(EXTENSION_WITH_ITEMS_XML);
        // when
        boolean hmcResetRequired = fireflyExtension.isHmcResetRequired();
        // then
        assertTrue(hmcResetRequired);
    }

    @Test
    public void shouldRequireUpdateIfDefinitionHashIsChanged() throws Exception {
        // given
        FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState("SOME_VALUE", null));
        given(fireflyExtensionRepository.findByName(EXTENSION_WITH_ITEMS_XML)).willReturn(fireflyExtensionModel);
        // when
        boolean updateRequired = fireflyExtension.isUpdateRequired();
        // then
        assertTrue(updateRequired);
    }

    @Test
    public void shouldNotRequireUpdateIfDefinitionHashIsInHistory() throws Exception {
        // given
        fireflyExtension = createExtension(EXTENSION_WITH_ITEMS_XML, true);
        FireflyExtensionModel fireflyExtensionModel = mockExtension(mockState(generateMD5(ITEMS_XML_CONTENT), null),