Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e6f1fd1
Developers added
ignat-mishura Oct 12, 2021
3369fd6
Test char and String completed
ignat-mishura Oct 14, 2021
01b5278
Fixed tests for boolean and Object
lllllllvlllllll Oct 14, 2021
5bab4a3
Added feature to output logs into file
lllllllvlllllll Oct 14, 2021
a84026c
Logger Refactoring
ignat-mishura Oct 14, 2021
cecc93a
Interation 2 - test 1/2 logic added
ignat-mishura Oct 15, 2021
b5ca1f7
Interation 2 - byte logic fixed
ignat-mishura Oct 15, 2021
f49bc20
Feature branch init
ignat-mishura Oct 15, 2021
3140393
Part of the solution with string for Iter02
lllllllvlllllll Oct 18, 2021
383ace4
Merge branch 'master' into feature/ignat
ignat-mishura Oct 18, 2021
03b41a4
Garbage commit 2.0
ignat-mishura Oct 18, 2021
a134e0d
1dim int test success
ignat-mishura Oct 18, 2021
7f58718
Fixed test for 2d array
lllllllvlllllll Oct 18, 2021
bc1ccf0
Init new branch
lllllllvlllllll Oct 18, 2021
3d06b75
OOP implementation: Int and Byte logic added
ignat-mishura Oct 20, 2021
f841998
Merge remote-tracking branch 'origin/feature/ignat' into feature/llvll
lllllllvlllllll Oct 21, 2021
e5ad277
OOP implementation: Int and Byte logic added
ignat-mishura Oct 21, 2021
ade76d6
Merge remote-tracking branch 'origin/feature/ignat' into feature/llvll
lllllllvlllllll Oct 21, 2021
585b354
OOAD: Int, Byte and String implementation added. Tests 1/2 passed
ignat-mishura Oct 21, 2021
257e4b3
Added test for Controller
lllllllvlllllll Oct 25, 2021
cdd532e
Merge branch 'feature/ignat' into feature/llvll
ignat-mishura Oct 26, 2021
fd3cea7
pom changed, test changed
ignat-mishura Oct 26, 2021
3f5c02c
Merge branch 'feature/llvll' into feature/ignat
ignat-mishura Oct 26, 2021
b20275f
...
ignat-mishura Oct 26, 2021
22f545d
...
ignat-mishura Oct 26, 2021
14bf045
All test passed
ignat-mishura Oct 26, 2021
a15a9bb
Controller test added
ignat-mishura Oct 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Ignat Mishura / Zarubin Vladimir

# Java Junior Developer Training Course.
88 hours training + 32 hours work project = 120 hr.

Expand Down
112 changes: 102 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<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/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.acme.edu</groupId>
Expand All @@ -18,25 +18,117 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.7.2</version>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.15</version>
</dependency>
</dependencies>
<configuration>
<targetClasses>
<param>com.acme.edu.*</param>
</targetClasses>
<targetTests>
<param>com.acme.edu.*</param>
</targetTests>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<id>mutation-coverage</id>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
<execution>
<id>mutation-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.21.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
</project>
32 changes: 32 additions & 0 deletions src/main/java/com/acme/edu/Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.acme.edu;

import com.acme.edu.message.*;

public class Controller {

private Message currentType;
private final Saver saver;

public Controller(Saver saver) {
this.saver = saver;
}

public void log(Message message) {
if (currentType != null) {
if (!currentType.isSameType(message)) {
flush();
currentType = message;
} else {
currentType.process(message);
}
} else {
currentType = message;
}
}

public void flush() {
saver.save(currentType.decorate());
currentType = null;
}

}
49 changes: 47 additions & 2 deletions src/main/java/com/acme/edu/Logger.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
package com.acme.edu;

import com.acme.edu.message.*;


public class Logger {
private static final Saver saver = new Saver();
private static final Controller controller = new Controller(saver);

public static void log(int message) {
System.out.println("primitive: " + message);
controller.log(new IntegerMessage(message));
}

public static void log(byte message) {
System.out.println("primitive: " + message);
controller.log(new ByteMessage(message));
}

public static void log(char message) {
controller.log(new CharacterMessage(message));
}

public static void log(String message) {
controller.log(new StringMessage(message));
}

public static void log(boolean message) {
controller.log(new BooleanMessage(message));
}

public static void log(Object message) {
controller.log(new ObjectMessage(message));
}

public static void log(int... message) {
for (int simpleIntMessage : message) {
log(simpleIntMessage);
}
}

public static void log(String... message) {
for (String simpleStringMessage : message) {
log(simpleStringMessage);
}
}

public static void log(int[][] message) {
for (int[] intArray : message) {
log(intArray);
}
}

public static void flush() {
controller.flush();
}

}
114 changes: 114 additions & 0 deletions src/main/java/com/acme/edu/LoggerDeprecated.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.acme.edu;

public class LoggerDeprecated {
public static final String PRIMITIVE_PREFIX = "primitive: ";
public static final String CHAR_PREFIX = "char: ";
public static final String STRING_PREFIX = "string: ";
public static final String OBJECT_PREFIX = "reference: ";
public static final String MATRIX_PREFIX = "primitives matrix: ";
public static boolean intAccIsNotEmpty = false;
private static long intAccumulator = 0;
public static boolean byteAccIsNotEmpty = false;
public static boolean allowToHandleMatrix = true;
private static int byteAccumulator = 0;
private static String currentString;
private static String prevString;
private static int strRepeatCounter = 1;


public static void log(int message) { output(Type.INTEGER,PRIMITIVE_PREFIX, message); }

public static void log(byte message) { output(Type.BYTE,PRIMITIVE_PREFIX, message); }

public static void log(char message) { output(Type.CHARACTER, CHAR_PREFIX, message); }

public static void log(String message) { output(Type.STRING,STRING_PREFIX, message); }

public static void log(boolean message) { output(Type.BOOLEAN,PRIMITIVE_PREFIX, message); }

public static void log(Object message) { output(Type.OBJECT,OBJECT_PREFIX, message); }

public static void log(int... message) {
output(Type.INTARRAY, PRIMITIVE_PREFIX, message);
}

public static void log(int[][] message) {
output(Type.INT2DARRAY, MATRIX_PREFIX, message);
}

private static void output(Type type, String prefix, Object message) {
switch (type.getValue()) {
case ("int"):
accumulator((int) message);
break;
case ("byte"):
accumulator((byte) message);
break;
case ("str"):
break;
case ("intarray"):
for (int i : (int[]) message) {
log(i);
}
break;
case ("int2darray"):
for (int[] i : (int[][]) message) {
for (int j : i) {
log(j);
}
}
break;
default:
System.out.println(prefix + message);
break;
}
}

private static void accumulator(int i) {
intAccumulator += i;
intAccIsNotEmpty = true;
}

private static void accumulator(byte b) {
byteAccumulator += b;
byteAccIsNotEmpty = true;
}

public static void flush() {
if (allowToHandleMatrix) {
System.out.println(MATRIX_PREFIX + intAccumulator);
}else if (intAccIsNotEmpty) {
System.out.println(PRIMITIVE_PREFIX + intAccumulator);
intAccumulator = 0;
intAccIsNotEmpty = false;
}
if (byteAccIsNotEmpty) {
System.out.println(PRIMITIVE_PREFIX + byteAccumulator);
byteAccumulator = 0;
byteAccIsNotEmpty = false;
}

}

enum Type {
INTEGER("int"),
BYTE("byte"),
STRING("str"),
CHARACTER("char"),
OBJECT("object"),
BOOLEAN("bool"),
INTARRAY("intarray"),
INT2DARRAY("int2darray");


private String value;

Type(String value) {
this.value = value;
}

public String getValue() {
return this.value;
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/acme/edu/Saver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.acme.edu;

public class Saver {
public void save(String string) {
System.out.println(string);
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/acme/edu/message/BooleanMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.acme.edu.message;

public class BooleanMessage extends Message {

private boolean value;

public BooleanMessage(boolean value) {
this.value = value;
}

@Override
public boolean isSameType(Message message) {
return false;
}

@Override
public void process(Message message) {
System.out.println("Unreachable output ...");
}

@Override
public String decorate() {
return "primitive: " + value;
}
}
Loading