Java Code Examples for com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder#jsonResponse()

The following examples show how to use com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder#jsonResponse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
        final FileSource files, final Parameters parameters) {
    final String subject = Iterables.get(this.urlSplitter.split(request.getUrl()), 1);
    try {
        final int id = SchemaRegistryMock.this.register(subject,
                new Schema.Parser()
                        .parse(RegisterSchemaRequest.fromJson(request.getBodyAsString()).getSchema()));
        final RegisterSchemaResponse registerSchemaResponse = new RegisterSchemaResponse();
        registerSchemaResponse.setId(id);
        return ResponseDefinitionBuilder.jsonResponse(registerSchemaResponse);
    } catch (final IOException e) {
        throw new IllegalArgumentException("Cannot parse schema registration request", e);
    }
}
 
Example 2
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
        final FileSource files, final Parameters parameters) {
    final List<Integer> versions = SchemaRegistryMock.this.listVersions(this.getSubject(request));
    log.debug("Got versions {}", versions);
    return ResponseDefinitionBuilder.jsonResponse(versions);
}
 
Example 3
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
        final FileSource files, final Parameters parameters) {
    final String versionStr = Iterables.get(this.urlSplitter.split(request.getUrl()), 3);
    final SchemaMetadata metadata;
    if (versionStr.equals("latest")) {
        metadata = SchemaRegistryMock.this.getSubjectVersion(this.getSubject(request), versionStr);
    } else {
        final int version = Integer.parseInt(versionStr);
        metadata = SchemaRegistryMock.this.getSubjectVersion(this.getSubject(request), version);
    }
    return ResponseDefinitionBuilder.jsonResponse(metadata);
}
 
Example 4
Source File: SchemaRegistryMock.java    From schema-registry-transfer-smt with Apache License 2.0 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
                                    final FileSource files, final Parameters parameters) {
    try {
        final int id = SchemaRegistryMock.this.register(getSubject(request),
                new Schema.Parser()
                        .parse(RegisterSchemaRequest.fromJson(request.getBodyAsString()).getSchema()));
        final RegisterSchemaResponse registerSchemaResponse = new RegisterSchemaResponse();
        registerSchemaResponse.setId(id);
        return ResponseDefinitionBuilder.jsonResponse(registerSchemaResponse);
    } catch (final IOException e) {
        throw new IllegalArgumentException("Cannot parse schema registration request", e);
    }
}
 
Example 5
Source File: SchemaRegistryMock.java    From schema-registry-transfer-smt with Apache License 2.0 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
                                    final FileSource files, final Parameters parameters) {
    final List<Integer> versions = SchemaRegistryMock.this.listVersions(getSubject(request));
    log.debug("Got versions {}", versions);
    return ResponseDefinitionBuilder.jsonResponse(versions);
}
 
Example 6
Source File: SchemaRegistryMock.java    From schema-registry-transfer-smt with Apache License 2.0 5 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
                                    final FileSource files, final Parameters parameters) {
    String versionStr = Iterables.get(this.urlSplitter.split(request.getUrl()), 3);
    SchemaMetadata metadata;
    if (versionStr.equals("latest")) {
        metadata = SchemaRegistryMock.this.getSubjectVersion(getSubject(request), versionStr);
    } else {
        int version = Integer.parseInt(versionStr);
        metadata = SchemaRegistryMock.this.getSubjectVersion(getSubject(request), version);
    }
    return ResponseDefinitionBuilder.jsonResponse(metadata);
}
 
Example 7
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 4 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
        final FileSource files, final Parameters parameters) {
    final List<Integer> ids = SchemaRegistryMock.this.delete(this.getSubject(request));
    return ResponseDefinitionBuilder.jsonResponse(ids);
}
 
Example 8
Source File: SchemaRegistryMock.java    From fluent-kafka-streams-tests with MIT License 4 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
        final FileSource files, final Parameters parameters) {
    final Collection<String> body = SchemaRegistryMock.this.listAllSubjects();
    return ResponseDefinitionBuilder.jsonResponse(body);
}
 
Example 9
Source File: SchemaRegistryMock.java    From schema-registry-transfer-smt with Apache License 2.0 4 votes vote down vote up
@Override
public ResponseDefinition transform(final Request request, final ResponseDefinition responseDefinition,
                                    final FileSource files, final Parameters parameters) {
    Config config = new Config(SchemaRegistryMock.this.getCompatibility(getSubject(request)));
    return ResponseDefinitionBuilder.jsonResponse(config);
}