cleanup work and test naming
This commit is contained in:
parent
2b374fa8ae
commit
e0b85586e2
@ -9,8 +9,6 @@ public class TenantBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sayHello() {
|
public void sayHello() {
|
||||||
System.out.println(String.format("Hello from %s of type %s",
|
System.out.println(String.format("Hello from %s of type %s", this.name, this.getClass().getName()));
|
||||||
this.name,
|
|
||||||
this.getClass().getName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class TenantScope implements Scope {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object get(String name, ObjectFactory<?> objectFactory) {
|
public Object get(String name, ObjectFactory<?> objectFactory) {
|
||||||
if(!scopedObjects.containsKey(name)) {
|
if (!scopedObjects.containsKey(name)) {
|
||||||
scopedObjects.put(name, objectFactory.getObject());
|
scopedObjects.put(name, objectFactory.getObject());
|
||||||
}
|
}
|
||||||
return scopedObjects.get(name);
|
return scopedObjects.get(name);
|
||||||
|
@ -25,7 +25,7 @@ public class SimpleReportExporter {
|
|||||||
public SimpleReportExporter() {
|
public SimpleReportExporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleReportExporter (JasperPrint jasperPrint){
|
public SimpleReportExporter(JasperPrint jasperPrint) {
|
||||||
this.jasperPrint = jasperPrint;
|
this.jasperPrint = jasperPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +37,6 @@ public class SimpleReportExporter {
|
|||||||
this.jasperPrint = jasperPrint;
|
this.jasperPrint = jasperPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void exportToPdf(String fileName, String author) {
|
public void exportToPdf(String fileName, String author) {
|
||||||
|
|
||||||
// print report to file
|
// print report to file
|
||||||
@ -61,27 +59,25 @@ public class SimpleReportExporter {
|
|||||||
try {
|
try {
|
||||||
exporter.exportReport();
|
exporter.exportReport();
|
||||||
} catch (JRException ex) {
|
} catch (JRException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exportToXlsx(String fileName,String sheetName) {
|
public void exportToXlsx(String fileName, String sheetName) {
|
||||||
JRXlsxExporter exporter = new JRXlsxExporter();
|
JRXlsxExporter exporter = new JRXlsxExporter();
|
||||||
|
|
||||||
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
|
||||||
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fileName));
|
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fileName));
|
||||||
|
|
||||||
SimpleXlsxReportConfiguration reportConfig = new SimpleXlsxReportConfiguration();
|
SimpleXlsxReportConfiguration reportConfig = new SimpleXlsxReportConfiguration();
|
||||||
reportConfig.setSheetNames(new String[]{sheetName});
|
reportConfig.setSheetNames(new String[] { sheetName });
|
||||||
|
|
||||||
exporter.setConfiguration(reportConfig);
|
exporter.setConfiguration(reportConfig);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
exporter.exportReport();
|
exporter.exportReport();
|
||||||
} catch (JRException ex) {
|
} catch (JRException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +90,7 @@ public class SimpleReportExporter {
|
|||||||
try {
|
try {
|
||||||
exporter.exportReport();
|
exporter.exportReport();
|
||||||
} catch (JRException ex) {
|
} catch (JRException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +103,7 @@ public class SimpleReportExporter {
|
|||||||
try {
|
try {
|
||||||
exporter.exportReport();
|
exporter.exportReport();
|
||||||
} catch (JRException ex) {
|
} catch (JRException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ public class SimpleReportFiller {
|
|||||||
jasperReport = JasperCompileManager.compileReport(reportStream);
|
jasperReport = JasperCompileManager.compileReport(reportStream);
|
||||||
JRSaver.saveObject(jasperReport, reportFileName.replace(".jrxml", ".jasper"));
|
JRSaver.saveObject(jasperReport, reportFileName.replace(".jrxml", ".jasper"));
|
||||||
} catch (JRException ex) {
|
} catch (JRException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +53,7 @@ public class SimpleReportFiller {
|
|||||||
try {
|
try {
|
||||||
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource.getConnection());
|
jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource.getConnection());
|
||||||
} catch (JRException | SQLException ex) {
|
} catch (JRException | SQLException ex) {
|
||||||
Logger.getLogger(SimpleReportFiller.class.getName())
|
Logger.getLogger(SimpleReportFiller.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,7 @@ public class JasperRerportsSimpleConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
return new EmbeddedDatabaseBuilder()
|
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).addScript("classpath:employee-schema.sql").build();
|
||||||
.setType(EmbeddedDatabaseType.HSQL)
|
|
||||||
.addScript("classpath:employee-schema.sql")
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -33,36 +33,25 @@ public class SimpleCLI implements CommandMarker {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@CliCommand(
|
@CliCommand(value = { "web-get", "wg" }, help = "Displays the contents of a URL.")
|
||||||
value = {"web-get", "wg"},
|
public String webGet(@CliOption(key = { "", "url" }, help = "URL whose contents will be displayed.") URL url) {
|
||||||
help = "Displays the contents of a URL."
|
|
||||||
)
|
|
||||||
public String webGet(
|
|
||||||
@CliOption(
|
|
||||||
key = {"", "url"},
|
|
||||||
help = "URL whose contents will be displayed."
|
|
||||||
) URL url) {
|
|
||||||
return getContentsOfUrlAsString(url);
|
return getContentsOfUrlAsString(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@CliCommand(
|
@CliCommand(value = { "web-save", "ws" }, help = "Saves the contents of a URL.")
|
||||||
value = {"web-save", "ws"},
|
public String webSave(@CliOption(key = { "", "url" }, help = "URL whose contents will be saved.") URL url, @CliOption(key = { "out", "file" }, mandatory = true, help = "The name of the file.") String file) {
|
||||||
help = "Saves the contents of a URL.")
|
|
||||||
public String webSave(
|
|
||||||
@CliOption(key = {"", "url"}, help = "URL whose contents will be saved.") URL url,
|
|
||||||
@CliOption(key = {"out", "file"}, mandatory = true, help = "The name of the file.") String file) {
|
|
||||||
String contents = getContentsOfUrlAsString(url);
|
String contents = getContentsOfUrlAsString(url);
|
||||||
try (PrintWriter out = new PrintWriter(file)) {
|
try (PrintWriter out = new PrintWriter(file)) {
|
||||||
out.write(contents);
|
out.write(contents);
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
//Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
return "Done.";
|
return "Done.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean adminEnableExecuted = false;
|
private boolean adminEnableExecuted = false;
|
||||||
|
|
||||||
@CliAvailabilityIndicator(value = {"web-save"})
|
@CliAvailabilityIndicator(value = { "web-save" })
|
||||||
public boolean isAdminEnabled() {
|
public boolean isAdminEnabled() {
|
||||||
return adminEnableExecuted;
|
return adminEnableExecuted;
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,13 @@ public class SimpleURLConverter implements Converter<URL> {
|
|||||||
try {
|
try {
|
||||||
return new URL(value);
|
return new URL(value);
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
//Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAllPossibleValues(List<Completion> completions, Class<?> requiredType,
|
public boolean getAllPossibleValues(List<Completion> completions, Class<?> requiredType, String existingData, String optionContext, MethodTarget target) {
|
||||||
String existingData, String optionContext, MethodTarget target) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ import org.springframework.retry.support.RetryTemplate;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(basePackages = "org.baeldung.springretry")
|
@ComponentScan(basePackages = "org.baeldung.springretry")
|
||||||
@EnableRetry
|
@EnableRetry
|
||||||
//Uncomment this two lines if we need XML configuration
|
// Uncomment this two lines if we need XML configuration
|
||||||
//@EnableAspectJAutoProxy
|
// @EnableAspectJAutoProxy
|
||||||
//@ImportResource("classpath:/retryadvice.xml")
|
// @ImportResource("classpath:/retryadvice.xml")
|
||||||
public class AppConfig {
|
public class AppConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -22,26 +22,27 @@ public class ThreadPoolTaskSchedulerExamples {
|
|||||||
private PeriodicTrigger periodicTrigger;
|
private PeriodicTrigger periodicTrigger;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void scheduleRunnableWithCronTrigger(){
|
public void scheduleRunnableWithCronTrigger() {
|
||||||
taskScheduler.schedule(new RunnableTask("Current Date"), new Date());
|
taskScheduler.schedule(new RunnableTask("Current Date"), new Date());
|
||||||
taskScheduler.scheduleWithFixedDelay(new RunnableTask("Fixed 1 second Delay"), 1000);
|
taskScheduler.scheduleWithFixedDelay(new RunnableTask("Fixed 1 second Delay"), 1000);
|
||||||
taskScheduler.scheduleWithFixedDelay(new RunnableTask("Current Date Fixed 1 second Delay"),new Date() , 1000);
|
taskScheduler.scheduleWithFixedDelay(new RunnableTask("Current Date Fixed 1 second Delay"), new Date(), 1000);
|
||||||
taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"),new Date(), 2000);
|
taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), new Date(), 2000);
|
||||||
taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), 2000);
|
taskScheduler.scheduleAtFixedRate(new RunnableTask("Fixed Rate of 2 seconds"), 2000);
|
||||||
taskScheduler.schedule(new RunnableTask("Cron Trigger"), cronTrigger);
|
taskScheduler.schedule(new RunnableTask("Cron Trigger"), cronTrigger);
|
||||||
taskScheduler.schedule(new RunnableTask("Periodic Trigger"), periodicTrigger);
|
taskScheduler.schedule(new RunnableTask("Periodic Trigger"), periodicTrigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RunnableTask implements Runnable{
|
class RunnableTask implements Runnable {
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public RunnableTask(String message){
|
public RunnableTask(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.println("Runnable Task with "+message+" on thread "+Thread.currentThread().getName());
|
System.out.println("Runnable Task with " + message + " on thread " + Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,19 +5,17 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
public class ConstructorBasedBeanInjectionWithJavaConfigTest {
|
public class ConstructorBasedBeanInjectionWithJavaConfigIntegrationTest {
|
||||||
private static final String HELM_NAME = "HelmBrand";
|
private static final String HELM_NAME = "HelmBrand";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenJavaConfigFile_whenUsingConstructorBasedBeanInjection_thenCorrectHelmName() {
|
public void givenJavaConfigFile_whenUsingConstructorBasedBeanInjection_thenCorrectHelmName() {
|
||||||
|
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
ctx.register(ConstructorBasedShipConfig.class);
|
ctx.register(ConstructorBasedShipConfig.class);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
Ship ship = ctx.getBean(Ship.class);
|
Ship ship = ctx.getBean(Ship.class);
|
||||||
|
|
||||||
Assert.assertEquals(HELM_NAME, ship.getHelm()
|
Assert.assertEquals(HELM_NAME, ship.getHelm().getBrandOfHelm());
|
||||||
.getBrandOfHelm());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
public class ConstructorBasedBeanInjectionWithXMLConfigTest {
|
public class ConstructorBasedBeanInjectionWithXMLConfigIntegrationTest {
|
||||||
|
|
||||||
private static final String HELM_NAME = "HelmBrand";
|
private static final String HELM_NAME = "HelmBrand";
|
||||||
|
|
||||||
@ -14,7 +14,6 @@ public class ConstructorBasedBeanInjectionWithXMLConfigTest {
|
|||||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-constructor.xml");
|
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-constructor.xml");
|
||||||
|
|
||||||
final Ship shipConstructorBean = (Ship) applicationContext.getBean("ship");
|
final Ship shipConstructorBean = (Ship) applicationContext.getBean("ship");
|
||||||
Assert.assertEquals(HELM_NAME, shipConstructorBean.getHelm()
|
Assert.assertEquals(HELM_NAME, shipConstructorBean.getHelm().getBrandOfHelm());
|
||||||
.getBrandOfHelm());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
public class SetterBasedBeanInjectionWithJavaConfigTest {
|
public class SetterBasedBeanInjectionWithJavaConfigIntegrationTest {
|
||||||
|
|
||||||
private static final String HELM_NAME = "HelmBrand";
|
private static final String HELM_NAME = "HelmBrand";
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ public class SetterBasedBeanInjectionWithJavaConfigTest {
|
|||||||
|
|
||||||
Ship ship = ctx.getBean(Ship.class);
|
Ship ship = ctx.getBean(Ship.class);
|
||||||
|
|
||||||
Assert.assertEquals(HELM_NAME, ship.getHelm()
|
Assert.assertEquals(HELM_NAME, ship.getHelm().getBrandOfHelm());
|
||||||
.getBrandOfHelm());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
public class SetterBasedBeanInjectionWithXMLConfigTest {
|
public class SetterBasedBeanInjectionWithXMLConfigIntegrationTest {
|
||||||
|
|
||||||
private static final String HELM_NAME = "HelmBrand";
|
private static final String HELM_NAME = "HelmBrand";
|
||||||
|
|
||||||
@ -14,7 +14,6 @@ public class SetterBasedBeanInjectionWithXMLConfigTest {
|
|||||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-setter.xml");
|
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beanInjection-setter.xml");
|
||||||
|
|
||||||
final Ship shipSetterBean = (Ship) applicationContext.getBean("ship");
|
final Ship shipSetterBean = (Ship) applicationContext.getBean("ship");
|
||||||
Assert.assertEquals(HELM_NAME, shipSetterBean.getHelm()
|
Assert.assertEquals(HELM_NAME, shipSetterBean.getHelm().getBrandOfHelm());
|
||||||
.getBrandOfHelm());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ public class TenantScopeTest {
|
|||||||
@Test
|
@Test
|
||||||
public final void whenRegisterScopeAndBeans_thenContextContainsFooAndBar() {
|
public final void whenRegisterScopeAndBeans_thenContextContainsFooAndBar() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
try{
|
try {
|
||||||
ctx.register(TenantScopeConfig.class);
|
ctx.register(TenantScopeConfig.class);
|
||||||
ctx.register(TenantBeansConfig.class);
|
ctx.register(TenantBeansConfig.class);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
@ -37,8 +37,7 @@ public class TenantScopeTest {
|
|||||||
|
|
||||||
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
||||||
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +45,7 @@ public class TenantScopeTest {
|
|||||||
@Test
|
@Test
|
||||||
public final void whenComponentScan_thenContextContainsFooAndBar() {
|
public final void whenComponentScan_thenContextContainsFooAndBar() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||||
try{
|
try {
|
||||||
ctx.scan("org.baeldung.customscope");
|
ctx.scan("org.baeldung.customscope");
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
@ -66,8 +65,7 @@ public class TenantScopeTest {
|
|||||||
|
|
||||||
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
assertThat(fooDefinition.getScope(), equalTo("tenant"));
|
||||||
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
assertThat(barDefinition.getScope(), equalTo("tenant"));
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ public class SquareCalculatorTest {
|
|||||||
public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() {
|
public void whenCalculatingSquareValueOnce_thenCacheDontHaveValues() {
|
||||||
for (int i = 10; i < 15; i++) {
|
for (int i = 10; i < 15; i++) {
|
||||||
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||||
System.out.println("Square value of " + i + " is: "
|
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,14 +29,12 @@ public class SquareCalculatorTest {
|
|||||||
public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() {
|
public void whenCalculatingSquareValueAgain_thenCacheHasAllValues() {
|
||||||
for (int i = 10; i < 15; i++) {
|
for (int i = 10; i < 15; i++) {
|
||||||
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
assertFalse(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||||
System.out.println("Square value of " + i + " is: "
|
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 10; i < 15; i++) {
|
for (int i = 10; i < 15; i++) {
|
||||||
assertTrue(cacheHelper.getSquareNumberCache().containsKey(i));
|
assertTrue(cacheHelper.getSquareNumberCache().containsKey(i));
|
||||||
System.out.println("Square value of " + i + " is: "
|
System.out.println("Square value of " + i + " is: " + squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
||||||
+ squaredCalculator.getSquareValueOfNumber(i) + "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user