Line data Source code
1 : // Copyright (C) 2018 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.acceptance; 16 : 17 : import com.google.gerrit.entities.Project; 18 : import com.google.gerrit.index.QueryOptions; 19 : import com.google.gerrit.index.Schema; 20 : import com.google.gerrit.index.project.ProjectData; 21 : import com.google.gerrit.index.project.ProjectIndex; 22 : import com.google.gerrit.index.query.DataSource; 23 : import com.google.gerrit.index.query.Predicate; 24 : 25 : /** 26 : * This class wraps an index and assumes the search index can't handle any queries. However, it does 27 : * return the current schema as the assumption is that we need a search index for starting Gerrit in 28 : * the first place and only later lose the index connection (making it so that we can't send 29 : * requests there anymore). 30 : */ 31 : public class DisabledProjectIndex implements ProjectIndex { 32 : private final ProjectIndex index; 33 : 34 1 : public DisabledProjectIndex(ProjectIndex index) { 35 1 : this.index = index; 36 1 : } 37 : 38 : public ProjectIndex unwrap() { 39 1 : return index; 40 : } 41 : 42 : @Override 43 : public Schema<ProjectData> getSchema() { 44 1 : return index.getSchema(); 45 : } 46 : 47 : @Override 48 : public void close() { 49 0 : index.close(); 50 0 : } 51 : 52 : @Override 53 : public void insert(ProjectData obj) { 54 0 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 55 : } 56 : 57 : @Override 58 : public void replace(ProjectData obj) { 59 1 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 60 : } 61 : 62 : @Override 63 : public void delete(Project.NameKey key) { 64 0 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 65 : } 66 : 67 : @Override 68 : public void deleteAll() { 69 0 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 70 : } 71 : 72 : @Override 73 : public DataSource<ProjectData> getSource(Predicate<ProjectData> p, QueryOptions opts) { 74 0 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 75 : } 76 : 77 : @Override 78 : public void markReady(boolean ready) { 79 0 : throw new UnsupportedOperationException("ProjectIndex is disabled"); 80 : } 81 : }