Clover coverage report - Maven Clover report
Coverage timestamp: Sun Mar 18 2007 17:42:32 CET
file stats: LOC: 112   Methods: 13
NCLOC: 88   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SectionManagerService.java 100% 100% 100% 100%
coverage
 1    package com.agical.rmock.core.expectation.section.service;
 2   
 3    import java.util.HashMap;
 4    import java.util.Map;
 5    import java.util.Stack;
 6   
 7    import com.agical.rmock.core.Section;
 8    import com.agical.rmock.core.SectionManager;
 9    import com.agical.rmock.core.SectionProvider;
 10    import com.agical.rmock.core.Verifiable;
 11    import com.agical.rmock.core.event.TestCaseListener;
 12    import com.agical.rmock.core.exception.EndSectionException;
 13    import com.agical.rmock.core.exception.IdMustBeUniqueException;
 14    import com.agical.rmock.core.exception.NoSuchSectionException;
 15    import com.agical.rmock.core.exception.UnclosedSectionException;
 16    import com.agical.rmock.core.expectation.section.AnyOrderSection;
 17    import com.agical.rmock.core.expectation.section.OverridableSection;
 18    import com.agical.rmock.core.expectation.section.StackedSection;
 19   
 20    public class SectionManagerService implements SectionManager, SectionProvider, Verifiable, TestCaseListener {
 21    private static final String DEFAULTS_ID = "defaults";
 22    private static final String MAIN_ID = "main";
 23    private Map descriptionToSection;
 24    private OverridableSection rootSection;
 25    private Stack sectionStack;
 26    private Object stackedSectionWrapper;
 27   
 28  37 public SectionManagerService() {
 29  37 init();
 30    }
 31   
 32  586 private void init() {
 33  586 descriptionToSection = new HashMap();
 34  586 rootSection = new OverridableSection(new AnyOrderSection( "root" ));
 35  586 Section mainSection = new OverridableSection(new AnyOrderSection( MAIN_ID ));
 36  586 Section defaultSection = new OverridableSection(new AnyOrderSection( DEFAULTS_ID ));
 37   
 38  586 rootSection.add(mainSection);
 39  586 rootSection.add(defaultSection);
 40   
 41  586 descriptionToSection.put(MAIN_ID, mainSection);
 42  586 descriptionToSection.put(DEFAULTS_ID, defaultSection);
 43   
 44   
 45   
 46  586 sectionStack = new Stack();
 47  586 sectionStack.push( mainSection );
 48  586 stackedSectionWrapper = new StackedSection(this );
 49    }
 50   
 51  78 public void beginSection(Section section) {
 52  78 if(descriptionToSection.containsKey(section.getDescription())) {
 53  1 throw new IdMustBeUniqueException("section", section.getDescription());
 54    }
 55  77 OverridableSection overridableSection = new OverridableSection(section);
 56  77 getCurrentSection().add( overridableSection );
 57  77 descriptionToSection.put(section.getDescription(), overridableSection);
 58  77 sectionStack.push( overridableSection );
 59    }
 60   
 61  86 public void endSection() {
 62  86 if( sectionStack.size() == 1 ) {
 63  1 throw new EndSectionException( "All endable sections are already ended" );
 64    }
 65  85 sectionStack.pop( );
 66    }
 67   
 68  825 public Section getCurrentSection() {
 69  825 return (Section) sectionStack.peek();
 70    }
 71   
 72  539 public void beginVerify() {
 73  539 if( sectionStack.size() != 1 ) {
 74  1 throw new UnclosedSectionException( sectionStack );
 75    }
 76    }
 77   
 78  1068 public void endVerify() {
 79   
 80    }
 81   
 82  549 public void beforeTestCase(Object testInstance, String testName) {
 83  549 init();
 84    }
 85   
 86  548 public void afterTestCase() {
 87   
 88    }
 89   
 90  1619 public Section getRootSection() {
 91  1619 return rootSection;
 92    }
 93   
 94  2 public void overrideSection(String id, Section section) {
 95  2 OverridableSection overridableSection = focusSectionById(id);
 96  1 overridableSection.overrideWith(section);
 97    }
 98   
 99  14 private OverridableSection focusSectionById(String id) {
 100  14 OverridableSection overridableSection = (OverridableSection) descriptionToSection.get(id);
 101  14 if (overridableSection == null) {
 102  1 throw new NoSuchSectionException(id);
 103    }
 104  13 sectionStack.push(overridableSection);
 105  13 return overridableSection;
 106    }
 107   
 108  12 public void extendSection(String sectionToExtend) {
 109  12 focusSectionById(sectionToExtend);
 110    }
 111   
 112    }