Amazon Interview Question for Interns
- 1of 1 vote
AnswersWrite a Junit test for the following 2 methods in the class which test for properties file as well:
- newbieJunit September 16, 2016 in India
public class Test{
private HashMap<String, String> aTCN;
private static final String alpha= "alpha.";
private static final String beta = "beta.";
private Properties exporterConfig;
private static final ADFLogger LOG = ADFLoggerFactory.getLogger("R",R.class);
public Map<String, String> getATCN() {
if (aTCN== null) {
aTCN= new HashMap<>();
Properties demo= new Properties();
try {
demo.load(ClassLoader.getSystemResourceAsStream("r1.properties"));
} catch (IOException e) {
LOG.emitError("", e.getMessage());
}
for (String columnName : demo.stringPropertyNames()) {
aTCN.put(columnName.replace(beta, ""),
demo.getProperty(columnName).replace(alpha, ""));
}
}
return aTCN;
}
public Properties getEC() {
if (eC== null) {
try {
exporterConfig = new Properties();
exporterConfig.load(ClassLoader.getSystemResourceAsStream("r2.properties"));
} catch (IOException e) {
LOG.emitError("", e.getMessage());
}
}
return eC;
}
}
I was unable to figure out the same. Let me know if any one has any solution.| Report Duplicate | Flag | PURGE
Amazon Intern Testing
Interview Type: Phone Interview