@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenStringHasNoStartingBrace() { // given String testTag = "tag_one"; String testNotBalancedString = testTag + "}"; // when Kirai.from(testNotBalancedString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenStringHasNoEndingBrace() { // given String testTag = "tag_one"; String testNotBalancedString = "{" + testTag; // when Kirai.from(testNotBalancedString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenStringIsNotBeBalanced() { // given String testTagOne = "tag_one"; String testTagTwo = "tag_two"; String testNotBalancedString = "Sample text } {{ {" + testTagOne + "} and {" + testTagTwo + "} { rest of the sentence."; // when Kirai.from(testNotBalancedString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testFromShouldThrowExceptionWhenKeyStartsFromNumber() { // given String incorrectTestTag = "1_incorrect_tag"; String testInputString = "Sample text {" + incorrectTestTag + "} rest of the sentence."; // when Kirai.from(testInputString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testFromShouldThrowExceptionWhenKeyContainsSpecialCharacters() { // given String incorrectTestTag = "#!@ tag &^*_"; String testInputString = "Sample text {" + incorrectTestTag + "} rest of the sentence."; // when Kirai.from(testInputString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenInputStringIsNull() { // given String testInputString = null; // when Kirai.from(testInputString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenInputStringIsEmpty() { // given String testInputString = ""; // when Kirai.from(testInputString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testFromShouldThrowExceptionWhenKeyStartsFromUnderscore() { // given String incorrectTestTag = "_incorrect_tag"; String testInputString = "Sample text {" + incorrectTestTag + "} rest of the sentence."; // when Kirai.from(testInputString); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testFromShouldThrowExceptionWhenKeyStartsFromSpecialCharacter() { // given String incorrectTestTag = "!_incorrect_tag"; String testInputString = "Sample text {" + incorrectTestTag + "} rest of the sentence."; // when Kirai.from(testInputString); // then // throw an exception }
@Test public void testStringShouldBeBalanced() { // given String testTagOne = "tag_one"; String testTagTwo = "tag_two"; String testBalancedString = "Sample text {" + testTagOne + "} and {" + testTagTwo + "} rest of the sentence."; // when Kirai kirai = Kirai.from(testBalancedString); // then // no exception is thrown and object is created assertThat(kirai).isNotNull(); }
@Test public void testKiraiShouldSetAnInputAndNotBeNull() { // given String sampleString = "sample string"; // when Kirai kirai = Kirai.from(sampleString); // then // no exception is thrown and object is created assertThat(kirai).isNotNull(); }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenPieceIsNull() { // given Piece nullPiece = null; String testTagOne = "tag_one"; String testInputString = "Sample text {" + testTagOne + "} rest of the sentence."; // when Kirai.from(testInputString).put(nullPiece); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testPutShouldThrowExceptionWhenKeyIsNotDefinedInInputString() { // given String presentTestTag = "test_tag_present"; String notPresentTestTag = "test_tag_NOT_present"; String testValue = "test value"; String testInputString = "Sample text {" + presentTestTag + "} rest of the sentence."; // when Kirai.from(testInputString).put(notPresentTestTag, testValue); // then throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenKeyAndValueAreNull() { // given String testTagOne = "tag_one"; String testTagTwo = "tag_two"; String testBalancedString = "Sample text {" + testTagOne + "} and {" + testTagTwo + "} rest of the sentence."; String nullTestKey = null; String nullTestValue = null; // when Kirai.from(testBalancedString).put(nullTestKey, nullTestValue); // then // throw an exception }
@Test(expected = IllegalArgumentException.class) public void testPutShouldThrowAnExceptionWhenKeyIsAnEmptyString() { // given String testKey = ""; String testValue = "test value"; String testInputString = "Sample text {" + testKey + "} rest of the sentence."; // when Kirai.from(testInputString).put(testKey, testValue).format(); // then throw an exception }
@Test(expected = IllegalArgumentException.class) public void testPutShouldThrowAnExceptionWhenValueIsAnEmptyString() { String testKey = "testKey"; String testValue = ""; String testInputString = "Sample text {" + testKey + "} rest of the sentence."; // when Kirai.from(testInputString).put(testKey, testValue).format(); // then throw an exception }
@Test(expected = IllegalArgumentException.class) public void testPutShouldThrowAnExceptionWhenValueIsNull() { String testKey = "testKey"; String testValue = null; String testInputString = "Sample text {" + testKey + "} rest of the sentence."; // when Kirai.from(testInputString).put(testKey, testValue).format(); // then throw an exception }
@Test(expected = IllegalArgumentException.class) public void testPutShouldThrowAnExceptionWhenKeyIsNull() { // given String testKey = null; String testValue = "test value"; String testInputString = "Sample text {" + testKey + "} rest of the sentence."; // when Kirai.from(testInputString).put(testKey, testValue).format(); // then throw an exception }
@Test(expected = IllegalArgumentException.class) public void testShouldThrowExceptionWhenPieceHasKeyNotDefinedInInputString() { // given String testValue = "test value"; String notPresentTestTag = "test_tag_NOT_present"; Piece testPiece = HtmlPiece.put(notPresentTestTag, testValue); String testTagOne = "tag_one"; String testInputString = "Sample text {" + testTagOne + "} rest of the sentence."; // when Kirai.from(testInputString).put(testPiece); // then // throw an exception }
@Test public void testPutShouldAddKeyAndValue() { // given String testKey = "test_tag_present"; String testValue = "test value"; String testInputString = "Sample text {" + testKey + "} rest of the sentence."; String expectedOutPutString = "Sample text " + testValue + " rest of the sentence."; // when CharSequence generatedCharSequence = Kirai.from(testInputString).put(testKey, testValue).format(); // then assertThat(generatedCharSequence).isEqualTo(expectedOutPutString); }