Skip to content

Commit dd58025

Browse files
authored
feat: stub implementation of StorageRpc for the sake of testing (#351)
* feat: stub implementation of StorageRpc which could be used outside of the storage module for testing purposes * feat: stub implementation of StorageRpc which could be used outside of the storage module for testing purposes * feat: stub implementation of StorageRpc which could be used outside of the storage module for testing purposes
1 parent 1a0cefc commit dd58025

File tree

2 files changed

+893
-0
lines changed

2 files changed

+893
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
/*
2+
* Copyright 2020 Google LLC
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+
17+
package com.google.cloud.storage.testing;
18+
19+
import com.google.api.services.storage.model.Bucket;
20+
import com.google.api.services.storage.model.BucketAccessControl;
21+
import com.google.api.services.storage.model.HmacKey;
22+
import com.google.api.services.storage.model.HmacKeyMetadata;
23+
import com.google.api.services.storage.model.Notification;
24+
import com.google.api.services.storage.model.ObjectAccessControl;
25+
import com.google.api.services.storage.model.Policy;
26+
import com.google.api.services.storage.model.ServiceAccount;
27+
import com.google.api.services.storage.model.StorageObject;
28+
import com.google.api.services.storage.model.TestIamPermissionsResponse;
29+
import com.google.cloud.Tuple;
30+
import com.google.cloud.storage.spi.v1.RpcBatch;
31+
import com.google.cloud.storage.spi.v1.StorageRpc;
32+
import java.io.InputStream;
33+
import java.io.OutputStream;
34+
import java.util.List;
35+
import java.util.Map;
36+
37+
/**
38+
* A stub implementation of {@link StorageRpc} which can be used outside of the Storage module for
39+
* testing purposes. All the methods throw an {@code UnsupportedOperationException}.
40+
*/
41+
public class StorageRpcTestBase implements StorageRpc {
42+
43+
@Override
44+
public Bucket create(Bucket bucket, Map<Option, ?> options) {
45+
throw new UnsupportedOperationException("Not implemented yet");
46+
}
47+
48+
@Override
49+
public StorageObject create(StorageObject object, InputStream content, Map<Option, ?> options) {
50+
throw new UnsupportedOperationException("Not implemented yet");
51+
}
52+
53+
@Override
54+
public Tuple<String, Iterable<Bucket>> list(Map<Option, ?> options) {
55+
throw new UnsupportedOperationException("Not implemented yet");
56+
}
57+
58+
@Override
59+
public Tuple<String, Iterable<StorageObject>> list(String bucket, Map<Option, ?> options) {
60+
throw new UnsupportedOperationException("Not implemented yet");
61+
}
62+
63+
@Override
64+
public Bucket get(Bucket bucket, Map<Option, ?> options) {
65+
throw new UnsupportedOperationException("Not implemented yet");
66+
}
67+
68+
@Override
69+
public StorageObject get(StorageObject object, Map<Option, ?> options) {
70+
throw new UnsupportedOperationException("Not implemented yet");
71+
}
72+
73+
@Override
74+
public Bucket patch(Bucket bucket, Map<Option, ?> options) {
75+
throw new UnsupportedOperationException("Not implemented yet");
76+
}
77+
78+
@Override
79+
public StorageObject patch(StorageObject storageObject, Map<Option, ?> options) {
80+
throw new UnsupportedOperationException("Not implemented yet");
81+
}
82+
83+
@Override
84+
public boolean delete(Bucket bucket, Map<Option, ?> options) {
85+
throw new UnsupportedOperationException("Not implemented yet");
86+
}
87+
88+
@Override
89+
public boolean delete(StorageObject object, Map<Option, ?> options) {
90+
throw new UnsupportedOperationException("Not implemented yet");
91+
}
92+
93+
@Override
94+
public RpcBatch createBatch() {
95+
throw new UnsupportedOperationException("Not implemented yet");
96+
}
97+
98+
@Override
99+
public StorageObject compose(
100+
Iterable<StorageObject> sources, StorageObject target, Map<Option, ?> targetOptions) {
101+
throw new UnsupportedOperationException("Not implemented yet");
102+
}
103+
104+
@Override
105+
public byte[] load(StorageObject storageObject, Map<Option, ?> options) {
106+
throw new UnsupportedOperationException("Not implemented yet");
107+
}
108+
109+
@Override
110+
public Tuple<String, byte[]> read(
111+
StorageObject from, Map<Option, ?> options, long position, int bytes) {
112+
throw new UnsupportedOperationException("Not implemented yet");
113+
}
114+
115+
@Override
116+
public long read(
117+
StorageObject from, Map<Option, ?> options, long position, OutputStream outputStream) {
118+
throw new UnsupportedOperationException("Not implemented yet");
119+
}
120+
121+
@Override
122+
public String open(StorageObject object, Map<Option, ?> options) {
123+
throw new UnsupportedOperationException("Not implemented yet");
124+
}
125+
126+
@Override
127+
public String open(String signedURL) {
128+
throw new UnsupportedOperationException("Not implemented yet");
129+
}
130+
131+
@Override
132+
public void write(
133+
String uploadId,
134+
byte[] toWrite,
135+
int toWriteOffset,
136+
long destOffset,
137+
int length,
138+
boolean last) {
139+
throw new UnsupportedOperationException("Not implemented yet");
140+
}
141+
142+
@Override
143+
public RewriteResponse openRewrite(RewriteRequest rewriteRequest) {
144+
throw new UnsupportedOperationException("Not implemented yet");
145+
}
146+
147+
@Override
148+
public RewriteResponse continueRewrite(RewriteResponse previousResponse) {
149+
throw new UnsupportedOperationException("Not implemented yet");
150+
}
151+
152+
@Override
153+
public BucketAccessControl getAcl(String bucket, String entity, Map<Option, ?> options) {
154+
throw new UnsupportedOperationException("Not implemented yet");
155+
}
156+
157+
@Override
158+
public boolean deleteAcl(String bucket, String entity, Map<Option, ?> options) {
159+
throw new UnsupportedOperationException("Not implemented yet");
160+
}
161+
162+
@Override
163+
public BucketAccessControl createAcl(BucketAccessControl acl, Map<Option, ?> options) {
164+
throw new UnsupportedOperationException("Not implemented yet");
165+
}
166+
167+
@Override
168+
public BucketAccessControl patchAcl(BucketAccessControl acl, Map<Option, ?> options) {
169+
throw new UnsupportedOperationException("Not implemented yet");
170+
}
171+
172+
@Override
173+
public List<BucketAccessControl> listAcls(String bucket, Map<Option, ?> options) {
174+
throw new UnsupportedOperationException("Not implemented yet");
175+
}
176+
177+
@Override
178+
public ObjectAccessControl getDefaultAcl(String bucket, String entity) {
179+
throw new UnsupportedOperationException("Not implemented yet");
180+
}
181+
182+
@Override
183+
public boolean deleteDefaultAcl(String bucket, String entity) {
184+
throw new UnsupportedOperationException("Not implemented yet");
185+
}
186+
187+
@Override
188+
public ObjectAccessControl createDefaultAcl(ObjectAccessControl acl) {
189+
throw new UnsupportedOperationException("Not implemented yet");
190+
}
191+
192+
@Override
193+
public ObjectAccessControl patchDefaultAcl(ObjectAccessControl acl) {
194+
throw new UnsupportedOperationException("Not implemented yet");
195+
}
196+
197+
@Override
198+
public List<ObjectAccessControl> listDefaultAcls(String bucket) {
199+
throw new UnsupportedOperationException("Not implemented yet");
200+
}
201+
202+
@Override
203+
public ObjectAccessControl getAcl(String bucket, String object, Long generation, String entity) {
204+
throw new UnsupportedOperationException("Not implemented yet");
205+
}
206+
207+
@Override
208+
public boolean deleteAcl(String bucket, String object, Long generation, String entity) {
209+
throw new UnsupportedOperationException("Not implemented yet");
210+
}
211+
212+
@Override
213+
public ObjectAccessControl createAcl(ObjectAccessControl acl) {
214+
throw new UnsupportedOperationException("Not implemented yet");
215+
}
216+
217+
@Override
218+
public ObjectAccessControl patchAcl(ObjectAccessControl acl) {
219+
throw new UnsupportedOperationException("Not implemented yet");
220+
}
221+
222+
@Override
223+
public List<ObjectAccessControl> listAcls(String bucket, String object, Long generation) {
224+
throw new UnsupportedOperationException("Not implemented yet");
225+
}
226+
227+
@Override
228+
public HmacKey createHmacKey(String serviceAccountEmail, Map<Option, ?> options) {
229+
throw new UnsupportedOperationException("Not implemented yet");
230+
}
231+
232+
@Override
233+
public Tuple<String, Iterable<HmacKeyMetadata>> listHmacKeys(Map<Option, ?> options) {
234+
throw new UnsupportedOperationException("Not implemented yet");
235+
}
236+
237+
@Override
238+
public HmacKeyMetadata updateHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<Option, ?> options) {
239+
throw new UnsupportedOperationException("Not implemented yet");
240+
}
241+
242+
@Override
243+
public HmacKeyMetadata getHmacKey(String accessId, Map<Option, ?> options) {
244+
throw new UnsupportedOperationException("Not implemented yet");
245+
}
246+
247+
@Override
248+
public void deleteHmacKey(HmacKeyMetadata hmacKeyMetadata, Map<Option, ?> options) {
249+
throw new UnsupportedOperationException("Not implemented yet");
250+
}
251+
252+
@Override
253+
public Policy getIamPolicy(String bucket, Map<Option, ?> options) {
254+
throw new UnsupportedOperationException("Not implemented yet");
255+
}
256+
257+
@Override
258+
public Policy setIamPolicy(String bucket, Policy policy, Map<Option, ?> options) {
259+
throw new UnsupportedOperationException("Not implemented yet");
260+
}
261+
262+
@Override
263+
public TestIamPermissionsResponse testIamPermissions(
264+
String bucket, List<String> permissions, Map<Option, ?> options) {
265+
throw new UnsupportedOperationException("Not implemented yet");
266+
}
267+
268+
@Override
269+
public boolean deleteNotification(String bucket, String notification) {
270+
throw new UnsupportedOperationException("Not implemented yet");
271+
}
272+
273+
@Override
274+
public List<Notification> listNotifications(String bucket) {
275+
throw new UnsupportedOperationException("Not implemented yet");
276+
}
277+
278+
@Override
279+
public Notification createNotification(String bucket, Notification notification) {
280+
throw new UnsupportedOperationException("Not implemented yet");
281+
}
282+
283+
@Override
284+
public Bucket lockRetentionPolicy(Bucket bucket, Map<Option, ?> options) {
285+
throw new UnsupportedOperationException("Not implemented yet");
286+
}
287+
288+
@Override
289+
public ServiceAccount getServiceAccount(String projectId) {
290+
throw new UnsupportedOperationException("Not implemented yet");
291+
}
292+
}

0 commit comments

Comments
 (0)