Skip to content

Commit 1eb0c3d

Browse files
committed
First Commit
0 parents  commit 1eb0c3d

34 files changed

+1391
-0
lines changed

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.example</groupId>
8+
<artifactId>CPS3230</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>19</maven.compiler.source>
13+
<maven.compiler.target>19</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
19+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
20+
<dependency>
21+
<groupId>org.junit.jupiter</groupId>
22+
<artifactId>junit-jupiter-api</artifactId>
23+
<version>5.7.0</version>
24+
<scope>test</scope>
25+
</dependency>
26+
27+
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
28+
<dependency>
29+
<groupId>org.seleniumhq.selenium</groupId>
30+
<artifactId>selenium-java</artifactId>
31+
<version>3.141.59</version>
32+
</dependency>
33+
34+
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
35+
<dependency>
36+
<groupId>com.google.code.gson</groupId>
37+
<artifactId>gson</artifactId>
38+
<version>2.9.0</version>
39+
</dependency>
40+
41+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
42+
<dependency>
43+
<groupId>org.mockito</groupId>
44+
<artifactId>mockito-core</artifactId>
45+
<version>4.6.1</version>
46+
<scope>test</scope>
47+
</dependency>
48+
49+
<!-- https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy -->
50+
<dependency>
51+
<groupId>net.bytebuddy</groupId>
52+
<artifactId>byte-buddy</artifactId>
53+
<version>1.12.18</version>
54+
</dependency>
55+
56+
<!-- https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy-agent -->
57+
<dependency>
58+
<groupId>net.bytebuddy</groupId>
59+
<artifactId>byte-buddy-agent</artifactId>
60+
<version>1.12.18</version>
61+
<scope>test</scope>
62+
</dependency>
63+
64+
65+
66+
67+
</dependencies>
68+
69+
</project>

src/main/java/org/alert/Alert.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.alert;
2+
3+
import com.google.gson.Gson;
4+
5+
import java.net.URI;
6+
import java.net.http.HttpClient;
7+
import java.net.http.HttpRequest;
8+
import java.net.http.HttpResponse;
9+
import java.util.concurrent.CompletableFuture;
10+
11+
public class Alert {
12+
int alertType;
13+
String heading;
14+
String description;
15+
String url;
16+
String imageUrl;
17+
String postedBy;
18+
int priceInCents;
19+
20+
public Alert(int alertType, String heading, String description, String url, String imageUrl, int priceInCents) {
21+
this.alertType = alertType;
22+
this.heading = heading;
23+
this.description = description;
24+
this.url = url;
25+
this.imageUrl = imageUrl;
26+
this.postedBy = "5b403bf6-4f10-4bb3-ba93-54a4513864e2";
27+
this.priceInCents = priceInCents;
28+
}
29+
30+
public String alertToJson() {
31+
return new Gson().toJson(this);
32+
}
33+
34+
public CompletableFuture<HttpResponse<String>> postAlert() {
35+
HttpClient httpclient = HttpClient.newHttpClient();
36+
HttpRequest request = HttpRequest.newBuilder()
37+
.uri(URI.create("https://api.marketalertum.com/Alert"))
38+
.header("Content-Type", "application/json")
39+
.POST(HttpRequest.BodyPublishers.ofString(alertToJson()))
40+
.build();
41+
42+
return httpclient.sendAsync(request, HttpResponse.BodyHandlers.ofString());
43+
}
44+
}

0 commit comments

Comments
 (0)