-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/java/com/esp/espflow/mappers/ExtractChipIsFromStringMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.esp.espflow.mappers; | ||
|
||
import com.esp.espflow.mappers.provider.ExtractChipIsFromStringMapperFailureProvider; | ||
import com.esp.espflow.mappers.provider.ExtractChipIsFromStringMapperSuccessProvider; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@DisplayName("When extracting the 'Chip is ESP82XX' from the text processed in the Xterm, we check for possible " + | ||
"errors and then send the event correctly in the notification panel.") | ||
class ExtractChipIsFromStringMapperTest { | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(ExtractChipIsFromStringMapperSuccessProvider.class) | ||
@DisplayName("The chip is obtained from the input String") | ||
void getChipIsFromThisString_Success(String inputLines) { | ||
|
||
final String chipIs = ExtractChipIsFromStringMapper.INSTANCE.getChipIsFromThisString(inputLines); | ||
|
||
assertThat(chipIs).isEqualTo("ESP8266EX"); | ||
|
||
} | ||
|
||
@ParameterizedTest | ||
@ArgumentsSource(ExtractChipIsFromStringMapperFailureProvider.class) | ||
@DisplayName("When the Chip cannot be parsed, cannot be matched because of lowercase f") | ||
void attemptToParseTheChip_Failure(final String inputLine) { | ||
|
||
final String chipIs = ExtractChipIsFromStringMapper.INSTANCE.getChipIsFromThisString(inputLine); | ||
|
||
assertThat(chipIs).isEqualTo("Can`t parsed this Chip"); | ||
|
||
} | ||
|
||
@Test | ||
@DisplayName("Input String is null, something happens when the text arrives at the Xterm and its text is null") | ||
void attemptToParseTheChip_Failure2() { | ||
|
||
final String chipIs = ExtractChipIsFromStringMapper.INSTANCE.getChipIsFromThisString(null); | ||
|
||
assertThat(chipIs).isEqualTo("Can`t parsed this Chip"); | ||
|
||
} | ||
|
||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...t/java/com/esp/espflow/mappers/provider/ExtractChipIsFromStringMapperFailureProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.esp.espflow.mappers.provider; | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.ArgumentsProvider; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class ExtractChipIsFromStringMapperFailureProvider implements ArgumentsProvider { | ||
|
||
@Override | ||
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) throws Exception { | ||
|
||
String parseMePlease = "esptool.py --port COM5 --baud 115200 " + | ||
"flash_id esptool.py v4.7.0 " + | ||
"Serial port COM5 " + | ||
"Connecting.... " + | ||
"Detecting chip type... " + | ||
"Unsupported detection protocol, switching and trying again... " + | ||
"Connecting.... " + | ||
"Detecting chip type... ESP8266 " + | ||
"Chip is ESP8266EX " + | ||
"features: WiFi " + | ||
"Crystal is 26MHz " + | ||
"MAC: 2c:f4:32:10:1d:bf " + | ||
"Uploading stub... " + | ||
"Running stub... " + | ||
"Stub running... " + | ||
"Manufacturer: 85 " + | ||
"Device: 6014 " + | ||
"Detected flash size: 1MB " + | ||
"Hard resetting via RTS pin..."; | ||
|
||
return Stream.of(Arguments.of(parseMePlease)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...t/java/com/esp/espflow/mappers/provider/ExtractChipIsFromStringMapperSuccessProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.esp.espflow.mappers.provider; | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.ArgumentsProvider; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class ExtractChipIsFromStringMapperSuccessProvider implements ArgumentsProvider { | ||
|
||
@Override | ||
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) throws Exception { | ||
|
||
String parseMePlease = "esptool.py --port COM5 --baud 115200 " + | ||
"flash_id esptool.py v4.7.0 " + | ||
"Serial port COM5 " + | ||
"Connecting.... " + | ||
"Detecting chip type... " + | ||
"Unsupported detection protocol, switching and trying again... " + | ||
"Connecting.... " + | ||
"Detecting chip type... ESP8266 " + | ||
"Chip is ESP8266EX " + | ||
"Features: WiFi " + | ||
"Crystal is 26MHz " + | ||
"MAC: 2c:f4:32:10:1d:bf " + | ||
"Uploading stub... " + | ||
"Running stub... " + | ||
"Stub running... " + | ||
"Manufacturer: 85 " + | ||
"Device: 6014 " + | ||
"Detected flash size: 1MB " + | ||
"Hard resetting via RTS pin..."; | ||
return Stream.of(Arguments.of(parseMePlease)); | ||
} | ||
} |