View Javadoc
1   /*
2    * Copyright (C) 2016 uwe
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.sw4j.tool.annotation.jpa.test.mock.annotation.processing;
18  
19  import java.util.HashMap;
20  import java.util.Locale;
21  import java.util.Map;
22  import javax.annotation.processing.Filer;
23  import javax.annotation.processing.Messager;
24  import javax.annotation.processing.ProcessingEnvironment;
25  import javax.lang.model.SourceVersion;
26  import javax.lang.model.util.Elements;
27  import javax.lang.model.util.Types;
28  
29  /**
30   * A mock for the processing environment.
31   *
32   * @author Uwe Plonus
33   */
34  public class ProcessingEnvironmentMock implements ProcessingEnvironment {
35  
36      private final Map<String, String> options;
37  
38      private final Messager messager;
39  
40      private final Types types;
41  
42      public ProcessingEnvironmentMock() {
43          this(new HashMap<String, String>(), new MessagerMock(), null);
44      }
45  
46      public ProcessingEnvironmentMock(final Messager messager, final Types types) {
47          this(new HashMap<String, String>(), messager, types);
48      }
49  
50      public ProcessingEnvironmentMock(final Map<String, String> options, final Messager messager) {
51          this(options, messager, null);
52      }
53  
54      public ProcessingEnvironmentMock(final Map<String, String> options, final Messager messager, final Types types) {
55          this.options = options;
56          this.messager = messager;
57          this.types = types;
58      }
59  
60      @Override
61      public Map<String, String> getOptions() {
62          return this.options;
63      }
64  
65      @Override
66      public Messager getMessager() {
67          return messager;
68      }
69  
70      @Override
71      public Filer getFiler() {
72          throw new UnsupportedOperationException("Not supported yet.");
73      }
74  
75      @Override
76      public Elements getElementUtils() {
77          throw new UnsupportedOperationException("Not supported yet.");
78      }
79  
80      @Override
81      public Types getTypeUtils() {
82          return this.types;
83      }
84  
85      @Override
86      public SourceVersion getSourceVersion() {
87          throw new UnsupportedOperationException("Not supported yet.");
88      }
89  
90      @Override
91      public Locale getLocale() {
92          throw new UnsupportedOperationException("Not supported yet.");
93      }
94  
95  }