This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf-minho.git


The following commit(s) were added to refs/heads/main by this push:
     new d99234c  [42] Change application type handling in spring-boot 
application manager
     new 4dba38d  Merge pull request #43 from jbonofre/42
d99234c is described below

commit d99234c0c838bcdea2a6ff844df7557a81437219
Author: Jean-Baptiste Onofré <[email protected]>
AuthorDate: Tue Jan 17 21:50:33 2023 +0100

    [42] Change application type handling in spring-boot application manager
---
 .../SpringBootApplicationManagerService.java       |  4 ++--
 .../SpringBootApplicationManagerServiceTest.java   | 26 +++++++++++++++++++---
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git 
a/services/minho-spring-boot/src/main/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerService.java
 
b/services/minho-spring-boot/src/main/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerService.java
index 41b7db2..74a43dc 100644
--- 
a/services/minho-spring-boot/src/main/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerService.java
+++ 
b/services/minho-spring-boot/src/main/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerService.java
@@ -61,7 +61,7 @@ public class SpringBootApplicationManagerService implements 
Service {
         // TODO add shutdown hook
     }
 
-    private List<Application> getApplications(Config config) {
+    protected List<Application> getApplications(Config config) {
         List<Application> applications = new LinkedList<>();
         if (config != null) {
             config.getApplications().forEach(application -> {
@@ -69,7 +69,7 @@ public class SpringBootApplicationManagerService implements 
Service {
                     if (canHandle(application.getUrl())) {
                         applications.add(application);
                     }
-                } else if (application.getType().equals(name())) {
+                } else if (application.getType().equals("spring-boot")) {
                     applications.add(application);
                 }
             });
diff --git 
a/services/minho-spring-boot/src/test/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerServiceTest.java
 
b/services/minho-spring-boot/src/test/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerServiceTest.java
index f6dcdbc..664502a 100644
--- 
a/services/minho-spring-boot/src/test/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerServiceTest.java
+++ 
b/services/minho-spring-boot/src/test/java/org/apache/karaf/minho/springboot/SpringBootApplicationManagerServiceTest.java
@@ -18,14 +18,34 @@
 package org.apache.karaf.minho.springboot;
 
 import org.apache.karaf.minho.boot.Minho;
+import org.apache.karaf.minho.boot.config.Application;
+import org.apache.karaf.minho.boot.service.ConfigService;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
 public class SpringBootApplicationManagerServiceTest {
 
     @Test
-    public void simpleTest() throws Exception {
-        // TODO add spring boot sample app
-        Minho.builder().build().start();
+    public void simpleTypeCheck() throws Exception {
+        ConfigService configService = new ConfigService();
+        List<Application> applications = new ArrayList<>();
+        Application application = new Application();
+        application.setType("spring-boot");
+        application.setName("my-test-app");
+        application.setUrl("mvn:foo/bar/1.0");
+        applications.add(application);
+        configService.setApplications(applications);
+
+        SpringBootApplicationManagerService service = new 
SpringBootApplicationManagerService();
+
+        List<Application> loaded = service.getApplications(configService);
+
+        Assertions.assertEquals(1, loaded.size());
+        Assertions.assertEquals("my-test-app", loaded.get(0).getName());
     }
 
 }

Reply via email to