DataServiceVisitorJsBuilder extends AbstractDataServiceVisitor { String computeKeys(ExecutableElement methodElement, List<String> arguments) { String keys = stringJoinAndDecorate(arguments, COMMA, new NothingDecorator()); if (arguments != null && !arguments.isEmpty()) { JsCacheResult jcr = methodElement.getAnnotation(JsCacheResult.class); if (!considerateAllArgs(jcr)) { keys = stringJoinAndDecorate(Arrays.asList(jcr.keys()), COMMA, new KeyForArgDecorator()); } } return keys; } DataServiceVisitorJsBuilder(ProcessingEnvironment environment, FwkWriter fwk);   }
@Test public void testComputeKeysFromSpecificArgs() throws IOException { System.out.println("computeKeys"); List<String> arguments = Arrays.asList("a", "b", "c", "d"); JsCacheResult jcr = mock(JsCacheResult.class); when(jcr.keys()).thenReturn(new String[]{"a.c", "b.i", "d"}); ExecutableElement methodElement = mock(ExecutableElement.class); when(methodElement.getAnnotation(eq(JsCacheResult.class))).thenReturn(jcr); String result = instance.computeKeys(methodElement, arguments); assertThat(result).isEqualTo("(a)?a.c:null,(b)?b.i:null,d"); }
@Test public void testComputeKeysFromNoArg() throws IOException { System.out.println("computeKeys"); List<String> arguments = new ArrayList(); ExecutableElement methodElement = mock(ExecutableElement.class); String result = instance.computeKeys(methodElement, arguments); assertThat(result).isEqualTo(""); }
@Test public void testComputeKeysFromNullArg() throws IOException { System.out.println("computeKeys"); ExecutableElement methodElement = mock(ExecutableElement.class); String result = instance.computeKeys(methodElement, null); assertThat(result).isEqualTo(""); }