Search in sources :

Example 1 with CVMelding

use of no.nav.pto.veilarbportefolje.cv.dto.CVMelding in project veilarbportefolje by navikt.

the class CvServiceTest method skal_ikke_behandle_meldinger_som_har_meldingstype_arbeidsgiver_generell.

@Test
void skal_ikke_behandle_meldinger_som_har_meldingstype_arbeidsgiver_generell() {
    String document = new JSONObject().put("aktoer_id", aktoerId.toString()).put("har_delt_cv", false).toString();
    IndexResponse indexResponse = opensearchTestClient.createDocument(aktoerId, document);
    assertThat(indexResponse.status().getStatus()).isEqualTo(201);
    CVMelding cvMelding = new CVMelding();
    cvMelding.setAktoerId(aktoerId);
    cvMelding.setRessurs(Ressurs.ARBEIDSGIVER_GENERELL);
    cvService.behandleCVHjemmelMelding(cvMelding);
    GetResponse getResponse = opensearchTestClient.fetchDocument(aktoerId);
    assertThat(getResponse.isExists()).isTrue();
    boolean harDeltCv = (boolean) getResponse.getSourceAsMap().get("har_delt_cv");
    assertThat(harDeltCv).isFalse();
}
Also used : JSONObject(org.json.JSONObject) IndexResponse(org.opensearch.action.index.IndexResponse) CVMelding(no.nav.pto.veilarbportefolje.cv.dto.CVMelding) GetResponse(org.opensearch.action.get.GetResponse) EndToEndTest(no.nav.pto.veilarbportefolje.util.EndToEndTest) Test(org.junit.jupiter.api.Test)

Example 2 with CVMelding

use of no.nav.pto.veilarbportefolje.cv.dto.CVMelding in project veilarbportefolje by navikt.

the class CvServiceKafkaConsumerTest method populateCVEksistereKafkaTopic.

private void populateCVEksistereKafkaTopic(AktorId... aktoerIds) throws ExecutionException, InterruptedException {
    for (AktorId aktoerId : aktoerIds) {
        Melding cvMelding = new Melding();
        cvMelding.setAktoerId(aktoerId.toString());
        cvMelding.setMeldingstype(Meldingstype.ENDRE);
        cvService.behandleKafkaMeldingLogikk(cvMelding);
    }
}
Also used : CVMelding(no.nav.pto.veilarbportefolje.cv.dto.CVMelding) Melding(no.nav.arbeid.cv.avro.Melding) AktorId(no.nav.common.types.identer.AktorId)

Example 3 with CVMelding

use of no.nav.pto.veilarbportefolje.cv.dto.CVMelding in project veilarbportefolje by navikt.

the class CVService method behandleKafkaMeldingCVHjemmel.

public void behandleKafkaMeldingCVHjemmel(ConsumerRecord<String, CVMelding> kafkaMelding) {
    log.info("Behandler kafka-melding med key {} og offset {} på topic {}", kafkaMelding.key(), kafkaMelding.offset(), kafkaMelding.topic());
    CVMelding cvMelding = kafkaMelding.value();
    behandleCVHjemmelMelding(cvMelding);
}
Also used : CVMelding(no.nav.pto.veilarbportefolje.cv.dto.CVMelding)

Example 4 with CVMelding

use of no.nav.pto.veilarbportefolje.cv.dto.CVMelding in project veilarbportefolje by navikt.

the class CvServiceTest method skal_ikke_behandle_meldinger_som_har_meldingstype_cv_generell.

@Test
void skal_ikke_behandle_meldinger_som_har_meldingstype_cv_generell() {
    String document = new JSONObject().put("aktoer_id", aktoerId.toString()).put("har_delt_cv", false).toString();
    IndexResponse indexResponse = opensearchTestClient.createDocument(aktoerId, document);
    assertThat(indexResponse.status().getStatus()).isEqualTo(201);
    CVMelding cvMelding = new CVMelding();
    cvMelding.setAktoerId(aktoerId);
    cvMelding.setRessurs(Ressurs.CV_GENERELL);
    cvService.behandleCVHjemmelMelding(cvMelding);
    GetResponse getResponse = opensearchTestClient.fetchDocument(aktoerId);
    assertThat(getResponse.isExists()).isTrue();
    boolean harDeltCv = (boolean) getResponse.getSourceAsMap().get("har_delt_cv");
    assertThat(harDeltCv).isFalse();
}
Also used : JSONObject(org.json.JSONObject) IndexResponse(org.opensearch.action.index.IndexResponse) CVMelding(no.nav.pto.veilarbportefolje.cv.dto.CVMelding) GetResponse(org.opensearch.action.get.GetResponse) EndToEndTest(no.nav.pto.veilarbportefolje.util.EndToEndTest) Test(org.junit.jupiter.api.Test)

Example 5 with CVMelding

use of no.nav.pto.veilarbportefolje.cv.dto.CVMelding in project veilarbportefolje by navikt.

the class CvServiceTest method skal_oppdatere_dokumentet_i_db_og_opensearch.

@Test
void skal_oppdatere_dokumentet_i_db_og_opensearch() {
    String document = new JSONObject().put("aktoer_id", aktoerId.toString()).put("har_delt_cv", false).toString();
    IndexResponse indexResponse = opensearchTestClient.createDocument(aktoerId, document);
    assertThat(indexResponse.status().getStatus()).isEqualTo(201);
    CVMelding cvMelding = new CVMelding();
    cvMelding.setAktoerId(aktoerId);
    cvMelding.setRessurs(Ressurs.CV_HJEMMEL);
    cvService.behandleCVHjemmelMelding(cvMelding);
    Boolean harDeltCvDb = cvRepository.harDeltCv(aktoerId);
    assertThat(harDeltCvDb).isTrue();
    GetResponse getResponse = opensearchTestClient.fetchDocument(aktoerId);
    assertThat(getResponse.isExists()).isTrue();
    boolean harDeltCv = (boolean) getResponse.getSourceAsMap().get("har_delt_cv");
    assertThat(harDeltCv).isTrue();
}
Also used : JSONObject(org.json.JSONObject) IndexResponse(org.opensearch.action.index.IndexResponse) CVMelding(no.nav.pto.veilarbportefolje.cv.dto.CVMelding) GetResponse(org.opensearch.action.get.GetResponse) EndToEndTest(no.nav.pto.veilarbportefolje.util.EndToEndTest) Test(org.junit.jupiter.api.Test)

Aggregations

CVMelding (no.nav.pto.veilarbportefolje.cv.dto.CVMelding)8 EndToEndTest (no.nav.pto.veilarbportefolje.util.EndToEndTest)5 Test (org.junit.jupiter.api.Test)5 GetResponse (org.opensearch.action.get.GetResponse)5 JSONObject (org.json.JSONObject)4 IndexResponse (org.opensearch.action.index.IndexResponse)4 AktorId (no.nav.common.types.identer.AktorId)2 Melding (no.nav.arbeid.cv.avro.Melding)1