method2testcases stringlengths 118 6.63k |
|---|
### Question:
Proto { public void applyBindings() { initBindings(null).applyBindings(null); } Proto(Object obj, Type type, BrwsrCtx context); BrwsrCtx getContext(); void acquireLock(); void acquireLock(String propName); void accessProperty(String propName); void verifyUnlocked(); void releaseLock(); void valueHasMutate... |
### Question:
Models { public static boolean isModel(Class<?> clazz) { return JSON.isModel(clazz); } private Models(); static boolean isModel(Class<?> clazz); static Model bind(Model model, BrwsrCtx context); static M parse(BrwsrCtx c, Class<M> model, InputStream is); static void parse(
BrwsrCtx c, Class<M> mo... |
### Question:
CoordImpl extends Position.Coordinates { @Override public double getLatitude() { return provider.latitude(data); } CoordImpl(Coords data, GLProvider<Coords, ?> p); @Override double getLatitude(); @Override double getLongitude(); @Override double getAccuracy(); @Override Double getAltitude(); @Override Dou... |
### Question:
Scripts { public static Scripts newPresenter() { return new Scripts(); } private Scripts(); @Deprecated static Presenter createPresenter(); @Deprecated static Presenter createPresenter(Executor exc); static Scripts newPresenter(); Scripts executor(Executor exc); Scripts engine(ScriptEngine engine); Scrip... |
### Question:
FXBrwsr extends Application { static String findCalleeClassName() { StackTraceElement[] frames = new Exception().getStackTrace(); for (StackTraceElement e : frames) { String cn = e.getClassName(); if (cn.startsWith("org.netbeans.html.")) { continue; } if (cn.startsWith("net.java.html.")) { continue; } if ... |
### Question:
FXBrowsers { public static void runInBrowser(WebView webView, Runnable code) { Object ud = webView.getUserData(); if (ud instanceof Fn.Ref<?>) { ud = ((Fn.Ref<?>)ud).presenter(); } if (!(ud instanceof InitializeWebView)) { throw new IllegalArgumentException(); } ((InitializeWebView)ud).runInContext(code);... |
### Question:
JsCallback { final String parse(String body) { StringBuilder sb = new StringBuilder(); int pos = 0; for (;;) { int next = body.indexOf(".@", pos); if (next == -1) { sb.append(body.substring(pos)); body = sb.toString(); break; } int ident = next; while (ident > 0) { if (!Character.isJavaIdentifierPart(body... |
### Question:
FallbackIdentity extends WeakReference<Fn.Presenter> implements Fn.Ref { @Override public int hashCode() { return hashCode; } FallbackIdentity(Fn.Presenter p); @Override Fn.Ref reference(); @Override Fn.Presenter presenter(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:
@T... |
### Question:
BrowserBuilder { static URL findLocalizedResourceURL(String resource, Locale l, IOException[] mal, Class<?> relativeTo) { URL url = null; if (l != null) { url = findResourceURL(resource, "_" + l.getLanguage() + "_" + l.getCountry(), mal, relativeTo); if (url != null) { return url; } url = findResourceURL(... |
### Question:
JSONList extends SimpleList<T> { @Override public String toString() { Iterator<T> it = iterator(); if (!it.hasNext()) { return "[]"; } String sep = ""; StringBuilder sb = new StringBuilder(); sb.append('['); while (it.hasNext()) { T t = it.next(); sb.append(sep); sb.append(JSON.toJSON(t)); sep = ","; } sb... |
### Question:
JSONList extends SimpleList<T> { @Override public boolean add(T e) { prepareChange(); boolean ret = super.add(e); notifyChange(); return ret; } JSONList(Proto proto, String name, int changeIndex, String... deps); void init(Object values); static void init(Collection<T> to, Object values); @Override boolea... |
### Question:
JSON { public static String stringValue(Object val) { if (val instanceof Boolean) { return ((Boolean)val ? "true" : "false"); } if (isNumeric(val)) { return Long.toString(((Number)val).longValue()); } if (val instanceof Float) { return Float.toString((Float)val); } if (val instanceof Double) { return Doub... |
### Question:
JSON { public static Number numberValue(Object val) { if (val instanceof String) { try { return Double.valueOf((String)val); } catch (NumberFormatException ex) { return Double.NaN; } } if (val instanceof Boolean) { return (Boolean)val ? 1 : 0; } return (Number)val; } private JSON(); static Transfer findT... |
### Question:
TableXMLFormatter { public String getSchemaXml() { String result= "<schema>"; Map<String, TableSchema> tableSchemas = schemaExtractor.getTablesFromQuery(query); for (TableSchema tableSchema : tableSchemas.values()) { result += getTableSchemaXml(tableSchema); } result += "</schema>"; return result; } Table... |
### Question:
QueryStripper { public String getStrippedSql() { String secureQuery = new SqlSecurer(sql).getSecureSql(); Select stmt = null; try { stmt = (Select) CCJSqlParserUtil.parse(secureQuery); } catch (JSQLParserException e) { throw new RuntimeException(e); } stmt.getSelectBody().accept(new QueryStripperVisitor()... |
### Question:
DBDouble implements DBType { static String truncateDecimals(double value, int decimals) { StringBuilder builder = new StringBuilder("0"); if (decimals > 0) builder.append('.'); for (int i = 0; i < decimals; i++) builder.append('#'); DecimalFormat df = new DecimalFormat(builder.toString(), defaultDecimalFo... |
### Question:
Fixture implements Cloneable { public String prettyPrint() { StringBuilder prettyFixture = new StringBuilder(); for (FixtureTable table : tables) { prettyFixture.append("-- Table: " + table.getName() + "\n"); Iterator<FixtureRow> it = table.getRows().iterator(); int rowCount = 1; while (it.hasNext()) { Fi... |
### Question:
Pipeline { public void execute() { Result queryRunnerResult = queryRunner.runQuery(sqlQuery, connectionData); Map<Generator, List<Output>> outputCache = new HashMap<>(); for (ResultProcessor rp : resultProcessors) { List<Output> generatedOutputs; if (outputCache.containsKey(rp.getGenerator())) { generated... |
### Question:
JUnitGeneratorHelper { public MethodSpec buildRunSqlEmpty() { MethodSpec.Builder runSql = MethodSpec.methodBuilder(METHOD_RUN_SQL) .addModifiers(Modifier.PRIVATE, Modifier.STATIC) .returns(RETURN_TYPE_RUN_SQL) .addParameter(String.class, "query") .addParameter(TypeName.BOOLEAN, "isUpdate") .addException(S... |
### Question:
JUnitGeneratorHelper { public MethodSpec buildMapMaker() { MethodSpec.Builder mapMaker = MethodSpec.methodBuilder(METHOD_MAP_MAKER) .addModifiers(Modifier.PRIVATE, Modifier.STATIC) .returns(ParameterizedTypeName.get(HashMap.class, String.class, String.class)) .addParameter(String[].class, "strings") .vara... |
### Question:
JUnitGeneratorHelper { public MethodSpec buildGetResultColumns() { MethodSpec.Builder getResultColumns = MethodSpec.methodBuilder(METHOD_GET_RESULT_COLUMNS) .addModifiers(Modifier.PRIVATE, Modifier.STATIC) .returns(ParameterizedTypeName.get(List.class, String.class)) .addParameter(ResultSet.class, "result... |
### Question:
JUnitGeneratorSettings { public static JUnitGeneratorSettings getDefault( ConnectionData connectionData, String filePackage, String className) { return new JUnitGeneratorSettings( connectionData, filePackage, className, true, true, true, false, true ); } static JUnitGeneratorSettings getDefault(
... |
### Question:
EvoSQLRunner implements QueryRunner { @Override public Result runQuery(@NonNull String sqlQuery, @NonNull ConnectionData connectionData) { EvoSQL evoSQL = evoSQLFactory.createEvoSQL(connectionData); nl.tudelft.serg.evosql.Result evoSQLResult = evoSQL.execute(sqlQuery); return convertResult(evoSQLResult); ... |
### Question:
EvoSQLRunner implements QueryRunner { Result convertResult(nl.tudelft.serg.evosql.Result evoSqlResult) { return new Result( evoSqlResult.getInputQuery(), evoSqlResult.getPathResults().stream() .filter(pr -> pr.getFixture() != null) .filter(pr -> pr.isSuccess()) .map(this::convertPathResult) .collect(Colle... |
### Question:
EvoSQLFactory { public EvoSQL createEvoSQL(ConnectionData connectionData) { return new EvoSQL( connectionData.getConnectionString(), connectionData.getDatabase(), connectionData.getUsername(), connectionData.getPassword(), false); } EvoSQL createEvoSQL(ConnectionData connectionData); }### Answer:
@Test ... |
### Question:
ExistingDataRunner implements QueryRunner { @Override public Result runQuery(String sqlQuery, ConnectionData connectionData) { return result; } @Override Result runQuery(String sqlQuery, ConnectionData connectionData); }### Answer:
@Test void testRunQuerySame() { final Result expected = Mockito.mock(Res... |
### Question:
FileConsumer implements OutputConsumer { @Override public void consumeOutput(List<Output> outputs) { try { Files.createDirectories(directory); for (Output output : outputs) { File outfile = Paths.get(directory.toString(), output.getName()).toFile(); FileOutputStream outStream = fileOutputStreamProvider.cr... |
### Question:
TableCreationBuilder extends QueryBuilder { @Override public List<String> buildQueries(Path path) { return path.getFixture().getTables().stream().map(table -> { StringBuilder createBuilder = new StringBuilder(); createBuilder.append("CREATE TABLE "); createBuilder.append(getVendorOptions().escapeIdentifie... |
### Question:
QueryBuilder { protected String getEscapedValue(FixtureColumn fixtureColumn, FixtureRow fixtureRow) { String value = fixtureRow.getValues().get(fixtureColumn.getName()); if (value == null || "NULL".equals(value)) { return "NULL"; } if (!numericSqlTypes.contains(fixtureColumn.getType())) { return "'" + val... |
### Question:
SelectionBuilder extends QueryBuilder { @Override public List<String> buildQueries(Path path) { return Collections.singletonList(path.getPathSql()); } SelectionBuilder(VendorOptions vendorOptions); @Override List<String> buildQueries(Path path); }### Answer:
@Test void selectionBuilderTestSmall() { Selec... |
### Question:
CleaningBuilder extends QueryBuilder { @Override public List<String> buildQueries(Path path) { return path.getFixture().getTables().stream().map(table -> { StringBuilder truncateBuilder = new StringBuilder(); truncateBuilder.append("TRUNCATE TABLE "); truncateBuilder.append(getVendorOptions().escapeIdenti... |
### Question:
InsertionBuilder extends QueryBuilder { @Override public List<String> buildQueries(Path path) { return path.getFixture().getTables().stream().map(table -> { StringBuilder insertBuilder = new StringBuilder(); insertBuilder.append("INSERT INTO "); insertBuilder.append(getVendorOptions().escapeIdentifier(tab... |
### Question:
PostgreSQLOptions implements VendorOptions { @Override public String escapeIdentifier(String id) { return "\"" + id + "\""; } @Override String escapeIdentifier(String id); }### Answer:
@Test void testStandard() { VendorOptions postgreSQLOptions = new PostgreSQLOptions(); assertThat(postgreSQLOptions.esc... |
### Question:
MySQLOptions implements VendorOptions { @Override public String escapeIdentifier(String id) { return "`" + id + "`"; } @Override String escapeIdentifier(String id); }### Answer:
@Test void testNormal() { VendorOptions mySQLOptions = new MySQLOptions(); assertThat(mySQLOptions.escapeIdentifier("table")).... |
### Question:
DestructionBuilder extends QueryBuilder { @Override public List<String> buildQueries(Path path) { return path.getFixture().getTables().stream().map(table -> { StringBuilder destructionBuilder = new StringBuilder(); destructionBuilder.append("DROP TABLE "); destructionBuilder.append(getVendorOptions().esca... |
### Question:
Vector3D { public static float[] vectorMultiply(float[] lhs, float[] rhs) { float[] result = new float[3]; result[x] = lhs[y]*rhs[z] - lhs[z]*rhs[y]; result[y] = lhs[z]*rhs[x] - lhs[x]*rhs[z]; result[z] = lhs[x]*rhs[y] - lhs[y]*rhs[x]; return result; } static float[] vectorMultiply(float[] lhs, float[] r... |
### Question:
Vector3D { public static float scalarMultiply(float[] lhs, float[] rhs) { return lhs[x]*rhs[x] + lhs[y]*rhs[y] + lhs[z]*rhs[z]; } static float[] vectorMultiply(float[] lhs, float[] rhs); static float scalarMultiply(float[] lhs, float[] rhs); static float distanceVertices(float[] left, float[] right); sta... |
### Question:
Vector3D { public static float distanceVertices(float[] left, float[] right) { float sum = 0; for (int i = 0; i < 3; i++) { sum += (left[i] - right[i])*(left[i] - right[i]); } return (float) Math.sqrt(sum); } static float[] vectorMultiply(float[] lhs, float[] rhs); static float scalarMultiply(float[] lhs... |
### Question:
Vector3D { public static float vectorLength(float[] vector) { return (float) Math.sqrt(vector[x]*vector[x] + vector[y]*vector[y] + vector[z]*vector[z]); } static float[] vectorMultiply(float[] lhs, float[] rhs); static float scalarMultiply(float[] lhs, float[] rhs); static float distanceVertices(float[] ... |
### Question:
Vector3D { public static float[] createVector(float[] start, float[] end) { float[] res = new float[4]; for (int i = 0; i < 3; i++) { res[i] = end[i] - start[i]; } res[w] = 0; return res; } static float[] vectorMultiply(float[] lhs, float[] rhs); static float scalarMultiply(float[] lhs, float[] rhs); sta... |
### Question:
Vector3D { public static float distanceDotLine(float[] dot, float[] lineA, float[] lineB) { float[] v_l = createVector(lineA, lineB); float[] w = createVector(lineA, dot); float[] mul = vectorMultiply(v_l, w); return vectorLength(mul)/vectorLength(v_l); } static float[] vectorMultiply(float[] lhs, float[... |
### Question:
Vector3D { public static float distancevertexSegment(float[] dot, float[] segmentStart, float[] segmentEnd) { float[] vecSegment = createVector(segmentStart, segmentEnd); float[] vecDot = createVector(segmentStart, dot); float scalarMul = scalarMultiply(vecSegment, vecDot); if ((Math.abs(scalarMul) < Epsi... |
### Question:
ProductEventConsumer extends AbstractKafkaConsumer { @KafkaListener(topics = "${eventing.topic_name}") public void listen(final ConsumerRecord<String, String> consumerRecord, final Acknowledgment ack) { super.handleConsumerRecord(consumerRecord, ack); } @Inject protected ProductEventConsumer(ProductEvent... |
### Question:
ApiVerticle extends AbstractVerticle { private void getProduct(RoutingContext rc) { String itemId = rc.request().getParam("itemid"); catalogService.getProduct(itemId, ar -> { if (ar.succeeded()) { Product product = ar.result(); if (product != null) { rc.response() .putHeader("Content-type", "application/j... |
### Question:
ApiVerticle extends AbstractVerticle { private void addProduct(RoutingContext rc) { JsonObject json = rc.getBodyAsJson(); catalogService.addProduct(new Product(json), ar -> { if (ar.succeeded()) { rc.response().setStatusCode(201).end(); } else { rc.fail(ar.cause()); } }); } ApiVerticle(CatalogService cata... |
### Question:
FileEventStorage implements InteractionContextSink, Closeable { String serialize(InteractionContext interactionContext) throws JsonProcessingException { return mapper.writeValueAsString(interactionContext); } FileEventStorage(ObjectMapper mapper); @Override void apply(InteractionContext interactionContext... |
### Question:
FileEventStorage implements InteractionContextSink, Closeable { InteractionContext deserialize(String line) throws IOException { return mapper.readValue(line, InteractionContext.class); } FileEventStorage(ObjectMapper mapper); @Override void apply(InteractionContext interactionContext); void load(File fil... |
### Question:
InboxModel implements InteractionContextSink { public abstract Map<Identifier, InboxTask> getTasks(); abstract Map<Identifier, InboxTask> getTasks(); }### Answer:
@Test public void givenEmptyModelWhenCreatedTaskThenModelHasTask() { InboxModel model = new InMemoryInboxModel(); List<Event> events = new Ar... |
### Question:
Inbox { public static Function<Inbox, Function<NewTask, Task>> newTask() { return inbox -> newTask -> { Task task = new Task(newTask.id); inbox.select(task); changeDescription().apply(inbox).apply(newTask.changeDescription); return task; }; } void select(Task task); static Function<Inbox, Function<NewTas... |
### Question:
Version { public String toString() { return mMajor + "." + mMinor + "." + mBuild; } Version(String versionString); boolean isEqualTo(Version compareVersion); boolean isLowerThan(Version compareVersion); boolean ishIGHERThan(Version compareVersion); int getMajor(); int getMinor(); int getBuild(); String to... |
### Question:
JsonBindingExample extends JsonData { public Book deserializeBook() { return JsonbBuilder.create().fromJson(bookJson, Book.class); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfS... |
### Question:
JsonBindingExample extends JsonData { public String bookAdapterToJson() { JsonbConfig jsonbConfig = new JsonbConfig().withAdapters(new BookletAdapter()); Jsonb jsonb = JsonbBuilder.create(jsonbConfig); return jsonb.toJson(book1); } String serializeBook(); Book deserializeBook(); String serializeListOfBoo... |
### Question:
JsonBindingExample extends JsonData { public Book bookAdapterToBook() { JsonbConfig jsonbConfig = new JsonbConfig().withAdapters(new BookletAdapter()); Jsonb jsonb = JsonbBuilder.create(jsonbConfig); String json = "{\"isbn\":\"1234567890\",\"bookTitle\":\"Professional Java EE Design Patterns\",\"firstName... |
### Question:
EnumExample { public String enumSerialisationInObject() { return JsonbBuilder.create().toJson(new container()); } String enumSerialisation(); String enumSerialisationInObject(); }### Answer:
@Test public void enumSerialisationInObject() { String expectedJson = "{\"binding\":\"Hard Back\"}"; EnumExample ... |
### Question:
EnumExample { public String enumSerialisation() { return JsonbBuilder.create().toJson(Binding.HARD_BACK.name()); } String enumSerialisation(); String enumSerialisationInObject(); }### Answer:
@Test @Ignore public void givenEnum_shouldThrownExceptionWhenSerialised() { new EnumExample().enumSerialisation(... |
### Question:
ComprehensiveExample { public String serialiseMagazine() throws MalformedURLException { Magazine magazine = new Magazine(); magazine.setId("ABCD-1234"); magazine.setTitle("Fun with Java"); magazine.setAuthor(new Author("Alex", "Theedom")); magazine.setPrice(45.00f); magazine.setPages(300); magazine.setInP... |
### Question:
ComprehensiveExample { public Magazine deserialiseMagazine() { String json = "{\"author\":{\"firstName\":\"Alex\",\"lastName\":\"Theedom\"},\"binding\":\"SOFT_BACK\",\"id\":\"ABCD-1234\",\"inPrint\":true,\"languages\":[\"French\",\"English\",\"Spanish\",null],\"pages\":300,\"price\":45.0,\"published\":\"2... |
### Question:
NestedClassExample { public String serializeNestedClasses() { OuterClass.InnerClass innerClass = new OuterClass().new InnerClass(); Jsonb jsonb = JsonbBuilder.create(); String json = jsonb.toJson(innerClass); return json; } String serializeNestedClasses(); OuterClass.InnerClass deserialiseNestedClasses()... |
### Question:
NestedClassExample { public OuterClass.InnerClass deserialiseNestedClasses() { String json = "{\"name\":\"Inner Class\"}"; OuterClass.InnerClass innerClass = JsonbBuilder.create().fromJson(json, OuterClass.InnerClass.class); return innerClass; } String serializeNestedClasses(); OuterClass.InnerClass dese... |
### Question:
MinimalExample { public String serializeBook() { Book book = new Book("SHDUJ-4532", "Fun with Java", "Alex Theedom"); Jsonb jsonb = JsonbBuilder.create(); String json = jsonb.toJson(book); return json; } String serializeBook(); Book deserializeBook(); }### Answer:
@Test public void givenBookInstance_sho... |
### Question:
MinimalExample { public Book deserializeBook() { Book book = new Book("SHDUJ-4532", "Fun with Java", "Alex Theedom"); Jsonb jsonb = JsonbBuilder.create(); String json = jsonb.toJson(book); book = jsonb.fromJson(json, Book.class); return book; } String serializeBook(); Book deserializeBook(); }### Answer... |
### Question:
JsonBindingExample extends JsonData { public String serializeBook() { return JsonbBuilder.create().toJson(book1); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfStrings(); String ... |
### Question:
JsonPointerExample { public String find() { JsonPointer pointer = Json.createPointer("/topics/1"); JsonString jsonValue = (JsonString) pointer.getValue(jsonObject); return jsonValue.getString(); } String find(); String replace(); String add(); }### Answer:
@Test public void givenPointerToTopic_shouldRet... |
### Question:
JsonPointerExample { public String replace() { JsonPointer pointer = Json.createPointer("/topics/1"); JsonObject newJsonObject = pointer.replace(jsonObject, Json.createValue("Big Data")); JsonString jsonValue = (JsonString) pointer.getValue(newJsonObject); return jsonValue.getString(); } String find(); S... |
### Question:
JsonPointerExample { public String add(){ JsonPointer pointer = Json.createPointer("/topics/0"); JsonObject newJsonObject = pointer.add(jsonObject,Json.createValue("Java EE")); JsonString jsonValue = (JsonString) pointer.getValue(newJsonObject); return jsonValue.getString(); } String find(); String repla... |
### Question:
JsonMergePatchExample extends JsonExample { public JsonValue changeValue() { JsonValue source = Json.createValue("{\"colour\":\"blue\"}"); JsonValue patch = Json.createValue("{\"colour\":\"red\"}"); JsonMergePatch jsonMergePatch = Json.createMergePatch(patch); return jsonMergePatch.apply(source); } JsonV... |
### Question:
JsonMergePatchExample extends JsonExample { public JsonValue addValue() { JsonValue source = Json.createValue("{\"colour\":\"blue\"}"); JsonValue patch = Json.createValue("{\"blue\":\"light\"}"); JsonMergePatch jsonMergePatch = Json.createMergePatch(patch); return jsonMergePatch.apply(source); } JsonValu... |
### Question:
JsonMergePatchExample extends JsonExample { public JsonValue deleteValue() { JsonValue source = Json.createValue("{\"colour\":\"blue\"}"); JsonValue patch = Json.createValue("{\"colour\":null}"); JsonMergePatch jsonMergePatch = Json.createMergePatch(patch); return jsonMergePatch.apply(source); } JsonValu... |
### Question:
JsonPatchExample extends JsonExample { public JsonObject toJsonArray() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonArray jsonArray = builder.copy("/series/0", "/topics/0").build().toJsonArray(); return Json.createPatchBuilder(jsonArray).build().apply(jsonObject); } String replace(); JsonO... |
### Question:
JsonPatchExample extends JsonExample { public JsonObject test() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonPatch jsonPatch = builder .test("/topics/2", "Data") .move("/series/2", "/topics/2") .build(); return jsonPatch.apply(jsonObject); } String replace(); JsonObject addAndRemove(); Jso... |
### Question:
JsonPatchExample extends JsonExample { public JsonObject copy() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonPatch jsonPatch = builder.copy("/series/0", "/topics/0").build(); return jsonPatch.apply(jsonObject); } String replace(); JsonObject addAndRemove(); JsonObject move(); JsonObject co... |
### Question:
JsonPatchExample extends JsonExample { public JsonObject move() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonPatch jsonPatch = builder.move("/series/0", "/topics/0").build(); return jsonPatch.apply(jsonObject); } String replace(); JsonObject addAndRemove(); JsonObject move(); JsonObject co... |
### Question:
JsonBindingExample extends JsonData { public String serializeListOfBooks() { return JsonbBuilder.create().toJson(books); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfStrings(); ... |
### Question:
JsonPatchExample extends JsonExample { public JsonObject addAndRemove() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonPatch jsonPatch = builder .add("/comments", Json.createArrayBuilder().add("Very Good!").add("Excellent").build()) .remove("/notes") .build(); return jsonPatch.apply(jsonObjec... |
### Question:
JsonPatchExample extends JsonExample { public String replace() { JsonPatchBuilder builder = Json.createPatchBuilder(); JsonPatch jsonPatch = builder.replace("/series/0", "Spring 5").build(); JsonObject newJsonObject = jsonPatch.apply(jsonObject); JsonPointer pointer = Json.createPointer("/series/0"); Json... |
### Question:
JsonMergeDiffExample extends JsonExample { public JsonMergePatch createMergePatch(){ JsonValue source = Json.createValue("{\"colour\":\"blue\"}"); JsonValue target = Json.createValue("{\"colour\":\"red\"}"); JsonMergePatch jsonMergePatch = Json.createMergeDiff(source, target); return jsonMergePatch; } Js... |
### Question:
Java8Integration extends JsonExample { public List<String> filterJsonArrayToList() { List<String> topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .map(jsonValue -> ((JsonString) jsonValue).getString()) .collect(Collectors.toLis... |
### Question:
Java8Integration extends JsonExample { public JsonArray filterJsonArrayToJsonArray() { JsonArray topics = jsonObject.getJsonArray("topics").stream() .filter(jsonValue -> ((JsonString) jsonValue).getString().startsWith("C")) .collect(JsonCollectors.toJsonArray()); return topics; } List<String> filterJsonA... |
### Question:
Book { public void addChapterTitle(String chapterTitle) { chapterTitles.add(chapterTitle); } List<String> getChapterTitles(); void addChapterTitle(String chapterTitle); Map<String, String> getAuthorChapter(); void addAuthorChapter(String author, String chapter); }### Answer:
@Test public void givenListW... |
### Question:
Book { public void addAuthorChapter(String author, String chapter) { authorChapter.put(author,chapter); } List<String> getChapterTitles(); void addChapterTitle(String chapterTitle); Map<String, String> getAuthorChapter(); void addAuthorChapter(String author, String chapter); }### Answer:
@Test public vo... |
### Question:
ClientChoice { public void addChoices(Choice choice) { choices.add(choice); } void addChoices(Choice choice); void addClientChoices(String name, List<Choice> choices); List<Choice> getChoices(); Map<String, List<Choice>> getClientChoices(); }### Answer:
@Test public void givenListWithConstraints_shouldV... |
### Question:
JsonBindingExample extends JsonData { public List<Book> deserializeListOfBooks() { return JsonbBuilder.create().fromJson(bookListJson, new ArrayList<Book>().getClass().getGenericSuperclass()); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBoo... |
### Question:
ClientChoice { public void addClientChoices(String name, List<Choice> choices) { clientChoices.put(name, choices); } void addChoices(Choice choice); void addClientChoices(String name, List<Choice> choices); List<Choice> getChoices(); Map<String, List<Choice>> getClientChoices(); }### Answer:
@Test publi... |
### Question:
Customer { public void setEmail(String email) { this.email = email; } String getFirstName(); void setFirstName(String firstName); String getSecondName(); void setSecondName(String secondName); String getEmail(); void setEmail(String email); }### Answer:
@Test public void givenBeanWithValidEmailConstrain... |
### Question:
Person { public void setEmail(String email) { this.email = email; } String getFirstName(); void setFirstName(String firstName); String getSecondName(); void setSecondName(String secondName); String getEmail(); void setEmail(String email); }### Answer:
@Test public void givenBeanWithValidEmailConstraints... |
### Question:
Person { public void setCars(List<String> cars) { this.cars = cars; } String getFirstName(); void setFirstName(String firstName); String getSecondName(); void setSecondName(String secondName); String getEmail(); void setEmail(String email); List<String> getCars(); void setCars(List<String> cars); }### A... |
### Question:
RepeatedConstraint { public void setText(String text) { this.text = text; } String getText(); void setText(String text); }### Answer:
@Test public void givenBeanWithValidDomain_shouldValidate() { RepeatedConstraint repeatedConstraint = new RepeatedConstraint(); repeatedConstraint.setText("www.readlearnc... |
### Question:
JsonBindingExample extends JsonData { public String serializeArrayOfBooks() { return JsonbBuilder.create().toJson(arrayBooks); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfStrin... |
### Question:
OptionalExample { public void setText(String text) { this.text = Optional.of(text); } Optional<String> getName(); void setName(String name); Optional<String> getText(); void setText(String text); }### Answer:
@Test public void givenBeanWithOptionalStringExample_shouldNotValidate() { OptionalExample opti... |
### Question:
JsonBindingExample extends JsonData { public String serializeArrayOfStrings() { return JsonbBuilder.create().toJson(new String[]{"Java EE", "Java SE"}); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); St... |
### Question:
JsonBindingExample extends JsonData { public String customizedMapping() { JsonbConfig jsonbConfig = new JsonbConfig() .withPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CASE_WITH_DASHES) .withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL) .withStrictIJSON(true) .withFormatting(true) .w... |
### Question:
JsonBindingExample extends JsonData { public String annotationMethodMapping() { return JsonbBuilder.create().toJson(newspaper); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfStri... |
### Question:
JsonBindingExample extends JsonData { public String annotationPropertyAndMethodMapping() { return JsonbBuilder.create().toJson(booklet); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeAr... |
### Question:
JsonBindingExample extends JsonData { public String annotationPropertiesMapping() { return JsonbBuilder.create().toJson(magazine); } String serializeBook(); Book deserializeBook(); String serializeListOfBooks(); List<Book> deserializeListOfBooks(); String serializeArrayOfBooks(); String serializeArrayOfS... |
### Question:
AuthenticationUtil { public static void clearAuthentication() { SecurityContextHolder.getContext().setAuthentication(null); } private AuthenticationUtil(); static void clearAuthentication(); static void configureAuthentication(String role); }### Answer:
@Test public void clearAuthentication_ShouldRemove... |
### Question:
AuthenticationUtil { public static void configureAuthentication(String role) { Collection<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList(role); Authentication authentication = new UsernamePasswordAuthenticationToken( USERNAME, role, authorities ); SecurityContextHolder.getContext().set... |
### Question:
SerializerFactoryLoader { public static SerializerFactory getFactory(ProcessingEnvironment processingEnv) { return new SerializerFactoryImpl(loadExtensions(processingEnv), processingEnv); } private SerializerFactoryLoader(); static SerializerFactory getFactory(ProcessingEnvironment processingEnv); }### ... |
### Question:
AnnotationValues { public static ImmutableList<DeclaredType> getTypeMirrors(AnnotationValue value) { return TYPE_MIRRORS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror... |
### Question:
AnnotationValues { public static AnnotationMirror getAnnotationMirror(AnnotationValue value) { return AnnotationMirrorVisitor.INSTANCE.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static Annotation... |
### Question:
AnnotationValues { public static ImmutableList<AnnotationMirror> getAnnotationMirrors(AnnotationValue value) { return ANNOTATION_MIRRORS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.