import pytest

from standardize_test_format import NamingScheme, standardize_java_text, Config

INPUT_1 = """
package test;

@Test
@DisplayName("Invocations fail with callers without required permissions")
public void selectInvocationWithoutPermission() { }
"""

OUTPUT_1 = """
package test;
import org.junit.jupiter.api.DisplayName;

@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""

INPUT_2 = """
package test;

/** Invocations fail with callers without required permissions. */
@Test
public void selectInvocationWithoutPermission() { }
"""

OUTPUT_2 = """
package test;
import org.junit.jupiter.api.DisplayName;

@Test
@DisplayName("Invocations fail with callers without required permissions")
public void invocationsFailWithCallersWithoutRequiredPermissions() { }
"""

INPUT_3 = """
package test;

@Test
public void helloWorldTest(
"""

OUTPUT_3 = """
package test;
import org.junit.jupiter.api.DisplayName;

@Test
@DisplayName("Hello World Test")
public void helloWorld(
"""

INPUT_4 = """
package test;

/**
 * Concat two produces a new array with the two input arrays joined together, with no separators.
 */
@Test
public void concatTwo()
"""

OUTPUT_4 = """
package test;
import org.junit.jupiter.api.DisplayName;

@Test
@DisplayName("Concat two produces a new array with the two input arrays joined together, with no separators")
public void concatTwoProducesNewArrayWithTwoInputArraysJoinedTogetherWithNoSeparators()
"""

INPUT_5 = """
package test;

/**
 * {@link ZkBinderContextImpl} propagates a lot of fields directly from the underlying {@link
 * ZkBinderContext}.
 */
@Test
public void propagate()
"""

INPUT_5B = """
package test;

@Test
@DisplayName(
  "ZkBinderContextImpl propagates a lot of fields directly from the underlying ZkBinderContext")
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""

INPUT_5C = """
package test;

@Test
@DisplayName(
  "ZkBinderContextImpl propagates a lot of "
      + "fields directly from "
      + "the underlying ZkBinderContext"
)
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""

INPUT_5D = """
package test;

@DisplayName(
  "ZkBinderContextImpl propagates a lot of "
      + "fields directly from "
      + "the underlying ZkBinderContext"
)
@Test
public void zkBinderContextImplPropagatesLotOfFieldsDirectlyFromTheUnderlyingZkBinderContext()
"""

OUTPUT_5 = """
package test;
import org.junit.jupiter.api.DisplayName;

@Test
@DisplayName("ZkBinderContextImpl propagates a lot of fields directly from the underlying ZkBinderContext")
public void zkBinderContextImplPropagatesLotFieldsDirectlyFromUnderlyingZkBinderContext()
"""

JAVADOC_TO_DISPLAYNAME = [
    (INPUT_1, OUTPUT_1),
    (INPUT_2, OUTPUT_2),
    (INPUT_3, OUTPUT_3),
    (INPUT_4, OUTPUT_4),
    (INPUT_5, OUTPUT_5),
    (INPUT_5B, OUTPUT_5),
    (INPUT_5C, OUTPUT_5),
    (INPUT_5D, OUTPUT_5),
]


@pytest.mark.parametrize(('inp','output'), JAVADOC_TO_DISPLAYNAME)
def test_javadoc_to_displayname(inp: str, output: str):
    config = Config(
        with_javadoc=False,
        with_display_name=True,
        only_for_javadoc = False,
        only_for_display_name = False,
        naming_scheme=NamingScheme.FROM_DESC,
    )
    converted = standardize_java_text(inp.strip(), config)
    assert converted == output.strip()