Skip to content

Commit

Permalink
Merge pull request #26 from Moesif/add-campaign-object
Browse files Browse the repository at this point in the history
Add: Campaign object to Update user and company tests
  • Loading branch information
matthewoates authored Nov 18, 2019
2 parents 995f701 + 15554bb commit 5ddc6f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Add the Moesif dependency to your project's pom.xml file:
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.6.6</version>
<version>1.6.7</version>
</dependency>
```

Expand All @@ -48,7 +48,7 @@ repositories {
}
dependencies {
compile 'com.moesif.servlet:moesif-servlet:1.6.6'
compile 'com.moesif.servlet:moesif-servlet:1.6.7'
}
```

Expand Down Expand Up @@ -520,6 +520,11 @@ The metadata field can be any custom data you want to set on the user. The `user
```java
MoesifFilter filter = new MoesifFilter("Your Moesif Application Id", new MoesifConfiguration());

CampaignModel campaign = new CampaignBuilder()
.utmSource("Newsletter")
.utmMedium("Email")
.build();

UserModel user = new UserBuilder()
.userId("12345")
.companyId("67890")
Expand All @@ -536,6 +541,7 @@ UserModel user = new UserBuilder()
"\"field_2\": \"value_2\"" +
"}" +
"}"))
.campaign(campaign)
.build();
filter.updateUser(user);
```
Expand Down Expand Up @@ -594,6 +600,11 @@ The metadata field can be any custom data you want to set on the company. The `c
```java
MoesifFilter filter = new MoesifFilter("Your Moesif Application Id", new MoesifConfiguration());

CampaignModel campaign = new CampaignBuilder()
.utmSource("Adwords")
.utmMedium("Twitter")
.build();

CompanyModel company = new CompanyBuilder()
.companyId("12345")
.companyDomain("acmeinc.com")
Expand All @@ -606,6 +617,7 @@ CompanyModel company = new CompanyBuilder()
"\"field_2\": \"value_2\"" +
"}" +
"}"))
.campaign(campaign)
.build();
filter.updateCompany(company);
```
Expand Down
4 changes: 2 additions & 2 deletions moesif-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.6.6</version>
<version>1.6.7</version>
<packaging>jar</packaging>
<name>moesif-servlet</name>
<description>Moesif SDK for Java Servlet to log and analyze API calls</description>
Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.6.6</version>
<version>1.6.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
import com.moesif.api.models.UserModel;
import com.moesif.api.models.CampaignModel;
import com.moesif.api.models.CampaignBuilder;
import static org.mockito.Mockito.when;


Expand All @@ -36,7 +38,7 @@ protected void setUp() throws Exception {
config = new MoesifConfiguration();
config.disableTransactionId = true;
servletOutputStream = Mockito.mock(ServletOutputStream.class);
filter = new MoesifFilter("Your Application Id", config);
filter = new MoesifFilter("Your Moesif Application Id", config);
}

public void testSendEvent() throws Exception {
Expand Down Expand Up @@ -115,6 +117,12 @@ public int read() throws IOException {
}

public void testUpdateUser() throws Throwable {

CampaignModel campaign = new CampaignBuilder()
.utmSource("Newsletter")
.utmMedium("Email")
.build();

UserModel user = new UserBuilder()
.userId("12345")
.companyId("67890")
Expand All @@ -131,6 +139,7 @@ public void testUpdateUser() throws Throwable {
"\"field_2\": \"value_2\"" +
"}" +
"}"))
.campaign(campaign)
.build();
filter.updateUser(user);
}
Expand Down Expand Up @@ -177,6 +186,12 @@ public void testUpdateUsersBatch() throws Throwable {
}

public void testUpdateCompany() throws Throwable {

CampaignModel campaign = new CampaignBuilder()
.utmSource("Adwords")
.utmMedium("Twitter")
.build();

CompanyModel company = new CompanyBuilder()
.companyId("12345")
.companyDomain("acmeinc.com")
Expand All @@ -189,6 +204,7 @@ public void testUpdateCompany() throws Throwable {
"\"field_2\": \"value_2\"" +
"}" +
"}"))
.campaign(campaign)
.build();
filter.updateCompany(company);
}
Expand Down

0 comments on commit 5ddc6f8

Please sign in to comment.