Skip to content

Commit

Permalink
Add tokens generators dummy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
l3r8yJ committed Apr 27, 2023
1 parent 5c3059d commit c78df2b
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* MIT License
*
* Copyright (c) Copyright (c) 2023 Blamer.io
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.blamer.bot.answer.generator.impl;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.commands.BotCommand;

@ExtendWith(MockitoExtension.class)
class StartMessageGeneratorTest {

@Test
void createsStartMessage(@Mock final Update update, @Mock final Message message) {
Mockito.when(update.getMessage()).thenReturn(message);
Assertions.assertNotNull(new StartMessageGenerator().messageFromUpdate(update));
}

@Test
void createsDescription() {
final BotCommand actual = new StartMessageGenerator().messageAsBotCommand();
MatcherAssert.assertThat(actual.getCommand(), Matchers.equalTo("/start"));
MatcherAssert.assertThat(
actual.getDescription(),
Matchers.equalTo("Just start command")
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* MIT License
*
* Copyright (c) Copyright (c) 2023 Blamer.io
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.blamer.bot.answer.generator.impl;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.commands.BotCommand;

@ExtendWith(MockitoExtension.class)
class TokenMessageGeneratorTest {

@Test
void createsStartMessage(@Mock final Update update, @Mock final Message message) {
Mockito.when(update.getMessage()).thenReturn(message);
Assertions.assertNotNull(new TokenMessageGenerator().messageFromUpdate(update));
}

@Test
void createsDescription() {
final BotCommand actual = new TokenMessageGenerator().messageAsBotCommand();
MatcherAssert.assertThat(actual.getCommand(), Matchers.equalTo("/token"));
MatcherAssert.assertThat(
actual.getDescription(),
Matchers.equalTo("Set GitHub token to get updates")
);
}
}

3 comments on commit c78df2b

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on c78df2b Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1-e16aaf49 disappeared from src/main/java/io/blamer/bot/bot/Bot.java), that's why I closed #4. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on c78df2b Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 4-3e287310 discovered in src/main/java/io/blamer/bot/answer/generator/MessageGenerator.java) and submitted as #9. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on c78df2b Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 4-2e64d6dc discovered in src/main/java/io/blamer/bot/bot/Bot.java) and submitted as #10. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.