From 432643f115a4682c290ecd07b125e7b5c6045779 Mon Sep 17 00:00:00 2001 From: Loredana Date: Sat, 15 Dec 2018 18:59:23 +0200 Subject: [PATCH] remove flips module --- flips/README.md | 1 - flips/pom.xml | 65 ---------------- .../com/baeldung/flips/ApplicationConfig.java | 15 ---- .../flips/controller/FlipController.java | 65 ---------------- .../java/com/baeldung/flips/model/Foo.java | 12 --- .../baeldung/flips/service/FlipService.java | 50 ------------- .../flips/service/NewFlipService.java | 13 ---- .../src/main/resources/application.properties | 5 -- flips/src/main/resources/logback.xml | 13 ---- .../FlipControllerIntegrationTest.java | 74 ------------------- pom.xml | 2 - 11 files changed, 315 deletions(-) delete mode 100644 flips/README.md delete mode 100644 flips/pom.xml delete mode 100644 flips/src/main/java/com/baeldung/flips/ApplicationConfig.java delete mode 100644 flips/src/main/java/com/baeldung/flips/controller/FlipController.java delete mode 100644 flips/src/main/java/com/baeldung/flips/model/Foo.java delete mode 100644 flips/src/main/java/com/baeldung/flips/service/FlipService.java delete mode 100644 flips/src/main/java/com/baeldung/flips/service/NewFlipService.java delete mode 100644 flips/src/main/resources/application.properties delete mode 100644 flips/src/main/resources/logback.xml delete mode 100644 flips/src/test/java/com/baeldung/flips/controller/FlipControllerIntegrationTest.java diff --git a/flips/README.md b/flips/README.md deleted file mode 100644 index 7d843af9ea..0000000000 --- a/flips/README.md +++ /dev/null @@ -1 +0,0 @@ -### Relevant Articles: diff --git a/flips/pom.xml b/flips/pom.xml deleted file mode 100644 index 75dc8bb579..0000000000 --- a/flips/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - 4.0.0 - flips - flips - 0.0.1-SNAPSHOT - jar - flips - - - parent-boot-1 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-1 - - - - - org.springframework.boot - spring-boot-starter-web - ${spring-boot-starter-web.version} - - - org.springframework.boot - spring-boot-starter-test - ${spring-boot-starter-test.version} - - - com.github.feature-flip - flips-web - ${flips-web.version} - - - org.projectlombok - lombok - - ${lombok.version} - provided - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - - - 1.5.10.RELEASE - 1.5.9.RELEASE - 1.0.1 - 1.16.18 - - - diff --git a/flips/src/main/java/com/baeldung/flips/ApplicationConfig.java b/flips/src/main/java/com/baeldung/flips/ApplicationConfig.java deleted file mode 100644 index 7001aeb991..0000000000 --- a/flips/src/main/java/com/baeldung/flips/ApplicationConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.flips; - -import org.flips.describe.config.FlipWebContextConfiguration; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Import; - -@SpringBootApplication -@Import(FlipWebContextConfiguration.class) -public class ApplicationConfig { - - public static void main(String[] args) { - SpringApplication.run(ApplicationConfig.class, args); - } -} \ No newline at end of file diff --git a/flips/src/main/java/com/baeldung/flips/controller/FlipController.java b/flips/src/main/java/com/baeldung/flips/controller/FlipController.java deleted file mode 100644 index 50458023b3..0000000000 --- a/flips/src/main/java/com/baeldung/flips/controller/FlipController.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.baeldung.flips.controller; - -import com.baeldung.flips.model.Foo; -import com.baeldung.flips.service.FlipService; -import org.flips.annotation.FlipOnDateTime; -import org.flips.annotation.FlipOnDaysOfWeek; -import org.flips.annotation.FlipOnEnvironmentProperty; -import org.flips.annotation.FlipOnProfiles; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import java.time.DayOfWeek; -import java.util.List; - -@RestController -public class FlipController { - - private FlipService flipService; - - @Autowired - public FlipController(FlipService flipService) { - this.flipService = flipService; - } - - @RequestMapping(value = "/foos", method = RequestMethod.GET) - @FlipOnProfiles(activeProfiles = "dev") - public List getAllFoos() { - return flipService.getAllFoos(); - } - - @RequestMapping(value = "/foo/{id}", method = RequestMethod.GET) - @FlipOnDaysOfWeek(daysOfWeek = { - DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, - DayOfWeek.FRIDAY, DayOfWeek.SATURDAY, DayOfWeek.SUNDAY - }) - public Foo getFooByNewId(@PathVariable int id) { - return flipService.getFooById(id).orElse(new Foo("Not Found", -1)); - } - - @RequestMapping(value = "/foo/last", method = RequestMethod.GET) - @FlipOnDateTime(cutoffDateTimeProperty = "last.active.after") - public Foo getLastFoo() { - return flipService.getLastFoo(); - } - - @RequestMapping(value = "/foo/first", method = RequestMethod.GET) - @FlipOnDateTime(cutoffDateTimeProperty = "first.active.after") - public Foo getFirstFoo() { - return flipService.getLastFoo(); - } - - @RequestMapping(value = "/foos/{id}", method = RequestMethod.GET) - @FlipOnEnvironmentProperty(property = "feature.foo.by.id", expectedValue = "Y") - public Foo getFooById(@PathVariable int id) { - return flipService.getFooById(id).orElse(new Foo("Not Found", -1)); - } - - @RequestMapping(value = "/foo/new", method = RequestMethod.GET) - public Foo getNewThing() { - return flipService.getNewFoo(); - } -} \ No newline at end of file diff --git a/flips/src/main/java/com/baeldung/flips/model/Foo.java b/flips/src/main/java/com/baeldung/flips/model/Foo.java deleted file mode 100644 index be15bee15c..0000000000 --- a/flips/src/main/java/com/baeldung/flips/model/Foo.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.flips.model; - -import lombok.Data; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -@Data -@RequiredArgsConstructor -public class Foo { - @NonNull private final String name; - @NonNull private final int id; -} diff --git a/flips/src/main/java/com/baeldung/flips/service/FlipService.java b/flips/src/main/java/com/baeldung/flips/service/FlipService.java deleted file mode 100644 index 9f7fb325a5..0000000000 --- a/flips/src/main/java/com/baeldung/flips/service/FlipService.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.baeldung.flips.service; - -import com.baeldung.flips.model.Foo; -import org.flips.annotation.FlipBean; -import org.flips.annotation.FlipOnSpringExpression; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -@Service -public class FlipService { - - private final List foos; - - public FlipService() { - foos = new ArrayList<>(); - foos.add(new Foo("Foo1", 1)); - foos.add(new Foo("Foo2", 2)); - foos.add(new Foo("Foo3", 3)); - foos.add(new Foo("Foo4", 4)); - foos.add(new Foo("Foo5", 5)); - foos.add(new Foo("Foo6", 6)); - - } - - public List getAllFoos() { - return foos; - } - - public Optional getFooById(int id) { - return foos.stream().filter(foo -> (foo.getId() == id)).findFirst(); - } - - @FlipBean(with = NewFlipService.class) - @FlipOnSpringExpression(expression = "(2 + 2) == 4") - public Foo getNewFoo() { - return new Foo("New Foo!", 99); - } - - public Foo getLastFoo() { - return foos.get(foos.size() - 1); - } - - public Foo getFirstFoo() { - return foos.get(0); - } - -} \ No newline at end of file diff --git a/flips/src/main/java/com/baeldung/flips/service/NewFlipService.java b/flips/src/main/java/com/baeldung/flips/service/NewFlipService.java deleted file mode 100644 index 1dcda9b6ca..0000000000 --- a/flips/src/main/java/com/baeldung/flips/service/NewFlipService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.flips.service; - -import com.baeldung.flips.model.Foo; -import org.springframework.stereotype.Service; - -@Service -public class NewFlipService { - - public Foo getNewFoo() { - return new Foo("Shiny New Foo!", 100); - } - -} \ No newline at end of file diff --git a/flips/src/main/resources/application.properties b/flips/src/main/resources/application.properties deleted file mode 100644 index 274896be15..0000000000 --- a/flips/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -feature.foo.by.id=Y -feature.new.foo=Y -last.active.after=2018-03-14T00:00:00Z -first.active.after=2999-03-15T00:00:00Z -logging.level.org.flips=info \ No newline at end of file diff --git a/flips/src/main/resources/logback.xml b/flips/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/flips/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/flips/src/test/java/com/baeldung/flips/controller/FlipControllerIntegrationTest.java b/flips/src/test/java/com/baeldung/flips/controller/FlipControllerIntegrationTest.java deleted file mode 100644 index 9dd4ef064a..0000000000 --- a/flips/src/test/java/com/baeldung/flips/controller/FlipControllerIntegrationTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.baeldung.flips.controller; - -import org.hamcrest.Matchers; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; - -@RunWith(SpringRunner.class) -@SpringBootTest(properties = { - "feature.foo.by.id=Y", - "feature.new.foo=Y", - "last.active.after=2018-03-14T00:00:00Z", - "first.active.after=2999-03-15T00:00:00Z", - "logging.level.org.flips=info" - -}, webEnvironment = SpringBootTest.WebEnvironment.MOCK) -@AutoConfigureMockMvc -@ActiveProfiles("dev") -public class FlipControllerIntegrationTest { - - @Autowired private MockMvc mvc; - - @Test - public void givenValidDayOfWeek_APIAvailable() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foo/1")) - .andExpect(MockMvcResultMatchers.status().is(200)) - .andExpect(MockMvcResultMatchers.jsonPath("$.name", Matchers.equalTo("Foo1"))) - .andExpect(MockMvcResultMatchers.jsonPath("$.id", Matchers.equalTo(1))); - } - - @Test - public void givenValidDate_APIAvailable() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foo/last")) - .andExpect(MockMvcResultMatchers.status().is(200)) - .andExpect(MockMvcResultMatchers.jsonPath("$.name", Matchers.equalTo("Foo6"))) - .andExpect(MockMvcResultMatchers.jsonPath("$.id", Matchers.equalTo(6))); - } - - @Test - public void givenInvalidDate_APINotAvailable() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foo/first")) - .andExpect(MockMvcResultMatchers.status().is(501)); - } - - @Test - public void givenCorrectProfile_APIAvailable() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foos")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andExpect(MockMvcResultMatchers.jsonPath("$", Matchers.hasSize(6))); - } - - @Test - public void givenPropertySet_APIAvailable() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foos/1")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andExpect(MockMvcResultMatchers.jsonPath("$.name", Matchers.equalTo("Foo1"))) - .andExpect(MockMvcResultMatchers.jsonPath("$.id", Matchers.equalTo(1))); - } - - @Test - public void getValidExpression_FlipBean() throws Exception { - mvc.perform(MockMvcRequestBuilders.get("/foo/new")) - .andExpect(MockMvcResultMatchers.status().is(200)) - .andExpect(MockMvcResultMatchers.jsonPath("$.name", Matchers.equalTo("Shiny New Foo!"))) - .andExpect(MockMvcResultMatchers.jsonPath("$.id", Matchers.equalTo(100))); - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bab3fc2317..643496e482 100644 --- a/pom.xml +++ b/pom.xml @@ -397,7 +397,6 @@ ethereum feign - flips flyway-cdi-extension @@ -1108,7 +1107,6 @@ ethereum feign - flips flyway-cdi-extension