Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-java"
---

Sync core to microsoft/typespec commit `2e1649b83`. Includes support for nested property paths and XML payloads in Azure pageable responses (core [#11504](https://github.com/microsoft/typespec/pull/11504)).
2 changes: 1 addition & 1 deletion packages/typespec-java/core-commit.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "sha": "38de4f58cffc6429f8ae0234441cbc3b6b429777" }
{ "sha": "2e1649b83df10557748cde848af4c8300582285a" }
9 changes: 0 additions & 9 deletions packages/typespec-java/emitter-tests/Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ Write-Host "Parallelization: $Parallelization"
$generateScript = {
$tspFile = $_

if ((($tspFile -match "payload[\\/]pageable[\\/]main\.tsp") -and (-not ($tspFile -match "azure[\\/]payload[\\/]pageable[\\/]main\.tsp")))) {
Write-Host "
SKIPPED
$tspFile
"
# nested pageItems/nextLink/continuationToken is not supported
return
}

$tspClientFile = $tspFile -replace 'main.tsp', 'client.tsp'
if (($tspClientFile -match 'client.tsp$') -and (Test-Path $tspClientFile)) {
$tspFile = $tspClientFile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package payload.pageable;

import com.azure.core.http.rest.PagedIterable;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import payload.pageable.models.Pet;
import payload.pageable.models.XmlPet;
import payload.pageable.serverdrivenpagination.alternateinitialverb.models.Filter;

public class PageableTests {

private final PageableClientBuilder builder = new PageableClientBuilder();

@Test
public void testLink() {
assertPetIds(builder.buildServerDrivenPaginationClient().link());
}

@Test
public void testLinkString() {
assertPetIds(builder.buildServerDrivenPaginationClient().linkString());
}

@Test
public void testNestedLink() {
assertPetIds(builder.buildServerDrivenPaginationClient().nestedLink());
}

@Test
public void testListWithoutContinuation() {
assertPetIds(builder.buildPageSizeClient().listWithoutContinuation());
}

@Test
public void testListWithPageSize() {
assertPetIds(builder.buildPageSizeClient().listWithPageSize(2), "1", "2");
}

@Test
public void testPost() {
assertPetIds(builder.buildServerDrivenPaginationAlternateInitialVerbClient().post(new Filter("foo eq bar")));
}

@Test
public void testXmlListWithNextLink() {
PagedIterable<XmlPet> pagedIterable = builder.buildXmlPaginationClient().listWithNextLink();

Assertions.assertEquals(List.of("1", "2", "3", "4"),
pagedIterable.stream().map(XmlPet::getId).collect(Collectors.toList()));
}

/*
* Continuation-token scenarios are intentionally not covered here. Azure V1 currently emits a single-page
* PagedIterable for them because it does not propagate a response continuation token into the next request.
*
* XML continuation-token paging is also intentionally not covered because it has the same token propagation
* limitation.
*/

private static void assertPetIds(PagedIterable<Pet> pagedIterable) {
assertPetIds(pagedIterable, "1", "2", "3", "4");
}

private static void assertPetIds(PagedIterable<Pet> pagedIterable, String... expectedIds) {
Assertions.assertEquals(List.of(expectedIds),
pagedIterable.stream().map(Pet::getId).collect(Collectors.toList()));
}
}
Loading