두 개의 클래스 Parameter 및 ParameterList가 있습니다. ParameterList 클래스는 Parameters로 구성된 ArrayList입니다. 키 값으로 목록에서 매개 변수를 찾는 메소드 getParameterByKey가 있습니다. 나는 값을 키에 따라 다르기를 원하기 때문에 Parameter.getValueString()을 모의하고 싶지 않으며, 각 키/값에 조롱이 필요하다. 모든 입력을 부탁드립니다.다른 클래스의 컨텍스트 내에서 메소드 조롱
"A431"키를 가져 와서 "BOSTON"(등)을 반환하지만 "java.lang.NullPointerException"을 얻고 싶습니다.
when(mockedParmList.getParameterByKey("A431").getValueString()).thenReturn("BOSTON");
when(mockedParmList.getParameterByKey("A432").getValueString()).thenReturn("NYC")
나는 원하는 각 가치에 대한 보상을 조롱하는 일을 피하려고했지만 null 문제를 해결할 수 있습니다. – Abercrombieande