Commit 284fc973 authored by Yannick Kirschhoffer's avatar Yannick Kirschhoffer

Split configuration classes in separate files.

parent cf3944c4
Pipeline #41695902 passed with stages
in 3 minutes and 45 seconds
package org.alcibiade.socializer.configuration.properties;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AccountProperties {
@NotBlank
private String apiKey;
@NotBlank
private String apiSecretKey;
@NotBlank
private String accessTokens;
@NotBlank
private String accessTokenSecret;
private RetweetProperties retweet;
}
package org.alcibiade.socializer.configuration.properties;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class RetweetProperties {
@NotNull
private List<String> filters;
@NotEmpty
private List<String> users;
}
......@@ -4,11 +4,7 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
@Data
@Validated
......@@ -17,33 +13,4 @@ public class SocializerProperties {
@NotNull
private TwitterProperties twitter;
@Data
public static class TwitterProperties {
@NotEmpty
private Map<String, AccountProperties> accounts;
@Data
public static class AccountProperties {
@NotBlank
private String apiKey;
@NotBlank
private String apiSecretKey;
@NotBlank
private String accessTokens;
@NotBlank
private String accessTokenSecret;
private RetweetProperties retweet;
@Data
public static class RetweetProperties {
@NotNull
private List<String> filters;
@NotEmpty
private List<String> users;
}
}
}
}
package org.alcibiade.socializer.configuration.properties;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.Map;
@Data
public class TwitterProperties {
@NotEmpty
private Map<String, AccountProperties> accounts;
}
package org.alcibiade.socializer;
import org.alcibiade.socializer.configuration.properties.AccountProperties;
import org.alcibiade.socializer.configuration.properties.SocializerProperties;
import org.assertj.core.api.Assertions;
import org.junit.Test;
......@@ -21,13 +22,13 @@ public class SocializerApplicationTests {
Assertions.assertThat(properties.getTwitter()).isNotNull();
Assertions.assertThat(properties.getTwitter().getAccounts()).hasSize(2);
SocializerProperties.TwitterProperties.AccountProperties account1 = properties.getTwitter().getAccounts().get("account1");
AccountProperties account1 = properties.getTwitter().getAccounts().get("account1");
Assertions.assertThat(account1.getAccessTokenSecret()).isEqualTo("dddddddddddddddddddddddddddddddddd");
Assertions.assertThat(account1.getRetweet().getFilters()).containsExactly("filterterm");
Assertions.assertThat(account1.getRetweet().getUsers()).containsExactly("retweeteduser1", "retweeteduser2");
SocializerProperties.TwitterProperties.AccountProperties account2 = properties.getTwitter().getAccounts().get("account2");
AccountProperties account2 = properties.getTwitter().getAccounts().get("account2");
Assertions.assertThat(account2.getAccessTokenSecret()).isEqualTo("ffffffffffffffffffffffffffffffffff");
Assertions.assertThat(account2.getRetweet()).isNull();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment