package com.atlassian.bitbucket.test.rules;

import com.atlassian.bitbucket.test.LicenseTestHelper;
import org.junit.Ignore;
import org.junit.rules.ExternalResource;

/**
 * A junit rule which ensures that the license count is what we expect. This helps to work around
 * the licensed user count being eventually consistent
 */
@Ignore
public class LicenseCountRule extends ExternalResource {

    private final int expected;

    public LicenseCountRule() {
        this(LicenseTestHelper.DEFAULT_LICENSED_USER_COUNT);
    }

    public LicenseCountRule(int expected) {
        this.expected = expected;
    }

    @Override
    protected void after() {
        LicenseTestHelper.ensureLicensedUserCount(expected);
    }

    @Override
    protected void before() throws Throwable {
        LicenseTestHelper.ensureLicensedUserCount(expected);
    }

}
