<commit_before>package com.zandero.rest;
/*

import com.zandero.rest.test.TestHtmlRest;
import com.zandero.rest.test.TestPostRest;
import com.zandero.rest.test.TestRest;
import com.zandero.rest.test.json.Dummy;
import com.zandero.rest.writer.TestCustomWriter;
import com.zandero.rest.writer.TestDummyWriter;
import com.zandero.utils.extra.JsonUtils;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.ext.web.Router;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ws.rs.core.MediaType;

*/
/**
 *
 *//*

@RunWith(VertxUnitRunner.class)
public class CustomWriterTest extends VertxTest {

	@Before
	public void setUp(TestContext context) {

		super.before();

		Router router = RestRouter.register(vertx,
		                                    TestRest.class,
		                                    TestHtmlRest.class,
		                                    TestPostRest.class);
		vertx.createHttpServer()
		     .requestHandler(router::accept)
		     .listen(PORT);
	}

	@Test
	public void testCustomOutput(TestContext context) {

		// call and check response
		final Async async = context.async();

		client.getNow("/test/custom", response -> {

			context.assertEquals(200, response.statusCode());

			response.bodyHandler(body -> {
				context.assertEquals("<custom>CUSTOM</custom>", body.toString());
				async.complete();
			});
		});
	}

	@Test
	public void testRegisteredContentTypeWriterOutput(TestContext context) {

		RestRouter.getWriters().register(MediaType.TEXT_HTML, TestCustomWriter.class); // bind media type to this writer

		final Async async = context.async();

		client.getNow("/html/body", response -> {

			context.assertEquals(200, response.statusCode());
			context.assertEquals(MediaType.TEXT_HTML, response.getHeader("Content-Type"));

			response.bodyHandler(body -> {
				context.assertEquals("<custom>body</custom>", body.toString());
				async.complete();
			});
		});
	}

	@Test
	public void testProducesOnExperimentalGet(TestContext context) {

		RestRouter.getWriters().register(MediaType.TEXT_HTML, TestCustomWriter.class); // bind media type to this writer

		final Async async = context.async();

		client.getNow("/html/head", response -> {

			context.assertEquals(200, response.statusCode());
			context.assertEquals(MediaType.TEXT_HTML, response.getHeader("Content-Type"));

			response.bodyHandler(body -> {
				context.assertEquals("<custom>head</custom>", body.toString());
				async.complete();
			});
		});
	}

	@Test
	public void testRegisteredClassTypeWriterOutput(TestContext context) {

		RestRouter.getWriters().register(Dummy.class, TestDummyWriter.class); // bind media type to this writer

		final Async async = context.async();

		Dummy dummy = new Dummy("hello", "world");
		String json = JsonUtils.toJson(dummy);

		client.post("/post/json", response -> {

			context.assertEquals(200, response.statusCode());
			context.assertEquals("application/json;charset=utf-8", response.getHeader("Content-Type"));

			response.bodyHandler(body -> {
				context.assertEquals("<custom>Received-hello=Received-world</custom>", body.toString());
				async.complete();
			});
		}).putHeader("Content-Type", "application/json").end(json);
	}

	@Test
	public void testRegisteredClassTypeReaderOutput(TestContext context) {

		final Async async = context.async();

		Dummy dummy = new Dummy("hello", "world");
		String json = JsonUtils.toJson(dummy);

		client.put("/post/json", response -> {

			context.assertEquals(200, response.statusCode());
			context.assertEquals(MediaType.APPLICATION_JSON, response.getHeader("Content-Type"));

			response.bodyHandler(body -> {
				context.assertEquals("<custom>Received-hello=Received-world</custom>", body.toString());
				async.complete();
			});
		}).putHeader("Content-Type", "application/json").end(json);
	}
}
*/<commit_msg>Migrating CustomWriterTest to JUnit 5<commit_after>package com.zandero.rest;

import com.zandero.rest.test.TestHtmlRest;
import com.zandero.rest.test.TestPostRest;
import com.zandero.rest.test.TestRest;
import com.zandero.rest.test.json.Dummy;
import com.zandero.rest.writer.TestCustomWriter;
import com.zandero.rest.writer.TestDummyWriter;
import com.zandero.utils.extra.JsonUtils;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.codec.BodyCodec;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import javax.ws.rs.core.MediaType;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 *
 */
@ExtendWith(VertxExtension.class)
class CustomWriterTest extends VertxTest {

    @BeforeEach
    void start() {

        super.before();

        Router router = RestRouter.register(vertx,
                TestRest.class,
                TestHtmlRest.class,
                TestPostRest.class);

        vertx.createHttpServer()
                .requestHandler(router)
                .listen(PORT);
    }

    @Test
    void testCustomOutput(VertxTestContext context) {

        client.get(PORT, HOST, "/test/custom")
                .as(BodyCodec.string())
                .send(context.succeeding(response -> context.verify(() -> {
                    assertEquals(200, response.statusCode());
                    assertEquals("<custom>CUSTOM</custom>", response.body());
                    context.completeNow();
                })));
    }

    @Test
    void testRegisteredContentTypeWriterOutput(VertxTestContext context) {

        RestRouter.getWriters().register(MediaType.TEXT_HTML, TestCustomWriter.class); // bind media type to this writer

        client.get(PORT, HOST, "/html/body")
                .as(BodyCodec.string())
                .send(context.succeeding(response -> context.verify(() -> {
                    assertEquals(200, response.statusCode());
                    assertEquals(MediaType.TEXT_HTML, response.getHeader("Content-Type"));
                    assertEquals("<custom>body</custom>", response.body());
                    context.completeNow();
                })));
    }

    @Test
    void testProducesOnExperimentalGet(VertxTestContext context) {

        RestRouter.getWriters().register(MediaType.TEXT_HTML, TestCustomWriter.class); // bind media type to this writer

        client.get(PORT, HOST, "/html/head").as(BodyCodec.string())
                .send(context.succeeding(response -> context.verify(() -> {

                    assertEquals(200, response.statusCode());
                    assertEquals(MediaType.TEXT_HTML, response.getHeader("Content-Type"));

                    assertEquals("<custom>head</custom>", response.body());
                    context.completeNow();
                })));
    }

    @Test
    void testRegisteredClassTypeWriterOutput(VertxTestContext context) {

        RestRouter.getWriters().register(Dummy.class, TestDummyWriter.class); // bind media type to this writer


        Dummy dummy = new Dummy("hello", "world");
        String json = JsonUtils.toJson(dummy);

        client.post(PORT, HOST,"/post/json")
                .as(BodyCodec.string())
                .putHeader("Content-Type", "application/json")
                .sendBuffer(Buffer.buffer(json),
                        context.succeeding(response -> context.verify(() -> {

                            assertEquals(200, response.statusCode());
                            assertEquals("application/json;charset=utf-8", response.getHeader("Content-Type"));
                            assertEquals("<custom>Received-hello=Received-world</custom>", response.body());
                            context.completeNow();
                        })));
    }

    @Test
    void testRegisteredClassTypeReaderOutput(VertxTestContext context) {

        Dummy dummy = new Dummy("hello", "world");
        String json = JsonUtils.toJson(dummy);

        client.put(PORT, HOST, "/post/json")
                .as(BodyCodec.string())
                .putHeader("Content-Type", "application/json")
                .sendBuffer(Buffer.buffer(json), context.succeeding(response -> context.verify(() -> {

                    assertEquals(200, response.statusCode());
                    assertEquals(MediaType.APPLICATION_JSON, response.getHeader("Content-Type"));
                    assertEquals("<custom>Received-hello=Received-world</custom>", response.body());
                    context.completeNow();
                })));
    }
}
{'fraction_non_alphanumeric': 0.13529479902698946, 'fraction_numerical': 0.004054210587281362, 'mean_word_length': 2.906787330316742, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1786027', 'n_tokens_mistral': 2591, 'n_tokens_neox': 2359, 'n_words': 380}