Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ package object extension {
def partialUpdateObjects(
indexName: String,
objects: Seq[Any],
createIfNotExists: Boolean,
createIfNotExists: Boolean = false,
requestOptions: Option[RequestOptions] = None
)(implicit ec: ExecutionContext): Future[Seq[BatchResponse]] = {
chunkedBatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.algolia.codegen.cts.lambda.*;
import com.algolia.codegen.cts.manager.CTSManager;
import com.algolia.codegen.cts.manager.CTSManagerFactory;
import com.algolia.codegen.cts.snippets.*;
import com.algolia.codegen.cts.tests.*;
import com.algolia.codegen.exceptions.*;
import com.algolia.codegen.utils.*;
Expand Down Expand Up @@ -60,7 +59,7 @@ public void processOpts() {
if (mode.equals("tests")) {
ctsManager.addTestsSupportingFiles(supportingFiles);

testsGenerators.add(new TestsRequest(language, client, false));
testsGenerators.add(new TestsRequest(language, client));
testsGenerators.add(new TestsClient(language, client, true));
testsGenerators.add(new TestsClient(language, client, false));
} else if (mode.equals("snippets")) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ public class ClientTestData {
public String testName;
public boolean autoCreateClient = true;
public List<Step> steps;

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ClientTestData {\n");
sb.append(" testName: ").append(testName).append("\n");
sb.append(" autoCreateClient: ").append(autoCreateClient).append("\n");
sb.append(" steps: ").append(steps).append("\n");
sb.append("}");
return sb.toString();
}
}

class Step {
Expand All @@ -17,11 +27,33 @@ class Step {
public int times;
public Map<String, Object> parameters;
public Expected expected;

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Step {\n");
sb.append(" type: ").append(type).append("\n");
sb.append(" method: ").append(method).append("\n");
sb.append(" times: ").append(times).append("\n");
sb.append(" parameters: ").append(parameters).append("\n");
sb.append(" expected: ").append(expected).append("\n");
sb.append("}");
return sb.toString();
}
}

class Expected {

public String type;
public Object error;
public Object match;

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Expected {\n");
sb.append(" type: ").append(type).append("\n");
sb.append(" error: ").append(error).append("\n");
sb.append(" match: ").append(match).append("\n");
sb.append("}");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public class ParametersWithDataType {
private final Map<String, CodegenModel> models;
private final String language;
private final String client;
private final boolean prettyIndexName;

public ParametersWithDataType(Map<String, CodegenModel> models, String language, String client) {
public ParametersWithDataType(Map<String, CodegenModel> models, String language, String client, boolean prettyIndexName) {
this.models = models;
this.language = language;
this.client = client;
this.prettyIndexName = prettyIndexName;
}

public void enhanceParameters(Map<String, Object> parameters, Map<String, Object> bundle)
Expand Down Expand Up @@ -155,6 +157,11 @@ private Map<String, Object> traverseParams(
handlePrimitive(param, testOutput, spec);
}

// for snippets, we want pretty index names, unless they are already pretty
if (prettyIndexName && paramName.equals("indexName") && !((String) testOutput.get("value")).startsWith("<")) {
testOutput.put("value", "<YOUR_INDEX_NAME>");
}

return testOutput;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.algolia.codegen.cts.tests;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import java.io.IOException;

// Output json to raw string with quotes
public class RawDeserializer extends JsonDeserializer<String> {

@Override
public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
TreeNode tree = jp.getCodec().readTree(jp);
return tree.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
package com.algolia.codegen.cts.tests;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.io.IOException;
import java.util.Map;

public class Request {

public String testName;
public boolean isSnippet;

public Map<String, Object> parameters;
public RequestOptions requestOptions;
Expand All @@ -24,7 +16,6 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Request {\n");
sb.append(" testName: ").append(testName).append("\n");
sb.append(" isSnippet").append(isSnippet).append("\n");
sb.append(" parameters: ").append(parameters).append("\n");
sb.append(" requestOptions: ").append(requestOptions).append("\n");
sb.append(" request: ").append(request).append("\n");
Expand All @@ -33,75 +24,3 @@ public String toString() {
return sb.toString();
}
}

class RequestOptions {

public Map<String, Object> queryParameters;
public Map<String, String> headers;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class RequestOptions {\n");
sb.append(" queryParameters: ").append(queryParameters).append("\n");
sb.append(" headers: ").append(headers).append("\n");
sb.append("}");
return sb.toString();
}
}

class RequestProp {

public String path;
public String method;

@JsonDeserialize(using = RawDeserializer.class)
public String body;

@JsonDeserialize(using = RawDeserializer.class)
public String queryParameters;

@JsonDeserialize(using = RawDeserializer.class)
public String headers;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class RequestProp {\n");
sb.append(" path: ").append(path).append("\n");
sb.append(" method: ").append(method).append("\n");
sb.append(" body: ").append(body).append("\n");
sb.append(" queryParameters: ").append(queryParameters).append("\n");
sb.append(" headers: ").append(headers).append("\n");
sb.append("}");
return sb.toString();
}
}

class ResponseProp {

public int statusCode;

@JsonDeserialize(using = RawDeserializer.class)
public String body;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ResponseProp {\n");
sb.append(" statusCode: ").append(statusCode).append("\n");
sb.append(" body: ").append(body).append("\n");
sb.append("}");
return sb.toString();
}
}

// Output json to raw string with quotes
class RawDeserializer extends JsonDeserializer<String> {

@Override
public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
TreeNode tree = jp.getCodec().readTree(jp);
return tree.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.algolia.codegen.cts.tests;

import java.util.Map;

public class RequestOptions {

public Map<String, Object> queryParameters;
public Map<String, String> headers;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class RequestOptions {\n");
sb.append(" queryParameters: ").append(queryParameters).append("\n");
sb.append(" headers: ").append(headers).append("\n");
sb.append("}");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.algolia.codegen.cts.tests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

public class RequestProp {

public String path;
public String method;

@JsonDeserialize(using = RawDeserializer.class)
public String body;

@JsonDeserialize(using = RawDeserializer.class)
public String queryParameters;

@JsonDeserialize(using = RawDeserializer.class)
public String headers;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class RequestProp {\n");
sb.append(" path: ").append(path).append("\n");
sb.append(" method: ").append(method).append("\n");
sb.append(" body: ").append(body).append("\n");
sb.append(" queryParameters: ").append(queryParameters).append("\n");
sb.append(" headers: ").append(headers).append("\n");
sb.append("}");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.algolia.codegen.cts.tests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

public class ResponseProp {

public int statusCode;

@JsonDeserialize(using = RawDeserializer.class)
public String body;

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ResponseProp {\n");
sb.append(" statusCode: ").append(statusCode).append("\n");
sb.append(" body: ").append(body).append("\n");
sb.append("}");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.algolia.codegen.cts.tests;

import java.util.Map;

public class Snippet {

public String testName;
public boolean isSnippet;

public Map<String, Object> parameters;
public RequestOptions requestOptions;

public Snippet(String testName, Map<String, Object> parameters) {
this.testName = testName;
this.isSnippet = true;
this.parameters = parameters;
}

public Snippet() {}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Request {\n");
sb.append(" testName: ").append(testName).append("\n");
sb.append(" isSnippet").append(isSnippet).append("\n");
sb.append(" parameters: ").append(parameters).append("\n");
sb.append(" requestOptions: ").append(requestOptions).append("\n");
sb.append("}");
return sb.toString();
}
}
Loading