<filename>thenReturn2DoReturn.py<gh_stars>0
import clipboard


def findIndexByWord(splitedSentence, wordToSearch):
    for index, item in enumerate(splitedSentence) :
        if wordToSearch in item:
            return index
			
def thenReturn2DoReturn(sentence):
    print("Transforming thenReturn sentence to doReturn sentence")
    sentence = sentence.replace("thenReturn", "doReturn")
    splitedSentence = sentence.split(".")
    thenReturnIndex = findIndexByWord(splitedSentence,"doReturn")
    whenIndex = findIndexByWord(splitedSentence,"when")
    if whenIndex < thenReturnIndex:
        splitedSentence[whenIndex] , splitedSentence[thenReturnIndex]  = splitedSentence[thenReturnIndex] , splitedSentence[whenIndex]
    finalString = ".".join(splitedSentence)
    print(finalString)

def doReturn2thenReturn(sentence):
    print("Transforming doReturn sentence to thenReturn sentence")
    sentence = sentence.replace("doReturn", "thenReturn")
    print(sentence)


clipboard.copy("Mockito.when(alguien.cxxxxx).thenReturn(esto)")
senteceToTransform = clipboard.paste()
print("iniciando transformacion de : "+senteceToTransform)
splitedSentence = senteceToTransform.split(".")
print(splitedSentence)


if "thenReturn" in senteceToTransform :
    print("It is a thenReturn sentence")
    thenReturn2DoReturn(senteceToTransform)
elif "doReturn" in senteceToTransform :
    print("It is a doReturn sentence")
    doReturn2thenReturn(senteceToTransform)
else :
    print("It is not a thenReturn or doReturn sentence coming out of the script")


<filename>thenReturn2DoReturn.py<gh_stars>0
import clipboard


def findIndexByWord(splitedSentence, wordToSearch):
    for index, item in enumerate(splitedSentence) :
        if wordToSearch in item:
            return index
			
def thenReturn2DoReturn(sentence):
    print("Transforming thenReturn sentence to doReturn sentence")
    sentence = sentence.replace("thenReturn", "doReturn")
    splitedSentence = sentence.split(".")
    thenReturnIndex = findIndexByWord(splitedSentence,"doReturn")
    whenIndex = findIndexByWord(splitedSentence,"when")
    if whenIndex < thenReturnIndex:
        splitedSentence[whenIndex] , splitedSentence[thenReturnIndex]  = splitedSentence[thenReturnIndex] , splitedSentence[whenIndex]
    finalString = ".".join(splitedSentence)
    print(finalString)

def doReturn2thenReturn(sentence):
    print("Transforming doReturn sentence to thenReturn sentence")
    sentence = sentence.replace("doReturn", "thenReturn")
    print(sentence)


clipboard.copy("Mockito.when(alguien.cxxxxx).thenReturn(esto)")
senteceToTransform = clipboard.paste()
print("iniciando transformacion de : "+senteceToTransform)
splitedSentence = senteceToTransform.split(".")
print(splitedSentence)


if "thenReturn" in senteceToTransform :
    print("It is a thenReturn sentence")
    thenReturn2DoReturn(senteceToTransform)
elif "doReturn" in senteceToTransform :
    print("It is a doReturn sentence")
    doReturn2thenReturn(senteceToTransform)
else :
    print("It is not a thenReturn or doReturn sentence coming out of the script")

