1 /*
2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 de.smartics.maven.bugzilla.command;
17
18 import de.smartics.maven.issue.command.AbstractCommand.Expectation;
19 import de.smartics.maven.issue.command.CommandResult.Page;
20
21 /**
22 * Helper for Bugzilla commands.
23 */
24 final class BugzillaCommandUtils
25 {
26 // ********************************* Fields *********************************
27
28 // --- constants ------------------------------------------------------------
29
30 // --- members --------------------------------------------------------------
31
32 // ****************************** Initializer *******************************
33
34 // ****************************** Constructors ******************************
35
36 /**
37 * Utilits class.
38 */
39 private BugzillaCommandUtils()
40 {
41 }
42
43 // ****************************** Inner Classes *****************************
44
45 // ********************************* Methods ********************************
46
47 // --- init -----------------------------------------------------------------
48
49 // --- get&set --------------------------------------------------------------
50
51 // --- business -------------------------------------------------------------
52
53 static Expectation createExpectation(final Page page,
54 final String expectedPageTitleCreated,
55 final String expectedPageTitleExists)
56 {
57 final String actualTitle = page.getTitle();
58
59 boolean expected;
60 String expectationFlag;
61 final boolean created = expectedPageTitleCreated.equals(actualTitle);
62 if (!created)
63 {
64 expected = expectedPageTitleExists.equals(actualTitle);
65 if (expected)
66 {
67 expectationFlag = expectedPageTitleExists;
68 }
69 else
70 {
71 expectationFlag = Expectation.UNKNOWN_FLAG;
72 }
73 }
74 else
75 {
76 expected = true;
77 expectationFlag = expectedPageTitleCreated;
78 }
79
80 return new Expectation(expected, expectedPageTitleCreated + " or "
81 + expectedPageTitleExists, expectationFlag);
82 }
83
84 // --- object basics --------------------------------------------------------
85
86 }