Skip to content

Commit

Permalink
#422 updated to core 72 and storage 68
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Apr 14, 2021
1 parent a80562c commit 78aac39
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

<properties>
<java.version>11</java.version>
<self.core.version>0.0.71</self.core.version>
<self.storage.version>0.0.67</self.storage.version>
<self.core.version>0.0.72</self.core.version>
<self.storage.version>0.0.68</self.storage.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public ResponseEntity<String> register(@Valid final PmInput newPm) {
newPm.getUsername(),
newPm.getProvider(),
newPm.getToken(),
newPm.getCommission()
newPm.getCommission(),
newPm.getContributorCommission()
);
response = ResponseEntity.ok(
new JsonProjectManager(registered).toString()
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/com/selfxdsd/selfweb/api/input/PmInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* @version $Id$
* @since 0.0.1
* @checkstyle JavadocMethod (200 lines)
* @checkstyle MemberName (200 lines)
* @checkstyle HiddenField (200 lines)
*/
public class PmInput {

Expand Down Expand Up @@ -64,11 +66,17 @@ public class PmInput {
private String token;

/**
* PM's commission.
* Project's commission.
*/
@Positive(message = "PM's commission must be a positive number!")
@Positive(message = "Project's commission must be a positive number!")
private double commission;

/**
* Contributor's commission.
*/
@Positive(message = "Contributor's commission must be a positive number!")
private double contributorCommission;

public String getUserId() {
return userId;
}
Expand Down Expand Up @@ -108,4 +116,12 @@ public double getCommission() {
public void setCommission(final double comm) {
this.commission = comm;
}

public double getContributorCommission() {
return contributorCommission;
}

public void setContributorCommission(final double contributorCommission) {
this.contributorCommission = contributorCommission;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public JsonInvoicedTask(final InvoicedTask task) {
.add("value", task.value().divide(BigDecimal.valueOf(100)))
.add(
"commission",
task.commission().divide(BigDecimal.valueOf(100))
task.projectCommission().divide(BigDecimal.valueOf(100))
).add(
"contributorCommission",
task.contributorCommission().divide(BigDecimal.valueOf(100))
).build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public JsonProjectManager(final ProjectManager manager) {
.add("userId", manager.userId())
.add("username", manager.username())
.add("provider", manager.provider().name())
.add("commission", manager.percentage())
.build()
.add("commission", manager.projectPercentage())
.add(
"contributorCommission",
manager.contributorPercentage()
).build()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private Project mockActiveProject(
Mockito.when(manager.id()).thenReturn(1);
Mockito.when(manager.userId()).thenReturn("123");
Mockito.when(manager.username()).thenReturn("zoeself");
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);
final Provider prov = Mockito.mock(Provider.class);
Mockito.when(prov.name()).thenReturn("github");
Mockito.when(manager.provider()).thenReturn(prov);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public void registerManagerWorksForAdmin() {
"zoe",
"github",
"token123",
8.0
8.0,
5.0
)
).thenReturn(registered);
Mockito.when(core.projectManagers()).thenReturn(all);
Expand All @@ -121,6 +122,7 @@ public void registerManagerWorksForAdmin() {
input.setProvider("github");
input.setToken("token123");
input.setCommission(8.0);
input.setContributorCommission(5.0);

final ResponseEntity<String> resp = new ProjectManagersApi(user, core)
.register(input);
Expand Down Expand Up @@ -169,7 +171,7 @@ private ProjectManager mockManager(final int id) {
final Provider provider = Mockito.mock(Provider.class);
Mockito.when(provider.name()).thenReturn("github");
Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(8.0);
Mockito.when(manager.projectPercentage()).thenReturn(8.0);
return manager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ private Project mockActiveProject(
Mockito.when(manager.id()).thenReturn(1);
Mockito.when(manager.userId()).thenReturn("123");
Mockito.when(manager.username()).thenReturn("zoeself");
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);
final Provider prov = Mockito.mock(Provider.class);
Mockito.when(prov.name()).thenReturn("github");
Mockito.when(manager.provider()).thenReturn(prov);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public void hasInvoicedTaskId(){

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.commission())
Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(100));


Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(30));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

MatcherAssert.assertThat(
Expand Down Expand Up @@ -92,9 +95,12 @@ public void hasIssueId(){

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.commission())
Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(100));


Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(30));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

MatcherAssert.assertThat(
Expand Down Expand Up @@ -124,8 +130,11 @@ public void hasEstimation(){

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.commission())
Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(30));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

Expand Down Expand Up @@ -156,8 +165,11 @@ public void hasValue(){

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(1000));

Mockito.when(invoicedTask.commission())
Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(30));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

Expand Down Expand Up @@ -188,8 +200,11 @@ public void hasCommission(){

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.commission())
Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(3000));

Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(30));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

Expand All @@ -198,4 +213,39 @@ public void hasCommission(){
Matchers.equalTo(30)
);
}

/**
* JsonInvoicedTask has contributor commission.
*/
@Test
public void hasContributorCommission(){
final InvoicedTask invoicedTask = Mockito.mock(InvoicedTask.class);

Mockito.when(invoicedTask.invoicedTaskId()).thenReturn(123);

Task task = Mockito.mock(Task.class);

Mockito.when(task.issueId()).thenReturn("123");

Mockito.when(invoicedTask.task()).thenReturn(task);

Mockito.when(task.estimation()).thenReturn(2);

Mockito.when(invoicedTask.task()).thenReturn(task);

Mockito.when(invoicedTask.value()).thenReturn(BigDecimal.valueOf(100));

Mockito.when(invoicedTask.projectCommission())
.thenReturn(BigDecimal.valueOf(3000));

Mockito.when(invoicedTask.contributorCommission())
.thenReturn(BigDecimal.valueOf(2000));

final JsonObject jsonInvoicedTask = new JsonInvoicedTask(invoicedTask);

MatcherAssert.assertThat(
jsonInvoicedTask.getInt("contributorCommission"),
Matchers.equalTo(20)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void hasRepoFullName(){
Mockito.when(provider.name()).thenReturn("Github");

Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);

Mockito.when(project.projectManager()).thenReturn(manager);

Expand Down Expand Up @@ -123,7 +123,7 @@ public void hasProvider(){
Mockito.when(provider.name()).thenReturn("Github");

Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);

Mockito.when(project.projectManager()).thenReturn(manager);

Expand Down Expand Up @@ -176,7 +176,7 @@ public void hasOwner(){
Mockito.when(provider.name()).thenReturn("Github");

Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);

Mockito.when(project.projectManager()).thenReturn(manager);

Expand Down Expand Up @@ -230,7 +230,7 @@ public void hasManager(){
Mockito.when(provider.name()).thenReturn("Github");

Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);

Mockito.when(project.projectManager()).thenReturn(manager);

Expand All @@ -257,8 +257,11 @@ public void hasManager(){
.add("userId", manager.userId())
.add("username", manager.username())
.add("provider", manager.provider().name())
.add("commission", manager.percentage())
.build())
.add("commission", manager.projectPercentage())
.add(
"contributorCommission",
manager.contributorPercentage()
).build())
);

}
Expand Down Expand Up @@ -290,7 +293,7 @@ public void hasWallet(){
Mockito.when(provider.name()).thenReturn("Github");

Mockito.when(manager.provider()).thenReturn(provider);
Mockito.when(manager.percentage()).thenReturn(6.5);
Mockito.when(manager.projectPercentage()).thenReturn(6.5);

Mockito.when(project.projectManager()).thenReturn(manager);

Expand Down

0 comments on commit 78aac39

Please sign in to comment.