-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lisätty kirjastoon lähetyksen vastaanottajien haku
- Loading branch information
Showing
7 changed files
with
143 additions
and
18 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
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 |
---|---|---|
@@ -1,17 +1,20 @@ | ||
package fi.oph.viestinvalitys; | ||
|
||
import fi.oph.viestinvalitys.vastaanotto.model.*; | ||
import fi.oph.viestinvalitys.vastaanotto.resource.VastaanottajaResponseImpl; | ||
import io.netty.handler.codec.http.cookie.Cookie; | ||
import org.asynchttpclient.Dsl; | ||
import org.asynchttpclient.AsyncHttpClient; | ||
import org.asynchttpclient.RequestBuilder; | ||
import org.asynchttpclient.Response; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.env.Environment; | ||
|
||
import java.util.Optional; | ||
import java.util.List; | ||
import java.util.Iterator; | ||
|
||
class ViestinvalitysClientTest extends BaseIntegraatioTesti { | ||
|
||
|
@@ -83,13 +86,15 @@ public void testLuoViesti() throws Exception { | |
|
||
@Test | ||
public void testLiitaLiite() throws Exception { | ||
LuoLiiteSuccessResponse liiteResponse = this.getClient().luoLiite(Liite.builder() | ||
ViestinvalitysClient client = this.getClient(); | ||
|
||
LuoLiiteSuccessResponse liiteResponse = client.luoLiite(Liite.builder() | ||
.withFileName("test") | ||
.withBytes(new byte[] {0}) | ||
.withContentType("image/png") | ||
.build()); | ||
|
||
LuoViestiSuccessResponse viestiResponse = this.getClient().luoViesti(Viesti.builder() | ||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(Viesti.builder() | ||
.withOtsikko("otsikko") | ||
.withTextSisalto("sisältö") | ||
.withKielet("fi") | ||
|
@@ -104,4 +109,36 @@ public void testLiitaLiite() throws Exception { | |
.build()); | ||
} | ||
|
||
@Test | ||
public void testGetVastaanottajat() throws Exception { | ||
ViestinvalitysClient client = this.getClient(); | ||
|
||
LuoViestiSuccessResponse viestiResponse = client.luoViesti(Viesti.builder() | ||
.withOtsikko("otsikko") | ||
.withTextSisalto("sisältö") | ||
.withKielet("fi") | ||
.withLahettaja(Optional.empty(), "[email protected]") | ||
.withVastaanottajat(Vastaanottajat.builder() | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.withVastaanottaja(Optional.empty(), "[email protected]") | ||
.build()) | ||
.withNormaaliPrioriteetti() | ||
.withSailytysAika(10) | ||
.withLahettavaPalvelu("palvelu") | ||
.build()); | ||
|
||
Iterator<List<VastaanottajaResponse>> vastaanottajat = client.getVastaanottajat(viestiResponse.getLahetysTunniste(), Optional.of(1)); | ||
|
||
List<VastaanottajaResponse> vastaanottajat1 = vastaanottajat.next(); | ||
Assertions.assertEquals(1, vastaanottajat1.size()); | ||
Assertions.assertEquals("[email protected]", vastaanottajat1.get(0).getSahkoposti()); | ||
|
||
List<VastaanottajaResponse> vastaanottajat2 = vastaanottajat.next(); | ||
Assertions.assertEquals(1, vastaanottajat2.size()); | ||
Assertions.assertEquals("[email protected]", vastaanottajat2.get(0).getSahkoposti()); | ||
|
||
Assertions.assertFalse(vastaanottajat.hasNext()); | ||
|
||
} | ||
|
||
} |
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
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
23 changes: 23 additions & 0 deletions
23
...japinta/src/main/scala/fi/oph/viestinvalitys/vastaanotto/model/VastaanottajaResponse.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,23 @@ | ||
package fi.oph.viestinvalitys.vastaanotto.model; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import fi.oph.viestinvalitys.vastaanotto.resource.VastaanottajaResponseImpl; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
@JsonDeserialize(as = VastaanottajaResponseImpl.class) | ||
@Schema(implementation = VastaanottajaResponseImpl.class) | ||
public interface VastaanottajaResponse { | ||
|
||
String getTunniste(); | ||
|
||
Optional<String> getNimi(); | ||
|
||
String getSahkoposti(); | ||
|
||
UUID getViestiTunniste(); | ||
|
||
String getTila(); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package fi.oph.viestinvalitys.vastaanotto.resource | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import fi.oph.viestinvalitys.vastaanotto.model.LuoLahetysSuccessResponse | ||
import fi.oph.viestinvalitys.vastaanotto.model.{LuoLahetysSuccessResponse, VastaanottajaResponse} | ||
import fi.oph.viestinvalitys.vastaanotto.resource.APIConstants.{ESIMERKKI_LAHETYSTUNNISTE, EXAMPLE_LAHETYSTUNNISTE_VALIDOINTIVIRHE, EXAMPLE_OTSIKKO_VALIDOINTIVIRHE, LAHETYSTUNNISTE_INVALID} | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
|
@@ -52,25 +52,31 @@ case class PalautaLahetysFailureResponse( | |
class VastaanottajatResponse() {} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_ABSENT) | ||
case class VastaanottajaResponse( | ||
case class VastaanottajaResponseImpl( | ||
@(Schema@field)(example = "3fa85f64-5717-4562-b3fc-2c963f66afa6") | ||
@BeanProperty tunniste: String, | ||
@(Schema@field)(example = "Vallu Vastaanottaja") | ||
@BeanProperty nimi: Optional[String], | ||
@(Schema@field)(example = "[email protected]") | ||
@BeanProperty sahkoposti: String, | ||
@(Schema@field)(example = "b4662fcb-a4a0-4747-b4b9-f3e165d9e626") | ||
@BeanProperty viestiTunniste: String, | ||
@BeanProperty viestiTunniste: UUID, | ||
@(Schema@field)(example = "BOUNCE") | ||
@BeanProperty tila: String | ||
) | ||
) extends VastaanottajaResponse { | ||
|
||
def this() = this(null, null, null, null, null) | ||
} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_ABSENT) | ||
case class VastaanottajatSuccessResponse( | ||
@BeanProperty vastaanottajat: java.util.List[VastaanottajaResponse], | ||
@(Schema@field)(example = "<linkki seuraavaan sivulliseen vastaanottajia>") | ||
@BeanProperty seuraavat: Optional[String], | ||
) extends VastaanottajatResponse | ||
) extends VastaanottajatResponse { | ||
|
||
def this() = this(null, null) | ||
} | ||
|
||
case class VastaanottajatFailureResponse( | ||
@(Schema@field)(example = EXAMPLE_LAHETYSTUNNISTE_VALIDOINTIVIRHE) | ||
|
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