mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-06-01 04:10:48 +00:00
docs: update service stub
This commit is contained in:
+8
-5
@@ -36,10 +36,8 @@ public class RealSentimentAnalysisServer implements SentimentAnalysisServer {
|
||||
* A real sentiment analysis implementation would analyze the input string using, e.g., NLP and
|
||||
* determine whether the sentiment is positive, negative or neutral. Here we simply choose a
|
||||
* random number to simulate this. The "model" may take some time to process the input and we
|
||||
* simulate this by delaying the execution 5 seconds.
|
||||
*
|
||||
* @param text the input string to analyze
|
||||
* @return sentiment classification result (Positive, Negative, or Neutral)
|
||||
* simulate this by delaying the execution 5 seconds. Analyzes the sentiment of the given input
|
||||
* string and returns the classification result (Positive, Negative, or Neutral).
|
||||
*/
|
||||
private final Supplier<Integer> sentimentSupplier;
|
||||
|
||||
@@ -61,6 +59,11 @@ public class RealSentimentAnalysisServer implements SentimentAnalysisServer {
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return sentiment == 0 ? "Positive" : sentiment == 1 ? "Negative" : "Neutral";
|
||||
|
||||
return switch (sentiment) {
|
||||
case 0 -> "Positive";
|
||||
case 1 -> "Negative";
|
||||
default -> "Neutral";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AppTest {
|
||||
class AppTest {
|
||||
@Test
|
||||
void shouldExecuteWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
|
||||
Reference in New Issue
Block a user