All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.jaylondev.swift.boot.test.constants.TestClassContainer Maven / Gradle / Ivy

The newest version!
package io.github.jaylondev.swift.boot.test.constants;

import io.github.jaylondev.swift.boot.test.annotations.IncludeComponent;
import io.github.jaylondev.swift.boot.test.annotations.SwiftBootTest;

import java.util.*;

/**
 * @author jaylon 2023/8/20 21:57
 */
public class TestClassContainer {

    private static final Set> classesList = new HashSet<>();

    private static Class testClass;

    public static void saveTestClass(Class clazz) {
        testClass = clazz;
    }

    public static void saveClasses(Set> list) {
        classesList.addAll(list);
    }

    public static List> getPreparedModifyLazyInitClasses() {
        List> unSetLazyClasses = new ArrayList<>(classesList);
        SwiftBootTest swiftBootTest = testClass.getAnnotation(SwiftBootTest.class);
        if (swiftBootTest != null) {
            Class[] unLazyClasses = swiftBootTest.unLazyClasses();
            Class[] includeComponent = swiftBootTest.includeComponent();
            unSetLazyClasses.removeAll(Arrays.asList(unLazyClasses));
            unSetLazyClasses.removeAll(Arrays.asList(includeComponent));
        }
        IncludeComponent commonIncludeComponent = testClass.getAnnotation(IncludeComponent.class);
        if (commonIncludeComponent != null) {
            Class[] commonIncludeClasses = commonIncludeComponent.value();
            unSetLazyClasses.removeAll(Arrays.asList(commonIncludeClasses));
        }
        return unSetLazyClasses;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy