OperationHelper.doWithRetry(5, new Operation() { @Override public void doIt() { //do some stuff } @Override public void handleException(Exception cause) { //recover from the Exception } });
@Before public void setUp() { operation = new PathOperation(HttpMethod.GET, "/test", new Operation()); }
@Before public void setUp() { operation = new PathOperation(HttpMethod.GET, "/test", new Operation()); }
@Test public void testWithInterDocumentCrossReferencesAndPrefix() { Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withInterDocumentCrossReferences("prefix_") .build(); Swagger2MarkupConverter.Context context = createContext(config); context.setOutputPath(Paths.get("/tmp")); assertThat(new OperationDocumentNameResolver(context).apply(new PathOperation(HttpMethod.GET, "/test", new Operation()))) .isEqualTo("paths.adoc"); }
Operation op = new Operation();
public OperationGenerator(SwaggerGenerator swaggerGenerator, Method providerMethod) { this.swaggerGenerator = swaggerGenerator; this.swagger = swaggerGenerator.swagger; this.operation = new Operation(); this.providerMethod = providerMethod; this.context = swaggerGenerator.context; if (swagger.getParameters() != null) { methodAnnotationParameters.addAll(swagger.getParameters().values()); } }
Object before = Operation.parse(subBefore); // a more specific type, not Object Object after = Term.parse(subAfter); if (before != null && after != null) { return new Operation(before, after); }
Operation increaseSalary = new Operation() { public void run(SQLiteDatabase database) throws SQLiteException { // .... write the new increased salary to the database } };
. . Executor.runOperation(new Operation() { public void run(SQLiteDatabase database) throws SQLiteException { // put the increase salary database-code in here } }); . .
public Operation parseMethod(String httpMethod, Method method) { int responseCode = 200; Operation operation = new Operation(); ApiOperation apiOperation = AnnotationUtils.findAnnotation(method, ApiOperation.class);
private Operation parseMethod(Method method, RequestMethod requestMethod) { int responseCode = 200; Operation operation = new Operation();
public OperationGenerator(SwaggerGenerator swaggerGenerator, Method providerMethod) { this.swaggerGenerator = swaggerGenerator; this.swagger = swaggerGenerator.swagger; this.operation = new Operation(); this.providerMethod = providerMethod; this.context = swaggerGenerator.context; if (swagger.getParameters() != null) { methodAnnotationParameters.addAll(swagger.getParameters().values()); } }
Runnable onEnd = new Runnable(){ //code to run after the task has completed } Operation o = new Operation(onEnd); o.execute(params);
private io.swagger.models.Operation opCreateInstance(ServiceDocument doc) { io.swagger.models.Operation op = new io.swagger.models.Operation(); op.addTag(this.currentTag.getName()); op.setParameters(Collections.singletonList(paramBody(doc))); op.setResponses(responseMap( Operation.STATUS_CODE_OK, responseOk(doc) )); return op; }
private io.swagger.models.Operation opDefault(ServiceDocument doc) { io.swagger.models.Operation op = new io.swagger.models.Operation(); op.addTag(this.currentTag.getName()); op.setResponses(responseMap( Operation.STATUS_CODE_OK, responseOk(doc), Operation.STATUS_CODE_NOT_FOUND, responseGenericError() )); return op; }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription, final String expectedName, final String expectedDescription) { operation = new Operation().description(operationDescription).summary(operationSummary); swagger = new Swagger().path("/test", new Path().get(operation)); expected = new OperationDescription(expectedName, expectedDescription); }
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription, final String expectedName, final String expectedDescription) { operation = new Operation().description(operationDescription).summary(operationSummary); swagger = new Swagger().path("/test", new Path().get(operation)); expected = new OperationDescription(expectedName, expectedDescription); }