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