Commit cf3944c4 authored by Yannick Kirschhoffer's avatar Yannick Kirschhoffer

Additional application properties for retweets.

parent 3186bb9d
Pipeline #41695728 passed with stages
in 3 minutes and 31 seconds
......@@ -5,7 +5,9 @@ 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
......@@ -17,6 +19,7 @@ public class SocializerProperties {
@Data
public static class TwitterProperties {
@NotEmpty
private Map<String, AccountProperties> accounts;
@Data
......@@ -29,6 +32,16 @@ public class SocializerProperties {
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;
}
}
}
......
......@@ -17,7 +17,7 @@ public class RetweetJob {
this.twitterService = twitterService;
}
@Scheduled(initialDelay = 5_000L, fixedRate = 3600_000L)
@Scheduled(initialDelay = 10_000L, fixedRate = 3600_000L)
@Transactional
public void retweet() {
twitterService.retweet();
......
......@@ -19,10 +19,18 @@ public class SocializerApplicationTests {
public void contextLoads() {
Assertions.assertThat(properties).isNotNull();
Assertions.assertThat(properties.getTwitter()).isNotNull();
Assertions.assertThat(properties.getTwitter().getAccounts()).hasSize(1);
Assertions.assertThat(
properties.getTwitter().getAccounts().get("account1").getAccessTokenSecret()
).isEqualTo("dddddddddddddddddddddddddddddddddd");
Assertions.assertThat(properties.getTwitter().getAccounts()).hasSize(2);
SocializerProperties.TwitterProperties.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");
Assertions.assertThat(account2.getAccessTokenSecret()).isEqualTo("ffffffffffffffffffffffffffffffffff");
Assertions.assertThat(account2.getRetweet()).isNull();
}
}
......
......@@ -13,3 +13,15 @@ socializer:
apiSecretKey: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
accessTokens: 'ccccccccccccc-cccccccccccccccccc'
accessTokenSecret: 'dddddddddddddddddddddddddddddddddd'
retweet:
filters:
- filterterm
users:
- retweeteduser1
- retweeteduser2
account2:
apiKey: 'aaaaaaaaaaaaaaaaaaaa'
apiSecretKey: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
accessTokens: 'eeeeeeeeeeeee-eeeeeeeeeeeeeeeeee'
accessTokenSecret: 'ffffffffffffffffffffffffffffffffff'
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