Line data Source code
1 : // Copyright (C) 2019 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.rest; 16 : 17 : import static com.google.gerrit.acceptance.rest.PluginResource.PLUGIN_KIND; 18 : import static com.google.gerrit.server.config.ConfigResource.CONFIG_KIND; 19 : 20 : import com.google.gerrit.extensions.annotations.Exports; 21 : import com.google.gerrit.extensions.config.CapabilityDefinition; 22 : import com.google.gerrit.extensions.registration.DynamicMap; 23 : import com.google.gerrit.extensions.restapi.RestApiModule; 24 : import com.google.inject.AbstractModule; 25 : 26 1 : public class TestPluginModule extends AbstractModule { 27 : 28 : public static final String PLUGIN_CAPABILITY = "printHello"; 29 : public static final String PLUGIN_COLLECTION = "foo"; 30 : 31 : @Override 32 : protected void configure() { 33 1 : bind(CapabilityDefinition.class) 34 1 : .annotatedWith(Exports.named(PLUGIN_CAPABILITY)) 35 1 : .toInstance( 36 1 : new CapabilityDefinition() { 37 : @Override 38 : public String getDescription() { 39 1 : return "Print Hello"; 40 : } 41 : }); 42 : 43 1 : install( 44 1 : new RestApiModule() { 45 : @Override 46 : protected void configure() { 47 1 : DynamicMap.mapOf(binder(), PLUGIN_KIND); 48 1 : child(CONFIG_KIND, PLUGIN_COLLECTION).to(PluginCollection.class); 49 1 : get(PLUGIN_KIND).to(GetTestPlugin.class); 50 1 : create(PLUGIN_KIND).to(CreateTestPlugin.class); 51 1 : } 52 : }); 53 1 : } 54 : }