@Test public void shouldReturnParameterNamesFromDebugSymbolsForConstructor() throws Exception { ParanamerParameterNameProvider parameterNameProvider = new ParanamerParameterNameProvider(); Constructor<ComputerGame> constructor = ComputerGame.class.getConstructor(String.class); List<String> parameterNames = parameterNameProvider.getParameterNames(constructor); assertThat(parameterNames).containsExactly("title"); }
@Test public void shouldReturnParameterNamesFromDebugSymbolsForMethod() throws Exception { ParanamerParameterNameProvider parameterNameProvider = new ParanamerParameterNameProvider(); Method method = ComputerGame.class.getMethod("startGame", String.class, int.class); List<String> parameterNames = parameterNameProvider.getParameterNames(method); assertThat(parameterNames).containsExactly("level", "numberOfPlayers"); }
@Test public void shouldReturnDefaultValuesAsFallBack() throws Exception { ParanamerParameterNameProvider parameterNameProvider = new ParanamerParameterNameProvider(new CustomAnnotationParanamer()); Method method = ComputerGame.class.getMethod("startGame", String.class, int.class); List<String> parameterNames = parameterNameProvider.getParameterNames(method); assertThat(parameterNames).containsExactly("level", "numberOfPlayers"); }
@Test public void shouldReturnParameterNamesFromCustomParanamer() throws Exception { ParanamerParameterNameProvider parameterNameProvider = new ParanamerParameterNameProvider(new CustomAnnotationParanamer()); Constructor<ComputerGame> constructor = ComputerGame.class.getConstructor(String.class); List<String> parameterNames = parameterNameProvider.getParameterNames(constructor); assertThat(parameterNames).containsExactly("gameTitle"); Method method = ComputerGame.class.getMethod("pauseGame", int.class); parameterNames = parameterNameProvider.getParameterNames(method); assertThat(parameterNames).containsExactly("durationInSeconds"); }