Skip to main content
summaryrefslogtreecommitdiffstats
blob: c4dfa6d532418fb1c6cf41aac175726c04307622 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.resource.management.test.mocks;

import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.IResourceListener;
import org.eclipse.osee.framework.resource.management.IResourceLocator;
import org.eclipse.osee.framework.resource.management.Options;

/**
 * @author Roberto E. Escobar
 */
public class MockResourceListener implements IResourceListener {
   private boolean postAcquire;
   private boolean preAcquire;
   private boolean preSave;
   private boolean postSave;
   private boolean preDelete;
   private boolean postDelete;
   private IResource resource;
   private IResourceLocator locator;

   public MockResourceListener() {
      reset();
   }

   public void reset() {
      postAcquire = false;
      preAcquire = false;
      preSave = false;
      postSave = false;
      preDelete = false;
      postDelete = false;
      this.resource = null;
      this.locator = null;
   }

   @Override
   public void onPostAcquire(IResource resource) {
      postAcquire = true;
      this.resource = resource;
   }

   @Override
   public void onPreAcquire(IResourceLocator locator) {
      preAcquire = true;
      this.locator = locator;
   }

   @Override
   public void onPostDelete(IResourceLocator locator) {
      postDelete = true;
      this.locator = locator;
   }

   @Override
   public void onPostSave(IResourceLocator locator, IResource resource, Options options) {
      postSave = true;
      this.resource = resource;
   }

   @Override
   public void onPreDelete(IResourceLocator locator) {
      preDelete = true;
      this.locator = locator;
   }

   @Override
   public void onPreSave(IResourceLocator locator, IResource resource, Options options) {
      preSave = true;
      this.locator = locator;
   }

   public boolean isPostAcquire() {
      return postAcquire;
   }

   public boolean isPreAcquire() {
      return preAcquire;
   }

   public boolean isPreSave() {
      return preSave;
   }

   public boolean isPostSave() {
      return postSave;
   }

   public boolean isPreDelete() {
      return preDelete;
   }

   public boolean isPostDelete() {
      return postDelete;
   }

   public IResource getResource() {
      return resource;
   }

   public IResourceLocator getLocator() {
      return locator;
   }
}

Back to the top