/** * Return the list of API versions for all reachable API methods. */ public static List<String> getReachableRestVersions(Model model) { Set<String> versions = Sets.newLinkedHashSet(); for (Interface iface : model.getSymbolTable().getInterfaces()) { for (Method method : iface.getReachableMethods()) { if (method.hasAttribute(HttpAttribute.KEY)) { for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { versions.add(binding.getRestMethod().getVersionWithDefault()); } } } } List<String> versionsList = Lists.newArrayList(versions); Collections.sort(versionsList, Collections.reverseOrder(new VersionComparator())); return versionsList; } }
/** * Return the list of API versions for all reachable API methods. */ public static List<String> getReachableRestVersions(Model model) { Set<String> versions = Sets.newLinkedHashSet(); for (Interface iface : model.getSymbolTable().getInterfaces()) { for (Method method : iface.getReachableMethods()) { if (method.hasAttribute(HttpAttribute.KEY)) { for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { versions.add(binding.getRestMethod().getVersionWithDefault()); } } } } List<String> versionsList = Lists.newArrayList(versions); Collections.sort(versionsList, Collections.reverseOrder(new VersionComparator())); return versionsList; } }
@BeforeClass public static void setupClass() { List<String> protoFiles = Lists.newArrayList("myproto.proto"); List<String> yamlFiles = Lists.newArrayList("myproto.yaml"); testDataLocator = TestDataLocator.create(SampleInitCodeTest.class); testConfig = new TestConfig(testDataLocator, tempDir.getRoot().getPath(), protoFiles); model = testConfig.createModel(yamlFiles); StandardSetup.registerStandardProcessors(model); StandardSetup.registerStandardConfigAspects(model); model.establishStage(Merged.KEY); apiInterface = model.getSymbolTable().getInterfaces().asList().get(0); method = apiInterface.getMethods().get(0); }
@BeforeClass public static void setupClass() { TestDataLocator locator = TestDataLocator.create(GoGapicSurfaceTransformerTest.class); model = CodegenTestUtil.readModel( locator, tempDir, new String[] {"myproto.proto", "singleservice.proto"}, new String[] {"myproto.yaml"}); for (Interface apiInterface : model.getSymbolTable().getInterfaces()) { if (apiInterface.getSimpleName().equals("Gopher")) { GoGapicSurfaceTransformerTest.apiInterface = apiInterface; break; } } ConfigProto configProto = CodegenTestUtil.readConfig( model.getDiagReporter().getDiagCollector(), locator, new String[] {"myproto_gapic.yaml"}); productConfig = GapicProductConfig.create(model, configProto, TargetLanguage.GO); if (model.getDiagReporter().getDiagCollector().hasErrors()) { throw new IllegalStateException( model.getDiagReporter().getDiagCollector().getDiags().toString()); } }