package com.auth0.client.mgmt;

import com.auth0.json.mgmt.jobs.Job;
import com.auth0.net.Request;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.Test;

import java.util.Map;

import static com.auth0.client.MockServer.*;
import static com.auth0.client.RecordedRequestMatcher.hasHeader;
import static com.auth0.client.RecordedRequestMatcher.hasMethodAndPath;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;

public class JobsEntityTest extends BaseMgmtEntityTest {

    @Test
    public void shouldSendAUserAVerificationEmail() throws Exception {
        Request<Job> request = api.jobs().sendVerificationEmail("google-oauth2|1234", null);
        assertThat(request, is(notNullValue()));

        server.jsonResponse(MGMT_JOB_POST_VERIFICATION_EMAIL, 200);
        Job response = request.execute();
        RecordedRequest recordedRequest = server.takeRequest();

        assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/verification-email"));
        assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
        assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));

        Map<String, Object> body = bodyFromRequest(recordedRequest);
        assertThat(body.size(), is(1));
        assertThat(body, hasEntry("user_id", (Object) "google-oauth2|1234"));

        assertThat(response, is(notNullValue()));
    }

    @Test
    public void shouldThrowOnNullEmailRecipient() throws Exception {
        exception.expect(IllegalArgumentException.class);
        exception.expectMessage("'recipient' cannot be null!");
        api.jobs().sendVerificationEmail(null, null);
    }
}

@@ -1518,16 +1518,1044 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void shouldSendUserAVerificationEmailWithClientId() throws Exception %7B%0A        Request%3CJob%3E request = api.jobs().sendVerificationEmail(%22google-oauth2%7C1234%22, %22google-oauth2%7Cclient-id%22);%0A        assertThat(request, is(notNullValue()));%0A%0A        server.jsonResponse(MGMT_JOB_POST_VERIFICATION_EMAIL, 200);%0A        Job response = request.execute();%0A        RecordedRequest recordedRequest = server.takeRequest();%0A%0A        assertThat(recordedRequest, hasMethodAndPath(%22POST%22, %22/api/v2/jobs/verification-email%22));%0A        assertThat(recordedRequest, hasHeader(%22Content-Type%22, %22application/json%22));%0A        assertThat(recordedRequest, hasHeader(%22Authorization%22, %22Bearer apiToken%22));%0A%0A        Map%3CString, Object%3E body = bodyFromRequest(recordedRequest);%0A        assertThat(body.size(), is(2));%0A        assertThat(body, hasEntry(%22user_id%22, (Object) %22google-oauth2%7C1234%22));%0A        assertThat(body, hasEntry(%22client_id%22, (Object) %22google-oauth2%7Cclient-id%22));%0A%0A        assertThat(response, is(notNullValue()));%0A    %7D%0A%0A
     @Tes

Add test for scenario when clientId is specified