source: josm/trunk/test/unit/org/openstreetmap/josm/testutils/mockers/BaseDialogMockUp.java@ 17275

Last change on this file since 17275 was 14355, checked in by Don-vip, 5 years ago

fix #16865 - UploadDialogTest: fix for non-headless mode (patch by ris, modified). Probably IUploadDialog should die

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.testutils.mockers;
3
4import java.util.ArrayList;
5import java.util.Collections;
6import java.util.HashMap;
7import java.util.List;
8import java.util.Map;
9
10import mockit.MockUp;
11
12/**
13 * Abstract class implementing the few common features of the dialog-mockers which are readily factorable.
14 * @param <T> type
15 */
16abstract class BaseDialogMockUp<T> extends MockUp<T> {
17 private final List<Object[]> invocationLog;
18
19 /**
20 * @return an unmodifiable view of the internal invocation log. Each entry is an array of Objects to
21 * allow for more advanced implementations to be able to express their invocations in their own
22 * ways. Typically the invocation's "result value" is used as the first element of the array.
23 */
24 public List<Object[]> getInvocationLog() {
25 return this.invocationLog;
26 }
27
28 /**
29 * Empties the invocation log.
30 */
31 public void resetInvocationLog() {
32 this.invocationLogInternal.clear();
33 }
34
35 private final List<Object[]> invocationLogInternal = new ArrayList<>(4);
36
37 /**
38 * @return the actual (writable) invocation log
39 */
40 protected List<Object[]> getInvocationLogInternal() {
41 return this.invocationLogInternal;
42 }
43
44 private final Map<String, Object> mockResultMap;
45
46 /**
47 * @return mapping to {@link Object}s so response button can be specified by String (label) or Integer
48 * - sorry, no type safety as java doesn't support union types
49 */
50 public Map<String, Object> getMockResultMap() {
51 return this.mockResultMap;
52 }
53
54 BaseDialogMockUp(final Map<String, Object> mockResultMap) {
55 this.mockResultMap = mockResultMap != null ? mockResultMap : new HashMap<>(4);
56 this.invocationLog = Collections.unmodifiableList(this.invocationLogInternal);
57 }
58}
Note: See TracBrowser for help on using the repository browser.