package com.atlassian.stash.internal.repository.sync.dao.v1;

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.activeobjects.external.ModelVersion;
import com.atlassian.activeobjects.test.TestActiveObjects;
import com.atlassian.bitbucket.ao.AbstractAoDaoTest;
import com.atlassian.bitbucket.server.ApplicationPropertiesService;
import net.java.ao.test.jdbc.NonTransactional;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;

import static org.mockito.Mockito.mock;

public class MigrateToV1TaskWithMissingTableTest extends AbstractAoDaoTest {

    private ActiveObjects ao;
    private ApplicationPropertiesService applicationPropertiesService;

    @Before
    public void setUp() throws Exception {
        ao = new TestActiveObjects(entityManager);
        applicationPropertiesService = mock(ApplicationPropertiesService.class);
    }

    @NonTransactional
    @Test
    public void testUpgradeSucceedWithMissingTable() throws IOException {
        new MigrateToV1Task(applicationPropertiesService).upgrade(ModelVersion.valueOf("0"), ao);
    }

}
