View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.creadur.whisker.model;
20  
21  import java.util.Collection;
22  import java.util.Collections;
23  
24  public class LicenseBuilderForTesting {
25  
26      private static final String DEFAULT_PRIMARY_TEXT = "License text for the primary license.";
27      public static final String DEFAULT_PRIMARY_URL = "http://primary.example.org";
28      public static final String DEFAULT_PRIMARY_NAME = "Primary License";
29      public static final String DEFAULT_PRIMARY_ID = "primary.example.org";
30      public static final String DEFAULT_NAME = "Example License";
31      public static final String DEFAULT_URL = "http://example.org";
32      public static final String DEFAULT_ID = "example.org";
33      public static final String DEFAULT_LICENSE_TEXT = "This is the license text";
34  
35      public static License defaultPrimaryLicense() {
36          return new LicenseBuilderForTesting()
37              .withId(DEFAULT_PRIMARY_ID)
38              .withName(DEFAULT_PRIMARY_NAME)
39              .withUrl(DEFAULT_PRIMARY_URL)
40              .withText(DEFAULT_PRIMARY_TEXT)
41              .build();
42      }
43  
44      boolean isSourceRequired = false;
45      String baseText = DEFAULT_LICENSE_TEXT;
46      Collection<String> expectedParameters = Collections.<String> emptyList();
47      String id = DEFAULT_ID;
48      String url = DEFAULT_URL;
49      String name = DEFAULT_NAME;
50  
51      public License build() {
52          return new License(isSourceRequired, baseText, expectedParameters, id, url, name);
53      }
54  
55      public LicenseBuilderForTesting withId(String id) {
56          this.id = id;
57          return this;
58      }
59  
60      public LicenseBuilderForTesting withUrl(String url) {
61          this.url = url;
62          return this;
63      }
64  
65      public LicenseBuilderForTesting withName(String name) {
66          this.name = name;
67          return this;
68      }
69  
70      public LicenseBuilderForTesting withText(String baseText) {
71          this.baseText = baseText;
72          return this;
73      }
74  }