This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip investments until CAPTCHA is gone (fixes #103)
The seemingly unrelated changes in this commit are there to increase mutation coverage in robozonky-app over the threshold.
- Loading branch information
Showing
14 changed files
with
278 additions
and
9 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...i/src/main/java/com/github/triceo/robozonky/api/notifications/InvestmentSkippedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2017 Lukáš Petrovický | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.github.triceo.robozonky.api.notifications; | ||
|
||
import com.github.triceo.robozonky.api.strategies.Recommendation; | ||
|
||
/** | ||
* Fired when an event was skipped by the investment algorithm due to CAPTCHA, to be evaluated later after CAPTCHA | ||
* expires. | ||
*/ | ||
public final class InvestmentSkippedEvent extends Event { | ||
|
||
private final Recommendation recommendation; | ||
|
||
public InvestmentSkippedEvent(final Recommendation recommendation) { | ||
this.recommendation = recommendation; | ||
} | ||
|
||
public Recommendation getRecommendation() { | ||
return recommendation; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.../java/com/github/triceo/robozonky/notifications/email/InvestmentSkippedEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2017 Lukáš Petrovický | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.github.triceo.robozonky.notifications.email; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.github.triceo.robozonky.api.notifications.InvestmentSkippedEvent; | ||
import com.github.triceo.robozonky.api.remote.entities.Loan; | ||
|
||
final class InvestmentSkippedEventListener extends AbstractEmailingListener<InvestmentSkippedEvent> { | ||
|
||
public InvestmentSkippedEventListener(final ListenerSpecificNotificationProperties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
String getSubject(final InvestmentSkippedEvent event) { | ||
return "Půjčka č. " + event.getRecommendation().getLoanDescriptor().getLoan().getId() + " dočasně přeskočena"; | ||
} | ||
|
||
@Override | ||
String getTemplateFileName() { | ||
return "investment-skipped.ftl"; | ||
} | ||
|
||
@Override | ||
Map<String, Object> getData(final InvestmentSkippedEvent event) { | ||
final Loan loan = event.getRecommendation().getLoanDescriptor().getLoan(); | ||
final Map<String, Object> result = new HashMap<>(); | ||
result.put("loanId", loan.getId()); | ||
result.put("loanRecommendation", event.getRecommendation().getRecommendedInvestmentAmount()); | ||
result.put("loanAmount", loan.getAmount()); | ||
result.put("loanRating", loan.getRating().getCode()); | ||
result.put("loanTerm", loan.getTermInMonths()); | ||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../java/com/github/triceo/robozonky/notifications/files/InvestmentSkippedEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2017 Lukáš Petrovický | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.github.triceo.robozonky.notifications.files; | ||
|
||
import com.github.triceo.robozonky.api.notifications.InvestmentSkippedEvent; | ||
|
||
final class InvestmentSkippedEventListener extends AbstractFileStoringListener<InvestmentSkippedEvent> { | ||
|
||
@Override | ||
int getLoanId(final InvestmentSkippedEvent event) { | ||
return event.getRecommendation().getLoanDescriptor().getLoan().getId(); | ||
} | ||
|
||
@Override | ||
int getAmount(final InvestmentSkippedEvent event) { | ||
return event.getRecommendation().getRecommendedInvestmentAmount(); | ||
} | ||
|
||
@Override | ||
String getSuffix() { | ||
return "skipped"; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...src/main/resources/com/github/triceo/robozonky/notifications/email/investment-skipped.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Půjčka s následujícími parametry byla přeskočena: | ||
|
||
- Číslo půjčky: ${data.loanId?c} | ||
- Rating: ${data.loanRating} | ||
- Délka splácení: ${data.loanTerm?c} měsíců | ||
- Požadovaná částka: ${data.loanAmount?c},- Kč | ||
- Navržená výše investice: ${data.loanRecommendation?c},- Kč | ||
|
||
Informace o této půjčce jsou dostupné na následující adrese: | ||
https://app.zonky.cz/#/marketplace/detail/${data.loanId?c}/ | ||
|
||
Pokud tato půjčka vydrží na tržišti až do vypršení CAPTCHA, robot se k ní vrátí. | ||
|
Oops, something went wrong.