Class JdutYamlFactory

    • Constructor Detail

      • JdutYamlFactory

        protected JdutYamlFactory()
        This class can only be used by implementation of subclass.
    • Method Detail

      • defaultBuilderOfConductorConfig

        public static Consumer<ConductorConfig.Builder> defaultBuilderOfConductorConfig​(org.junit.jupiter.api.extension.ExtensionContext context)
        Constructs a builder for ConductorConfig by default convention for resource loading(from testing class).
        Parameters:
        context - The context provided by JUnit 5
        Returns:
        new builder
      • afterAll

        public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
                      throws Exception
        Checks if any DuetConductor in ExtensionContext.Store. If it is, use the conductor to clean up data. For example:
        
         package guru.mikelue.cassia;
        
         // Loading: classpath:guru/mikelue/cassia/Verum.yaml
         @JdutResource
         public class Verum {
         }
         

        This callback would remove the DuetConductor in class-ExtensionContext.Namespace ExtensionContext.Store.

        Specified by:
        afterAll in interface org.junit.jupiter.api.extension.AfterAllCallback
        Parameters:
        context - The context provided by JUnit 5
        Throws:
        Exception - See BeforeAllCallback.beforeAll(org.junit.jupiter.api.extension.ExtensionContext)
      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                        throws Exception
        Checks if JdutResource is on testing method. If it is, loading the YAML file from classpaht:{package}/{classname}-{methodname}.yaml. For example:
        
         package guru.mikelue.cassia;
        
         public class Verum {
             // Loading: classpath:guru/mikelue/cassia/Verum-grind.yaml
             @Test @JdutResource
             void grind()
             {
             }
         }
         

        This callback would put the DuetConductor in method-ExtensionContext.Namespace ExtensionContext.Store. The DuetConductor is constructed from getYamlConductorFactory(org.junit.jupiter.api.extension.ExtensionContext, guru.mikelue.jdut.junit5.JdutYamlFactory.Event).

        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Parameters:
        context - The context provided by JUnit 5
        Throws:
        Exception - See BeforeAllCallback.beforeAll(org.junit.jupiter.api.extension.ExtensionContext)
      • afterEach

        public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                       throws Exception
        Checks if any DuetConductor in ExtensionContext.Store. If it is, use the conductor to clean up data. For example:
        
         package guru.mikelue.cassia;
        
         public class Verum {
             // Loading: classpath:guru/mikelue/cassia/Verum-grind.yaml
             @Test @JdutResource
             void grind()
             {
             }
         }
         

        This callback would remove the DuetConductor in method-ExtensionContext.Namespace ExtensionContext.Store.

        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
        Parameters:
        context - The context provided by JUnit 5
        Throws:
        Exception - See BeforeAllCallback.beforeAll(org.junit.jupiter.api.extension.ExtensionContext)
      • getLogger

        protected final org.slf4j.Logger getLogger()
        The retrieved Logger has the name of implementing class.
        Returns:
        A logger having the name of implementing class.
      • needConductData

        protected boolean needConductData​(org.junit.jupiter.api.extension.ExtensionContext context,
                                          JdutYamlFactory.Event event)
        Checks if the test should conduct data. You can override this method to control whether or not to conduct data for testing.
        Parameters:
        context - The context provided by JUnit 5
        event - The event for scope of current triggered.
        Returns:
        true if the conduction should be executed