<commit_before>package org.smoothbuild.acceptance.lang;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.testory.Testory.then;

import org.junit.jupiter.api.Test;
import org.smoothbuild.acceptance.AcceptanceTestCase;
import org.smoothbuild.acceptance.testing.CacheableRandom;
import org.smoothbuild.acceptance.testing.NotCacheableRandom;

public class CachingTest extends AcceptanceTestCase {
  @Test
  public void result_from_cacheable_function_is_cached() throws Exception {
    givenNativeJar(CacheableRandom.class);
    givenScript(
        "  String cacheableRandom();  ",
        "  result = cacheableRandom;  ");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    String resultFromFirstCall = artifactContent("result");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    then(artifactContent("result"), equalTo(resultFromFirstCall));
  }

  @Test
  public void result_from_not_cacheable_function_is_not_cached() throws Exception {
    givenNativeJar(NotCacheableRandom.class);
    givenScript(
        "  String notCacheableRandom();  ",
        "  result = notCacheableRandom;  ");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    String resultFromFirstCall = artifactContent("result");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    then(artifactContent("result"), not(equalTo(resultFromFirstCall)));
  }
}<commit_msg>refactored CachingTest to use Truth framework and fixed bug<commit_after>package org.smoothbuild.acceptance.lang;

import static com.google.common.truth.Truth.assertThat;

import org.junit.jupiter.api.Test;
import org.smoothbuild.acceptance.AcceptanceTestCase;
import org.smoothbuild.acceptance.testing.CacheableRandom;
import org.smoothbuild.acceptance.testing.NotCacheableRandom;

public class CachingTest extends AcceptanceTestCase {
  @Test
  public void result_from_cacheable_function_is_cached() throws Exception {
    givenNativeJar(CacheableRandom.class);
    givenScript(
        "  String cacheableRandom();  ",
        "  result = cacheableRandom;  ");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    String resultFromFirstCall = artifactContent("result");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    assertThat(artifactContent("result"))
        .isEqualTo(resultFromFirstCall);
  }

  @Test
  public void result_from_not_cacheable_function_is_not_cached() throws Exception {
    givenNativeJar(NotCacheableRandom.class);
    givenScript(
        "  String notCacheableRandom();  ",
        "  result = notCacheableRandom;  ");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    String resultFromFirstCall = artifactContent("result");
    whenSmoothBuild("result");
    thenFinishedWithSuccess();
    assertThat(artifactContent("result"))
        .isNotEqualTo(resultFromFirstCall);
  }
}
{'fraction_non_alphanumeric': 0.10055096418732783, 'fraction_numerical': 0.0, 'mean_word_length': 5.039501039501039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891532', 'n_tokens_mistral': 840, 'n_tokens_neox': 815, 'n_words': 134}