Gridarta Editor
TestErrorView.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.errorview;
21 
22 import org.apache.log4j.Category;
23 import org.apache.log4j.Logger;
24 import org.jetbrains.annotations.NotNull;
25 
30 public class TestErrorView implements ErrorView {
31 
35  @NotNull
36  private static final Category LOG = Logger.getLogger(TestErrorView.class);
37 
41  private boolean hasErrors;
42 
46  private boolean hasWarnings;
47 
48  @Override
49  public void addError(@NotNull final ErrorViewCategory categoryName, @NotNull final String message) {
50  hasErrors = true;
51  if (LOG.isInfoEnabled()) {
52  LOG.info("addError: " + categoryName + " " + message);
53  }
54  }
55 
56  @Override
57  public void addError(@NotNull final ErrorViewCategory categoryName, final int lineNo, @NotNull final String message) {
58  hasErrors = true;
59  if (LOG.isInfoEnabled()) {
60  LOG.info("addError: " + categoryName + " " + lineNo + " " + message);
61  }
62  }
63 
64  @Override
65  public void addWarning(@NotNull final ErrorViewCategory categoryName, @NotNull final String message) {
66  hasWarnings = true;
67  if (LOG.isInfoEnabled()) {
68  LOG.info("addWarning: " + categoryName + " " + message);
69  }
70  }
71 
72  @Override
73  public void addWarning(@NotNull final ErrorViewCategory categoryName, final int lineNo, @NotNull final String message) {
74  hasWarnings = true;
75  if (LOG.isInfoEnabled()) {
76  LOG.info("addWarning: " + categoryName + " " + lineNo + " " + message);
77  }
78  }
79 
80  @Override
81  public boolean hasErrors() {
82  return hasErrors;
83  }
84 
89  public boolean hasWarnings() {
90  return hasWarnings;
91  }
92 
93  @Override
94  public void waitDialog() {
95  throw new AssertionError();
96  }
97 
98 }
net.sf.gridarta.model.errorview.TestErrorView.addError
void addError(@NotNull final ErrorViewCategory categoryName, final int lineNo, @NotNull final String message)
Adds an error message.
Definition: TestErrorView.java:57
net.sf.gridarta.model.errorview.TestErrorView.hasErrors
boolean hasErrors()
Whether at least one error message has been added.
Definition: TestErrorView.java:81
net.sf.gridarta.model.errorview.TestErrorView.hasErrors
boolean hasErrors
Whether errors have been collected.
Definition: TestErrorView.java:41
net.sf.gridarta.model.errorview.ErrorView
Interface for classes displaying error messages.
Definition: ErrorView.java:28
net.sf.gridarta.model.errorview.TestErrorView.waitDialog
void waitDialog()
Waits until the dialog has been dismissed.
Definition: TestErrorView.java:94
net.sf.gridarta.model.errorview.TestErrorView.hasWarnings
boolean hasWarnings()
Returns whether at least one warning message has been added.
Definition: TestErrorView.java:89
net.sf.gridarta.model.errorview.ErrorViewCategory
Defines possible error categories for ErrorView instances.
Definition: ErrorViewCategory.java:28
net.sf.gridarta.model.errorview.TestErrorView
An ErrorView suitable for unit tests.
Definition: TestErrorView.java:30
net.sf.gridarta.model.errorview.TestErrorView.LOG
static final Category LOG
The Logger for printing log messages.
Definition: TestErrorView.java:36
net.sf.gridarta.model.errorview.TestErrorView.addWarning
void addWarning(@NotNull final ErrorViewCategory categoryName, @NotNull final String message)
Adds a warning message.
Definition: TestErrorView.java:65
net.sf.gridarta.model.errorview.TestErrorView.addWarning
void addWarning(@NotNull final ErrorViewCategory categoryName, final int lineNo, @NotNull final String message)
Adds a warning message.
Definition: TestErrorView.java:73
net.sf.gridarta.model.errorview.TestErrorView.hasWarnings
boolean hasWarnings
Whether warnings have been collected.
Definition: TestErrorView.java:46
net.sf.gridarta.model.errorview.TestErrorView.addError
void addError(@NotNull final ErrorViewCategory categoryName, @NotNull final String message)
Adds an error message.
Definition: TestErrorView.java:49