-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add java-kotlin support --------- Co-authored-by: a.v.muratova <[email protected]>
- Loading branch information
1 parent
ac4f530
commit 758352e
Showing
38 changed files
with
739 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package ru.tinkoff.load.javaapi; | ||
|
||
import io.gatling.javaapi.core.internal.Expressions; | ||
import ru.tinkoff.load.javaapi.actions.BatchInsertBaseAction; | ||
import ru.tinkoff.load.javaapi.actions.BatchUpdateBaseAction; | ||
import ru.tinkoff.load.javaapi.actions.DBBaseAction; | ||
import ru.tinkoff.load.javaapi.check.simpleCheckType; | ||
import ru.tinkoff.load.javaapi.protocol.JdbcProtocolBuilderBase; | ||
import ru.tinkoff.load.jdbc.actions.actions; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Arrays; | ||
|
||
import static scala.jdk.javaapi.CollectionConverters.asScala; | ||
|
||
public final class JdbcDsl { | ||
private JdbcDsl(){} | ||
|
||
public static JdbcProtocolBuilderBase DB(){ | ||
return new JdbcProtocolBuilderBase(); | ||
} | ||
@Nonnull | ||
public static DBBaseAction jdbc(@Nonnull String name){ | ||
return new DBBaseAction(ru.tinkoff.load.jdbc.Predef.jdbc(Expressions.toStringExpression(name))); | ||
} | ||
|
||
@Nonnull | ||
public static BatchInsertBaseAction insetInto(@Nonnull String tableName, String... columns){ | ||
return new BatchInsertBaseAction(ru.tinkoff.load.jdbc.Predef.insertInto(Expressions.toStringExpression(tableName), | ||
new actions.Columns( | ||
asScala( | ||
Arrays | ||
.stream(columns) | ||
.toList()) | ||
.toSeq()))); | ||
} | ||
|
||
@Nonnull | ||
public static BatchUpdateBaseAction update(@Nonnull String tableName){ | ||
return new BatchUpdateBaseAction(ru.tinkoff.load.jdbc.Predef.update(Expressions.toStringExpression(tableName))); | ||
} | ||
|
||
@Nonnull | ||
public static io.gatling.core.check.Check.Simple<scala.collection.immutable.List<scala.collection.immutable.Map<java.lang.String,java.lang.Object>>> simpleCheck(simpleCheckType checkType){ | ||
return ru.tinkoff.load.jdbc.internal.JdbcCheck.simpleJavaCheck(checkType); | ||
} | ||
|
||
@Nonnull | ||
public static io.gatling.core.check.CheckBuilder.Final<ru.tinkoff.load.jdbc.check.JdbcCheckSupport.JdbcAllRecordCheckType,scala.collection.immutable.List<scala.collection.immutable.Map<java.lang.String,java.lang.Object>>> allResults(){ | ||
return ru.tinkoff.load.jdbc.internal.JdbcCheck.results(); | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/ru/tinkoff/load/javaapi/actions/BatchAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
public interface BatchAction{} |
15 changes: 15 additions & 0 deletions
15
src/main/java/ru/tinkoff/load/javaapi/actions/BatchActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.ActionBuilder; | ||
public class BatchActionBuilder implements ActionBuilder{ | ||
private final ru.tinkoff.load.jdbc.actions.actions.BatchActionBuilder wrapped; | ||
|
||
public BatchActionBuilder(ru.tinkoff.load.jdbc.actions.actions.BatchActionBuilder batchActionBuilder){ | ||
this.wrapped = batchActionBuilder; | ||
} | ||
|
||
@Override | ||
public io.gatling.core.action.builder.ActionBuilder asScala() { | ||
return this.wrapped; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/ru/tinkoff/load/javaapi/actions/BatchInsertAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.commons.validation.Validation; | ||
import io.gatling.core.session.Session; | ||
import ru.tinkoff.load.javaapi.internal.Utils; | ||
import scala.Function1; | ||
import java.util.Map; | ||
|
||
public class BatchInsertAction implements BatchAction { | ||
|
||
public ru.tinkoff.load.jdbc.actions.actions.BatchInsertAction wrapped; | ||
|
||
public BatchInsertAction(ru.tinkoff.load.jdbc.actions.actions.BatchInsertAction batchInsertAction){ | ||
this.wrapped = batchInsertAction; | ||
} | ||
|
||
public static ru.tinkoff.load.jdbc.actions.actions.BatchInsertAction toScala( | ||
Function1<Session, Validation<String>> tableName, | ||
Map<String, Object> values, | ||
ru.tinkoff.load.jdbc.actions.actions.Columns columns | ||
){ | ||
return new ru.tinkoff.load.jdbc.actions.actions.BatchInsertAction | ||
(tableName, columns, Utils.getSeq(values) | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/tinkoff/load/javaapi/actions/BatchInsertBaseAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import java.util.Map; | ||
|
||
public class BatchInsertBaseAction implements BatchAction { | ||
private final ru.tinkoff.load.jdbc.actions.actions.BatchInsertBaseAction wrapped; | ||
|
||
public BatchInsertBaseAction(ru.tinkoff.load.jdbc.actions.actions.BatchInsertBaseAction batchInsertBaseAction){ | ||
this.wrapped = batchInsertBaseAction; | ||
} | ||
|
||
public BatchInsertAction values(Map<String, Object> ps){ | ||
return new BatchInsertAction(BatchInsertAction.toScala(wrapped.tableName(), ps, wrapped.columns())); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/ru/tinkoff/load/javaapi/actions/BatchUpdateAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
public class BatchUpdateAction implements BatchAction { | ||
public ru.tinkoff.load.jdbc.actions.actions.BatchUpdateAction wrapped; | ||
public BatchUpdateAction(ru.tinkoff.load.jdbc.actions.actions.BatchUpdateAction batchUpdateAction){ | ||
this.wrapped = batchUpdateAction; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/tinkoff/load/javaapi/actions/BatchUpdateBaseAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import java.util.Map; | ||
import static ru.tinkoff.load.javaapi.internal.Utils.getSeq; | ||
|
||
public class BatchUpdateBaseAction implements BatchAction { | ||
private final ru.tinkoff.load.jdbc.actions.actions.BatchUpdateBaseAction wrapped; | ||
public BatchUpdateBaseAction(ru.tinkoff.load.jdbc.actions.actions.BatchUpdateBaseAction batchUpdateBaseAction) { | ||
this.wrapped = batchUpdateBaseAction; | ||
} | ||
|
||
public BatchUpdateValuesStepAction set(Map<String, Object> values){ | ||
return new BatchUpdateValuesStepAction(new ru.tinkoff.load.jdbc.actions.actions.BatchUpdateValuesStepAction(wrapped.tableName(), | ||
getSeq(values))); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/ru/tinkoff/load/javaapi/actions/BatchUpdateValuesStepAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import static io.gatling.javaapi.core.internal.Expressions.toStringExpression; | ||
|
||
public class BatchUpdateValuesStepAction { | ||
private final ru.tinkoff.load.jdbc.actions.actions.BatchUpdateValuesStepAction wrapped; | ||
|
||
public BatchUpdateValuesStepAction(ru.tinkoff.load.jdbc.actions.actions.BatchUpdateValuesStepAction batchUpdateValuesStepAction) { | ||
this.wrapped = batchUpdateValuesStepAction; | ||
} | ||
public BatchUpdateAction where(String whereExpression){ | ||
return new BatchUpdateAction(new ru.tinkoff.load.jdbc.actions.actions.BatchUpdateAction(wrapped.tableName(), | ||
wrapped.updateValues(), | ||
scala.Option.apply(toStringExpression(whereExpression)))); | ||
|
||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/ru/tinkoff/load/javaapi/actions/DBBaseAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.internal.Expressions; | ||
import java.util.Arrays; | ||
import static scala.jdk.javaapi.CollectionConverters.asScala; | ||
|
||
public final class DBBaseAction{ | ||
|
||
private final ru.tinkoff.load.jdbc.actions.actions.DBBaseAction wrapped; | ||
|
||
public DBBaseAction(ru.tinkoff.load.jdbc.actions.actions.DBBaseAction dbBaseAction){ | ||
this.wrapped = dbBaseAction; | ||
} | ||
|
||
public DBInsertActionValuesStep insertInto(String tableName, String... columns){ | ||
return new DBInsertActionValuesStep( | ||
wrapped.insertInto( | ||
Expressions.toStringExpression(tableName), | ||
new ru.tinkoff.load.jdbc.actions.actions.Columns( | ||
asScala( | ||
Arrays | ||
.stream(columns) | ||
.toList()) | ||
.toSeq() | ||
))); | ||
} | ||
|
||
public DBCallActionParamStep call(String procedureName){ | ||
return new DBCallActionParamStep(wrapped.call(Expressions.toStringExpression(procedureName))); | ||
} | ||
|
||
public RawSqlActionBuilder rawSql(String queryString){ | ||
return new RawSqlActionBuilder(wrapped.rawSql(Expressions.toStringExpression(queryString))); | ||
} | ||
|
||
public QueryActionParamsStep queryP(String sql){ | ||
return new QueryActionParamsStep(wrapped.queryP(Expressions.toStringExpression(sql))); | ||
} | ||
|
||
public QueryActionBuilder query(String sql) { | ||
return new QueryActionBuilder(wrapped.query(Expressions.toStringExpression(sql))); | ||
} | ||
|
||
public BatchActionBuilder batch(BatchAction... actions) { | ||
return new BatchActionBuilder( | ||
wrapped.batch( | ||
asScala(Arrays.stream(actions).map(x -> | ||
ru.tinkoff.load.jdbc.internal.BatchBase.toScalaBatch(x)) | ||
.toList()).toSeq() | ||
)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/tinkoff/load/javaapi/actions/DBCallActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.ActionBuilder; | ||
|
||
public class DBCallActionBuilder implements ActionBuilder { | ||
private final ru.tinkoff.load.jdbc.actions.actions.DBCallActionBuilder wrapped; | ||
|
||
public DBCallActionBuilder(ru.tinkoff.load.jdbc.actions.actions.DBCallActionBuilder dbCallActionBuilder){ | ||
this.wrapped = dbCallActionBuilder; | ||
} | ||
|
||
@Override | ||
public io.gatling.core.action.builder.ActionBuilder asScala() { | ||
return this.wrapped; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/ru/tinkoff/load/javaapi/actions/DBCallActionParamStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import ru.tinkoff.load.javaapi.internal.Utils; | ||
import java.util.Map; | ||
|
||
import static ru.tinkoff.load.javaapi.internal.Utils.getSeq; | ||
|
||
public class DBCallActionParamStep { | ||
private final ru.tinkoff.load.jdbc.actions.actions.DBCallActionParamsStep wrapped; | ||
|
||
public DBCallActionParamStep(ru.tinkoff.load.jdbc.actions.actions.DBCallActionParamsStep wrapped){ | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public DBCallActionBuilder params(Map<String, Object> values){ | ||
return new DBCallActionBuilder(wrapped.params( | ||
getSeq(values)) | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/tinkoff/load/javaapi/actions/DBInsertActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.ActionBuilder; | ||
|
||
public class DBInsertActionBuilder implements ActionBuilder { | ||
private final ru.tinkoff.load.jdbc.actions.actions.DBInsertActionBuilder wrapped; | ||
|
||
public DBInsertActionBuilder(ru.tinkoff.load.jdbc.actions.actions.DBInsertActionBuilder dbInsertActionBuilder){ | ||
this.wrapped = dbInsertActionBuilder; | ||
} | ||
|
||
@Override | ||
public io.gatling.core.action.builder.ActionBuilder asScala() { | ||
return this.wrapped; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/ru/tinkoff/load/javaapi/actions/DBInsertActionValuesStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import java.util.Map; | ||
import static ru.tinkoff.load.javaapi.internal.Utils.getSeq; | ||
|
||
public class DBInsertActionValuesStep { | ||
private final ru.tinkoff.load.jdbc.actions.actions.DBInsertActionValuesStep wrapped; | ||
|
||
public DBInsertActionValuesStep(ru.tinkoff.load.jdbc.actions.actions.DBInsertActionValuesStep wrapped){ | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public DBInsertActionBuilder values(Map<String, Object> vals){ | ||
return new DBInsertActionBuilder(wrapped.values( | ||
getSeq(vals) | ||
)); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/ru/tinkoff/load/javaapi/actions/QueryActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.ActionBuilder; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class QueryActionBuilder implements ActionBuilder { | ||
private ru.tinkoff.load.jdbc.actions.actions.QueryActionBuilder wrapped; | ||
|
||
public QueryActionBuilder(ru.tinkoff.load.jdbc.actions.actions.QueryActionBuilder wrapped){ | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public QueryActionBuilder check(Object...checks){ | ||
return check(Arrays.asList(checks)); | ||
} | ||
|
||
public QueryActionBuilder check(List<Object> checks) { | ||
this.wrapped = wrapped.check(ru.tinkoff.load.jdbc.internal.JdbcCheck.toScalaChecks(checks)); | ||
return this; | ||
} | ||
|
||
@Override | ||
public io.gatling.core.action.builder.ActionBuilder asScala() { | ||
return this.wrapped; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/ru/tinkoff/load/javaapi/actions/QueryActionParamsStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import ru.tinkoff.load.javaapi.internal.Utils; | ||
|
||
import java.util.Map; | ||
|
||
import static ru.tinkoff.load.javaapi.internal.Utils.getSeq; | ||
|
||
public class QueryActionParamsStep { | ||
private final ru.tinkoff.load.jdbc.actions.actions.QueryActionParamsStep wrapped; | ||
|
||
public QueryActionParamsStep(ru.tinkoff.load.jdbc.actions.actions.QueryActionParamsStep wrapped){ | ||
this.wrapped = wrapped; | ||
} | ||
|
||
public QueryActionBuilder params(Map<String, Object> values){ | ||
return new QueryActionBuilder (wrapped.params( | ||
getSeq(values) | ||
)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/tinkoff/load/javaapi/actions/RawSqlActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.tinkoff.load.javaapi.actions; | ||
|
||
import io.gatling.javaapi.core.ActionBuilder; | ||
|
||
public class RawSqlActionBuilder implements ActionBuilder{ | ||
private final ru.tinkoff.load.jdbc.actions.actions.RawSqlActionBuilder wrapped; | ||
|
||
public RawSqlActionBuilder(ru.tinkoff.load.jdbc.actions.actions.RawSqlActionBuilder wrapped){ | ||
this.wrapped = wrapped; | ||
} | ||
|
||
@Override | ||
public io.gatling.core.action.builder.ActionBuilder asScala() { | ||
return this.wrapped; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/ru/tinkoff/load/javaapi/check/simpleCheckType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package ru.tinkoff.load.javaapi.check; | ||
|
||
public enum simpleCheckType { | ||
NonEmpty, | ||
Empty, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.tinkoff.load.javaapi.internal; | ||
|
||
import io.gatling.javaapi.core.internal.Expressions; | ||
|
||
import java.util.Map; | ||
|
||
import static scala.jdk.javaapi.CollectionConverters.asScala; | ||
|
||
public final class Utils { | ||
public static scala.collection.immutable.Seq<scala.Tuple2<String, scala.Function1<io.gatling.core.session.Session, io.gatling.commons.validation.Validation<Object>>>> getSeq(Map<String, Object> values){ | ||
return asScala( | ||
values | ||
.entrySet() | ||
.stream() | ||
.map(pair -> | ||
scala.Tuple2.apply(pair.getKey(), Expressions.toExpression(pair.getValue().toString(), Object.class)) | ||
).toList() | ||
.stream() | ||
.toList()) | ||
.toSeq(); | ||
} | ||
} |
Oops, something went wrong.