Skip to content

Commit

Permalink
Clean up build.gradle and application
Browse files Browse the repository at this point in the history
- Remove unused variables
- Move Beans used for testing from src to test folder
- Disable bootRepackage
  • Loading branch information
shyamz-22 committed Dec 16, 2017
1 parent d560ea9 commit 01924ad
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ buildscript {
}

apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'org.springframework.boot'

jar {
baseName = 'conditional'
version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand All @@ -26,11 +27,14 @@ repositories {


dependencies {
compile('org.projectlombok:lombok')
compile('org.springframework.boot:spring-boot-starter')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}

bootRepackage {
enabled = false
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.ennovate.condition;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Arrays;
Expand All @@ -13,9 +11,6 @@

public class ActiveOnProfilesCondition implements Condition {

@Autowired
Environment environment;

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
Map<String, Object> attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

Expand All @@ -14,18 +13,15 @@

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles({"A","B"})
@ActiveProfiles({"A", "B"})
public class ConditionalBeanOnProfilesABActiveTests {

@Autowired
Environment environment;
@Autowired
private ConditionalBean conditionalBean;

@Autowired
ConditionalBean conditionalBean;

@Test
public void generatesConditionalBeanAB_onlyWhenBothProfilesAreActive() {
assertThat(conditionalBean.getValue(), equalTo("AB"));
}
@Test
public void generatesConditionalBeanAB_onlyWhenBothProfilesAreActive() {
assertThat(conditionalBean.getValue(), equalTo("AB"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
@ActiveProfiles({"A"})
public class DefaultSpringProfileBehaviorTests {

@Autowired
Environment environment;

@Autowired
ConditionalBean conditionalBean;

Expand Down

0 comments on commit 01924ad

Please sign in to comment.