diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolver.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolver.java index b5b8098044..96d1c0c154 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolver.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolver.java @@ -24,7 +24,7 @@ import org.eclipse.che.api.factory.server.scm.AuthorisationRequestManager; import org.eclipse.che.api.factory.server.urlfactory.RemoteFactoryUrl; import org.eclipse.che.api.factory.server.urlfactory.URLFactoryBuilder; -import org.eclipse.che.api.factory.shared.dto.FactoryDto; +import org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto; import org.eclipse.che.api.factory.shared.dto.FactoryMetaDto; import org.eclipse.che.api.factory.shared.dto.FactoryVisitor; import org.eclipse.che.api.workspace.server.devfile.FileContentProvider; @@ -60,7 +60,12 @@ protected FactoryMetaDto createFactory( contentProvider, extractOverrideParams(factoryParameters), getSkipAuthorisation(factoryParameters)) - .orElseGet(() -> newDto(FactoryDto.class).withV(CURRENT_VERSION).withSource("repo")) + .orElseGet( + () -> + newDto(FactoryDevfileV2Dto.class) + .withDevfile(Map.of("schemaVersion", "2.3.0")) + .withV(CURRENT_VERSION) + .withSource("repo")) .acceptVisitor(factoryVisitor); } diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolverTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolverTest.java index 105de8e5f3..e9293f8617 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolverTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/BaseFactoryParameterResolverTest.java @@ -12,14 +12,20 @@ package org.eclipse.che.api.factory.server; import static java.util.Collections.emptyMap; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Map; import org.eclipse.che.api.factory.server.scm.AuthorisationRequestManager; +import org.eclipse.che.api.factory.server.urlfactory.RemoteFactoryUrl; import org.eclipse.che.api.factory.server.urlfactory.URLFactoryBuilder; +import org.eclipse.che.api.factory.shared.dto.FactoryDevfileV2Dto; +import org.eclipse.che.api.factory.shared.dto.FactoryVisitor; +import org.eclipse.che.api.workspace.server.devfile.FileContentProvider; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -31,7 +37,9 @@ public class BaseFactoryParameterResolverTest { @Mock private AuthorisationRequestManager authorisationRequestManager; @Mock private URLFactoryBuilder urlFactoryBuilder; - + @Mock private RemoteFactoryUrl remoteFactoryUrl; + @Mock private FactoryVisitor factoryVisitor; + @Mock private FileContentProvider contentProvider; private static final String PROVIDER_NAME = "test"; private BaseFactoryParameterResolver baseFactoryParameterResolver; @@ -73,4 +81,15 @@ public void shouldReturnTrueOnGetSkipAuthorisationFromFactoryParams() { // then assertTrue(result); } + + @Test + public void shouldReturnDevfileV2() throws Exception { + // given + when(authorisationRequestManager.isStored(eq(PROVIDER_NAME))).thenReturn(false); + // when + baseFactoryParameterResolver.createFactory( + emptyMap(), remoteFactoryUrl, factoryVisitor, contentProvider); + // then + verify(factoryVisitor).visit(any(FactoryDevfileV2Dto.class)); + } }