From 26329ff4f72587cc55d6a2fb6570b2c8e8d8fdff Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Mon, 22 Jul 2019 15:28:09 +0300 Subject: [PATCH 1/3] Groovy Rest example fails due to Unable to find loader for language=xml Fixes #838 --- pkg/trait/dependencies.go | 2 +- pkg/trait/dependencies_test.go | 47 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go index 2fd1a56ff0..67dfec707e 100644 --- a/pkg/trait/dependencies.go +++ b/pkg/trait/dependencies.go @@ -50,7 +50,7 @@ func (t *dependenciesTrait) Apply(e *Environment) error { util.StringSliceUniqueAdd(&dependencies, dep) } } - for _, s := range e.Integration.Spec.Sources { + for _, s := range append(e.Integration.Spec.Sources, e.Integration.Status.GeneratedSources...) { meta := metadata.Extract(e.CamelCatalog, s) switch s.InferLanguage() { diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go index 3744264d61..18549154af 100644 --- a/pkg/trait/dependencies_test.go +++ b/pkg/trait/dependencies_test.go @@ -125,3 +125,50 @@ func TestIntegrationCustomDeps(t *testing.T) { e.Integration.Status.Dependencies, ) } + +func TestIntegrationAutoGeneratedDeps(t *testing.T) { + catalog, err := test.DefaultCatalog() + assert.Nil(t, err) + + e := &Environment{ + CamelCatalog: catalog, + Integration: &v1alpha1.Integration{ + Spec: v1alpha1.IntegrationSpec{ + Sources: []v1alpha1.SourceSpec{ + { + DataSpec: v1alpha1.DataSpec{ + Name: "Request.java", + Content: `from("direct:foo").to("log:bar");`, + }, + Language: v1alpha1.LanguageJavaSource, + }, + }, + }, + Status: v1alpha1.IntegrationStatus{ + Phase: v1alpha1.IntegrationPhaseInitialization, + GeneratedSources: []v1alpha1.SourceSpec{ + { + DataSpec: v1alpha1.DataSpec{ + Name: "RequestAuto.xml", + Content: ``, + }, + Language: v1alpha1.LanguageXML, + }, + }, + }, + }, + } + + trait := newDependenciesTrait() + enabled, err := trait.Configure(e) + assert.Nil(t, err) + assert.True(t, enabled) + + err = trait.Apply(e) + assert.Nil(t, err) + assert.ElementsMatch( + t, + []string{"camel:direct", "camel:log", "mvn:org.apache.camel.k/camel-k-loader-java", "mvn:org.apache.camel.k/camel-k-loader-xml", "mvn:org.apache.camel.k/camel-k-runtime-main"}, + e.Integration.Status.Dependencies, + ) +} \ No newline at end of file From 477e37bea3e8347aae7b76bfa5a6c37ddf03d78f Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Mon, 22 Jul 2019 18:51:57 +0300 Subject: [PATCH 2/3] Fix code --- .gitignore | 1 + pkg/trait/dependencies.go | 2 +- pkg/trait/dependencies_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2513a32962..35ad0f8bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -126,6 +126,7 @@ Session.vim tags ### VisualStudioCode ### +.vscode .vscode/* !.vscode/settings.json !.vscode/tasks.json diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go index 67dfec707e..453806c8dc 100644 --- a/pkg/trait/dependencies.go +++ b/pkg/trait/dependencies.go @@ -50,7 +50,7 @@ func (t *dependenciesTrait) Apply(e *Environment) error { util.StringSliceUniqueAdd(&dependencies, dep) } } - for _, s := range append(e.Integration.Spec.Sources, e.Integration.Status.GeneratedSources...) { + for _, s := range e.Integration.Sources() { meta := metadata.Extract(e.CamelCatalog, s) switch s.InferLanguage() { diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go index 18549154af..102ab920da 100644 --- a/pkg/trait/dependencies_test.go +++ b/pkg/trait/dependencies_test.go @@ -171,4 +171,4 @@ func TestIntegrationAutoGeneratedDeps(t *testing.T) { []string{"camel:direct", "camel:log", "mvn:org.apache.camel.k/camel-k-loader-java", "mvn:org.apache.camel.k/camel-k-loader-xml", "mvn:org.apache.camel.k/camel-k-runtime-main"}, e.Integration.Status.Dependencies, ) -} \ No newline at end of file +} From 13213b9ef9d209392cad24e79b9b3345ec40be42 Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Wed, 24 Jul 2019 10:12:26 +0300 Subject: [PATCH 3/3] Fix lint issue --- pkg/trait/dependencies_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go index 102ab920da..e795fa8037 100644 --- a/pkg/trait/dependencies_test.go +++ b/pkg/trait/dependencies_test.go @@ -168,7 +168,8 @@ func TestIntegrationAutoGeneratedDeps(t *testing.T) { assert.Nil(t, err) assert.ElementsMatch( t, - []string{"camel:direct", "camel:log", "mvn:org.apache.camel.k/camel-k-loader-java", "mvn:org.apache.camel.k/camel-k-loader-xml", "mvn:org.apache.camel.k/camel-k-runtime-main"}, + []string{"camel:direct", "camel:log", "mvn:org.apache.camel.k/camel-k-loader-java", "mvn:org.apache.camel.k/camel-k-loader-xml", + "mvn:org.apache.camel.k/camel-k-runtime-main"}, e.Integration.Status.Dependencies, ) }