Skip to content

Commit

Permalink
Fixed platform stream selection when platform key is null
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Jan 7, 2022
1 parent 23388b9 commit 4514310
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package io.quarkus.devtools.project.create;

import io.quarkus.devtools.testing.registry.client.TestRegistryClientBuilder;
import io.quarkus.maven.ArtifactCoords;
import io.quarkus.registry.catalog.PlatformStreamCoords;
import java.nio.file.Path;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class UpstreamStreamCoordsWithNullPlatformKeyTest extends MultiplePlatformBomsTestBase {

private static final String DOWNSTREAM_PLATFORM_KEY = "io.downstream.platform";
private static final String UPSTREAM_PLATFORM_KEY = "io.upstream.platform";

@BeforeAll
public static void setup() throws Exception {
TestRegistryClientBuilder.newInstance()
//.debug()
.baseDir(configDir())
// registry
.newRegistry("downstream.registry.test")
.recognizedQuarkusVersions("*-downstream")
// platform key
.newPlatform(DOWNSTREAM_PLATFORM_KEY)
.newStream("1.0")
// 1.0.4 release
.newRelease("1.1.1-downstream")
.quarkusVersion("1.1.1-downstream")
.upstreamQuarkusVersion("1.1.1")
// default bom including quarkus-core + essential metadata
.addCoreMember()
// foo platform member
.newMember("acme-a-bom").addExtension("io.acme", "ext-a", "1.1.1-downstream").release()
.stream().platform().registry()
.clientBuilder()
.newRegistry("upstream.registry.test")
// platform key
.newPlatform(UPSTREAM_PLATFORM_KEY)
// 2.0 STREAM
.newStream("2.0")
// 2.0.5 release
.newRelease("2.0.5")
.quarkusVersion("2.0.5")
// default bom including quarkus-core + essential metadata
.addCoreMember()
.newMember("acme-a-bom").addExtension("io.acme", "ext-a", "2.0.5").release().stream().platform()
// 1.0 STREAM
.newStream("1.0")
.newRelease("1.1.1")
.quarkusVersion("1.1.1")
// default bom including quarkus-core + essential metadata
.addCoreMember()
.newMember("acme-a-bom").addExtension("io.acme", "ext-a", "1.1.1")
.registry()
.clientBuilder()
.build();

enableRegistryClient();
}

protected String getMainPlatformKey() {
return UPSTREAM_PLATFORM_KEY;
}

@Test
public void createUsingStream2_0() throws Exception {
final Path projectDir = newProjectDir("created-using-upstream-2.0");
createProject(projectDir, new PlatformStreamCoords(null, "2.0"), List.of("ext-a"));

assertModel(projectDir,
List.of(mainPlatformBom(), platformMemberBomCoords("acme-a-bom")),
List.of(new ArtifactCoords("io.acme", "ext-a", null)),
"2.0.5");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public ExtensionCatalog resolveExtensionCatalog(PlatformStreamCoords streamCoord

PlatformStream stream = null;
int registryIndex = 0;
while (registryIndex < registries.size()) {
while (registryIndex < registries.size() && stream == null) {
final RegistryExtensionResolver qer = registries.get(registryIndex++);
final PlatformCatalog platforms = qer.resolvePlatformCatalog();
if (platforms == null) {
Expand All @@ -508,8 +508,10 @@ public ExtensionCatalog resolveExtensionCatalog(PlatformStreamCoords streamCoord
continue;
}
stream = platform.getStream(streamId);
if (stream != null) {
break;
}
}
break;
}

if (stream == null) {
Expand Down

0 comments on commit 4514310

Please sign in to comment.