package de.tse.beanrepository.example;

import de.tse.beanrepository.BeanRepository;
import de.tse.beanrepository.example.services.MailService;
import de.tse.beanrepository.example.services.PrintService;
import de.tse.beanrepository.example.services.ServiceWithPostConstruct;
import org.junit.Test;

/**
 * No valid Tests, but it shows the Functionality of the BeanRepository.
 */
public class ExampleTest {

    /**
     * MailService depends on PrintService
     */
    @Test public void singletonDependency() {

        final BeanRepository repo = new BeanRepository.BeanRepositoryBuilder()
                .singleton(MailService.class, MailService::new)
                .singleton(PrintService.class, PrintService::new)
                .build();

        final MailService mailService = repo.get(MailService.class);
        mailService.sendMail("You", "Hi!");
    }

    @Test public void singeInstance() {

        final String[] values = new String[] { "a", "b", "c" } ;

        final BeanRepository repo = new BeanRepository.BeanRepositoryBuilder()
                .instance(values)
                .build();

        for (String value : repo.get(String[].class)) {
            System.out.println(value);
        }
    }

    /**
     * For a singleton to onPostConstruct Method must be called only once.
     */
    @Test public void singletonOnlyOnePostConstruct() {

        final BeanRepository repo = new BeanRepository.BeanRepositoryBuilder()
                .singleton(ServiceWithPostConstruct.class, ServiceWithPostConstruct::new)
                .build();

        repo.get(ServiceWithPostConstruct.class);
        repo.get(ServiceWithPostConstruct.class);
        repo.get(ServiceWithPostConstruct.class);
        // see System.out: only one output has to appear for this test
    }

    /**
     * For a singleton to onPostConstruct Method must be called only once.
     */
    @Test public void prototypeWithMultiplePostConstruct() {

        final BeanRepository repo = new BeanRepository.BeanRepositoryBuilder()
                .prototype(ServiceWithPostConstruct.class, ServiceWithPostConstruct::new)
                .build();

        repo.get(ServiceWithPostConstruct.class);
        repo.get(ServiceWithPostConstruct.class);
        repo.get(ServiceWithPostConstruct.class);
        // see System.out: three outputs has to appear for this test
    }
}

@@ -890,21 +890,24 @@
 oid 
-singeI
+i
 nstance
+Handling
 () %7B
@@ -1239,33 +1239,33 @@
 **%0A     * For a 
-s
+S
 ingleton to onPo
@@ -1250,33 +1250,34 @@
 or a Singleton t
-o
+he
  onPostConstruct
@@ -1824,20 +1824,21 @@
 r a 
-singleton to
+Prototype the
  onP
@@ -1868,33 +1868,59 @@
 t be called 
-only once
+every time, the Prototype is needed
 .%0A     */%0A  

Fix description