001    /**
002     * Copyright 2013 The Kuali Foundation Licensed under the
003     * Educational Community License, Version 2.0 (the "License"); you may
004     * not use this file except in compliance with the License. You may
005     * obtain a copy of the License at
006     *
007     * http://www.osedu.org/licenses/ECL-2.0
008     *
009     * Unless required by applicable law or agreed to in writing,
010     * software distributed under the License is distributed on an "AS IS"
011     * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012     * or implied. See the License for the specific language governing
013     * permissions and limitations under the License.
014     *
015     * Created by Mezba Mahtab (mezba.mahtab@utoronto.ca) on 3/11/13
016     */
017    package org.kuali.student.mock.mojo;
018    
019    import org.kuali.student.contract.model.Service;
020    import org.kuali.student.contract.model.ServiceContractModel;
021    import org.kuali.student.contract.model.util.ServicesFilter;
022    import org.slf4j.Logger;
023    import org.slf4j.LoggerFactory;
024    
025    /**
026     * This class writers the conformance tests for service
027     *
028     * @author Mezba Mahtab (mezba.mahtab@utoronto.ca)
029     */
030    public class ConformanceTestWriter extends MockImplWriter {
031    
032        private static final Logger log = LoggerFactory.getLogger(ConformanceTestWriter.class);
033        
034        ///////////////////////
035        // CONSTRUCTOR
036        ///////////////////////
037    
038        public ConformanceTestWriter(ServiceContractModel model, String directory, String rootPackage, ServicesFilter filter, boolean isR1) {
039            super (model, directory, rootPackage, filter, isR1);
040        }
041    
042        ////////////////////////
043        // FUNCTIONAL
044        ////////////////////////
045    
046        /**
047         * Write out the entire file
048         */
049        public void write() {
050            this.validate();
051            for (Service service : filterServices()) {
052                log.info ("************** generating conformance test for service = " + service.getKey() + " **************");
053                
054                try {
055                    new ConformanceTestWriterForOneService(model, directory, rootPackage, service.getKey(), isR1).write();
056                } catch (Exception e) {
057                    log.error ("Failed to generate conformance test for service = " + service.getKey(), e);
058                }
059            }
060        }
061    
062    }