Skip to content

Commit 12b5e3d

Browse files
committed
feat: initial commit for Java OpenSlava 2023 BalloonChallenge CodeFix
1 parent dcf0804 commit 12b5e3d

File tree

9 files changed

+270
-2
lines changed

9 files changed

+270
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.idea/
2+
target/
3+
*.iml
14
# Compiled class file
25
*.class
36

README.adoc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
== Win a Thrilling Balloon Flight at OpenSlava 2023!
2+
:toc:
3+
4+
*🎈 BalloonChallenge CodeFix 🎈*
5+
6+
=== Welcome to the Skyward BalloonChallenge CodeFix Project! 🚀
7+
8+
=== 🎉 Win a Thrilling Balloon Flight! 🎉
9+
10+
Embark on a coding adventure and get the chance to soar high in the sky in a hot air balloon! 🌍🎈 This repository is the gateway to a challenge where your code-fixing skills could win you an unforgettable balloon flight experience.
11+
12+
'''
13+
14+
=== 🛠 Challenge Overview:
15+
16+
==== The Task:
17+
18+
* *Repair the Despair*: Dive into our code repository and get your hands on bugs, inefficiencies, and areas that need enhancement.
19+
20+
* *Limited Time Magic*: Make meaningful contributions by fixing code within a specified time frame at ableneo booth.
21+
22+
==== The Reward:
23+
24+
* *Fly High*: The coder with the best fix will be awarded a spectacular hot air balloon flight.
25+
26+
'''
27+
28+
=== 🚀 How to Participate:
29+
30+
. *Check in @ ableneo booth*: Visit ableneo booth and check in to the challenge.
31+
32+
. *Code & Commit*: Implement your fix and commit your changes.
33+
34+
. *Pull & Pray*: Make a pull request back to the original repository. Ensure your PR has a descriptive title and thorough explanation of the fixes made.
35+
36+
. *Wait & See*: Judges will evaluate the solutions and announce the winner once the challenge ends.
37+
38+
'''
39+
40+
=== 🏆 Judging Criteria:
41+
42+
* *Efficiency*: The simplicity and computational efficiency of your fix.
43+
44+
* *Readability*: How clean and understandable your code is.
45+
46+
* *Impact*: The significance of the bug/issue you resolved.
47+
48+
* *Explanation*: The clarity of your explanation and documentation for the fix.
49+
50+
* *Tests*: The tests suite passes.
51+
52+
'''
53+
54+
=== 📅 Important Dates:
55+
56+
* *Coding stand*: @ableneo booth, OpenSlava 2023, *19.10.2023*, Bratislava, Slovakia https://www.openslava.sk/2023
57+
58+
* *Winners Unveiled*: Winner will be declared on *19.10.2023 16:30* at our ableneo booth. The winner will be contacted via email.
59+
60+
'''
61+
62+
=== 💌 Stay Connected:
63+
64+
* *Ask Me Anything*: Reach out to us at out https://github.com/ableneo/ama[AMA] project for any questions or feedback.
65+
66+
* *Issues*: Use the `Issues` tab for queries or to interact with the community.
67+
68+
* *Social Media*: Join us on https://twitter.com/ableneo[Twitter] and https://www.linkedin.com/company/ableneoie/[LinkedIn] for more insights and updates.
69+
70+
'''
71+
72+
=== 📜 License:
73+
74+
This project is licensed under the MIT License. See the link:LICENSE[LICENSE] file for details.
75+
76+
'''
77+
78+
🚀 *Join the BalloonChallenge CodeFix and let your coding skills take you to the skies!* 🎈
79+
80+
'''

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>sk.ableneo</groupId>
6+
<artifactId>BalloonChallenge</artifactId>
7+
<version>0.1-SNAPSHOT</version>
8+
9+
<name>sk.ableneo.openslava2023.codefix.BalloonChallenge-CodeFix</name>
10+
11+
<properties>
12+
<maven.compiler.source>17</maven.compiler.source>
13+
<maven.compiler.target>17</maven.compiler.target>
14+
<junit.version>5.10.0</junit.version>
15+
<mockito.version>5.6.0</mockito.version>
16+
</properties>
17+
18+
<build>
19+
<plugins>
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-surefire-plugin</artifactId>
23+
<version>3.1.2</version>
24+
</plugin>
25+
</plugins>
26+
</build>
27+
<dependencies>
28+
29+
<!-- test start -->
30+
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
31+
<dependency>
32+
<groupId>org.junit.jupiter</groupId>
33+
<artifactId>junit-jupiter-engine</artifactId>
34+
<version>${junit.version}</version>
35+
<scope>test</scope>
36+
</dependency>
37+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter -->
38+
<dependency>
39+
<groupId>org.mockito</groupId>
40+
<artifactId>mockito-junit-jupiter</artifactId>
41+
<version>${mockito.version}</version>
42+
<scope>test</scope>
43+
</dependency>
44+
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
45+
<dependency>
46+
<groupId>org.mockito</groupId>
47+
<artifactId>mockito-core</artifactId>
48+
<version>${mockito.version}</version>
49+
<scope>test</scope>
50+
</dependency>
51+
</dependencies>
52+
53+
54+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package sk.ableneo.openslava2023.codefix;
2+
3+
import sk.ableneo.openslava2023.donotfix.Order;
4+
import sk.ableneo.openslava2023.donotfix.OrderRepository;
5+
import sk.ableneo.openslava2023.donotfix.Product;
6+
7+
import java.util.ArrayList;
8+
import java.util.LinkedList;
9+
10+
// TODO: fix the class
11+
public class BalloonChallenge {
12+
13+
public LinkedList findOrdersForProduct(Product p, boolean debug) {
14+
ArrayList l = new ArrayList();
15+
ArrayList list = getAllOrders();
16+
for (int i = 0; i < list.size(); i++) {
17+
Order order = (Order) list.get(i);
18+
boolean found = false;
19+
if (order.getProducts().size() > 0) {
20+
for (int j = 0; j <= order.getProducts().size(); j++) {
21+
Product p2 = (Product) order.getProducts().get(j);
22+
found = (p2 == p);
23+
}
24+
if (found && order != null)
25+
l.add(order);
26+
}
27+
}
28+
return new LinkedList(l);
29+
}
30+
31+
public ArrayList getAllOrders() {
32+
return new ArrayList<Object>(OrderRepository.getAllOrders());
33+
}
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package sk.ableneo.openslava2023.donotfix;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class Order {
7+
private final List<Product> products = new ArrayList<>();
8+
9+
public Order(List<Product> products) {
10+
this.products.addAll(products);
11+
}
12+
13+
public List<Product> getProducts() {
14+
return products;
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package sk.ableneo.openslava2023.donotfix;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
7+
public class OrderRepository {
8+
public static List<Order> getAllOrders() {
9+
return Arrays.asList(
10+
new Order(new ArrayList<>(Arrays.asList(new Product("hot air balloon")))),
11+
new Order(new ArrayList<>(Arrays.asList(new Product("gas balloon")))),
12+
new Order(new ArrayList<>(Arrays.asList(new Product("gas balloon"))))
13+
);
14+
}
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package sk.ableneo.openslava2023.donotfix;
2+
3+
public class Product {
4+
private String name;
5+
6+
public Product(String name) {
7+
this.name = name;
8+
}
9+
10+
public String getName() {
11+
return name;
12+
}
13+
14+
@Override
15+
public boolean equals(Object o) {
16+
if (this == o) return true;
17+
if (o == null || getClass() != o.getClass()) return false;
18+
19+
Product product = (Product) o;
20+
21+
return getName().equals(product.getName());
22+
}
23+
24+
@Override
25+
public int hashCode() {
26+
return getName().hashCode();
27+
}
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package sk.ableneo.openslava2023.codefix;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
import org.junit.jupiter.api.extension.ExtendWith;
6+
import org.mockito.Mock;
7+
import org.mockito.junit.jupiter.MockitoExtension;
8+
import sk.ableneo.openslava2023.donotfix.Order;
9+
import sk.ableneo.openslava2023.donotfix.Product;
10+
11+
import java.util.ArrayList;
12+
import java.util.Arrays;
13+
14+
import static org.junit.jupiter.api.Assertions.*;
15+
import static org.mockito.ArgumentMatchers.any;
16+
import static org.mockito.ArgumentMatchers.anyBoolean;
17+
import static org.mockito.Mockito.when;
18+
@ExtendWith(MockitoExtension.class)
19+
class BalloonChallengeTest {
20+
21+
@Mock
22+
private BalloonChallenge balloonChallenge;
23+
24+
@BeforeEach
25+
void setUp() {
26+
when(balloonChallenge.getAllOrders()).thenReturn(
27+
new ArrayList<Object>(Arrays.asList(
28+
new Order(new ArrayList<>(Arrays.asList(new Product("hot air balloon")))),
29+
new Order(new ArrayList<>(Arrays.asList(new Product("gas balloon")))),
30+
new Order(new ArrayList<>(Arrays.asList(new Product("gas balloon"))))
31+
))
32+
);
33+
when(balloonChallenge.findOrdersForProduct(any(),anyBoolean())).thenCallRealMethod();
34+
}
35+
@Test
36+
void findOrdersForProduct() {
37+
assertEquals(1, balloonChallenge.findOrdersForProduct(new Product("hot air balloon"), false).size());
38+
assertEquals(2, balloonChallenge.findOrdersForProduct(new Product("gas balloon"), false).size());
39+
}
40+
}

0 commit comments

Comments
 (0)