assertEquals("", data.getKeyProviderBeanName());
assertEquals(AnnotationData.DEFAULT_INTEGER, data.getKeyIndex());
// No KeyProvider annotations at all
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider01").withArgs(String.class);
try {
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
fail("expected exception");
} catch (InvalidParameterException ex) {}
assertEquals("", data.getKeyProviderBeanName());
assertEquals(AnnotationData.DEFAULT_INTEGER, data.getKeyIndex());
// ReturnKeyProvider with an empty bean name
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider02").withArgs(String.class);
try {
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
fail("expected exception");
} catch (InvalidParameterException ex) {}
assertEquals("", data.getKeyProviderBeanName());
assertEquals(AnnotationData.DEFAULT_INTEGER, data.getKeyIndex());
// ParamKeyProvider with an empty bean name
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider03").withArgs(String.class);
try {
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
fail("expected exception");
} catch (InvalidParameterException ex) {}
assertEquals("", data.getKeyProviderBeanName());
assertEquals(AnnotationData.DEFAULT_INTEGER, data.getKeyIndex());
// Multiple ParamKeyProviders
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider04").withArgs(String.class, String.class);
try {
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
fail("expected exception");
} catch (InvalidParameterException ex) {}
assertEquals("", data.getKeyProviderBeanName());
assertEquals(AnnotationData.DEFAULT_INTEGER, data.getKeyIndex());
// Param KeyProvider with override
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider05").withArgs(String.class, String.class, String.class);
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
assertEquals(AnnotationDataDummy.SAMPLE_PARAM_BEAN, data.getKeyProviderBeanName());
assertEquals(2, data.getKeyIndex());
// Return KeyProvider with override
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider06").withArgs(String.class);
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
assertEquals(AnnotationDataDummy.SAMPLE_RETURN_BEAN, data.getKeyProviderBeanName());
assertEquals(-1, data.getKeyIndex());
// Param KeyProvider without override
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider07").withArgs(String.class, String.class, String.class);
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
assertEquals(AnnotationConstants.DEFAULT_KEY_PROVIDER_BEAN_NAME, data.getKeyProviderBeanName());
assertEquals(1, data.getKeyIndex());
// Return KeyProvider without override
expected = InvalidateSingleCache.class;
targetMethod = new Mirror().on(AnnotationDataDummy.class).reflect()
.method("populateKeyProvider08").withArgs(String.class);
AnnotationDataBuilder.populateKeyIndexAndBeanName(data, expected, targetMethod);
assertEquals(AnnotationConstants.DEFAULT_KEY_PROVIDER_BEAN_NAME, data.getKeyProviderBeanName());
assertEquals(-1, data.getKeyIndex());
}