View Javadoc

1   /**
2    * Copyright 2013 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   *
15   * Created by Mezba Mahtab (mezba.mahtab@utoronto.ca) on 3/11/13
16   */
17  package org.kuali.student.mock.mojo;
18  
19  import org.kuali.student.contract.model.ServiceContractModel;
20  import org.kuali.student.contract.model.ServiceMethod;
21  import org.kuali.student.contract.model.impl.ServiceContractModelPescXsdLoader;
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  import java.util.List;
26  
27  /**
28   * This class writes the conformance test for one service.
29   *
30   * @author Mezba Mahtab (mezba.mahtab@utoronto.ca)
31   */
32  public class ConformanceTestWriterForOneService extends MockImplWriterForOneService {
33      
34      private static Logger log = LoggerFactory.getLogger(ConformanceTestWriterForOneService.class);
35  
36      /////////////////////////////
37      // CONSTRUCTOR
38      /////////////////////////////
39  
40      public ConformanceTestWriterForOneService
41              (ServiceContractModel model,
42               String directory,
43               String rootPackage,
44               String servKey,
45               boolean isR1) {
46          super (model, directory, rootPackage, servKey, isR1);
47      }
48  
49      ////////////////////////
50      // FUNCTIONAL
51      ////////////////////////
52  
53      /**
54       * Write out the entire file
55       */
56      public void write() {
57          List<ServiceMethod> methods = finder.getServiceMethodsInService(servKey);
58          if (methods.size() == 0) {
59              log.warn("No methods defined for servKey: " + servKey);
60              return;
61          }
62  
63          // the main servKey
64          log.info("Generating Conformance Tests for " + servKey);
65          new ConformanceTestBaseCrudClassServiceWriter(model, directory, rootPackage, servKey, methods, isR1).write();
66          new ConformanceTestExtendedCrudClassServiceWriter(model, directory, rootPackage, servKey, methods, isR1).write();
67      }
68  }