The repeating part of the test's HTML such as javascript and href in the <a> tags can be managed by a OCPJP flavored java program:
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class test{
private static final String URLBASE = "http://xyzcode.blogspot.com/2017/01/ocpjp-simulation-test-";
private static Map<Integer, String> qNumberAnswers = new HashMap<>();
public static final int[] PRE_SET_SEQUENCE = new int[] { 1, 2 };
public static final int[] ClassDesign = new int[] { 1, 2, 3, 4,5,6,7,8,9,10 };
public static final int[] GenericsandCollections = new int[] { 11, 12, 13,14,15,16,17 };
public static final int[] LambdaandStream = new int[] { 21, 22 };
public static final int[] ExceptionsandAssertions = new int[] { 31, 32 };
public static final int[] DateTimeAPI = new int[] { 41, 42 };
public static final int[] IO = new int[] { 51, 52 };
public static final int[] Concurrency = new int[] { 61, 62,63,64,65,66 };
public static final int[] JDBC = new int[] { 71, 72 };
public static final int[] Localization = new int[] { 81, 82 };
public static final int[] MISC = new int[] { 91, 92,93,94,95,96,97 };
public static Map<int[], Integer> weight = new HashMap<>();
//total 25
static {
weight.put(ClassDesign, 5);
weight.put(GenericsandCollections, 2);
weight.put(LambdaandStream, 1);
weight.put(ExceptionsandAssertions, 2);
weight.put(DateTimeAPI, 1);
weight.put(IO, 1);
weight.put(Concurrency, 3);
weight.put(JDBC, 1);
weight.put(Localization, 1);
weight.put(MISC, 5);
}
public static final int[][] MIXER = new int[][] {ClassDesign, GenericsandCollections, LambdaandStream,
ExceptionsandAssertions, DateTimeAPI, IO, Concurrency, JDBC, Localization, MISC};
static {
qNumberAnswers.put(1, "B, H,");
qNumberAnswers.put(2, "B, H,");
qNumberAnswers.put(3, "B, H,");
qNumberAnswers.put(4, "B, H,");
qNumberAnswers.put(5, "B, H,");
qNumberAnswers.put(6, "B, H,");
qNumberAnswers.put(7, "B, H,");
qNumberAnswers.put(8, "B, H,");
qNumberAnswers.put(9, "B, H,");
qNumberAnswers.put(10, "B, H,");
qNumberAnswers.put(11, "B, H,");
qNumberAnswers.put(12, "B, H,");
qNumberAnswers.put(13, "B, H,");
qNumberAnswers.put(14, "B, H,");
qNumberAnswers.put(15, "B, H,");
qNumberAnswers.put(16, "B, H,");
qNumberAnswers.put(17, "B, H,");
qNumberAnswers.put(18, "B, H,");
qNumberAnswers.put(19, "B, H,");
qNumberAnswers.put(20, "B, H,");
qNumberAnswers.put(21, "B, H,");
qNumberAnswers.put(22, "B, H,");
qNumberAnswers.put(23, "B, H,");
qNumberAnswers.put(24, "B, H,");
qNumberAnswers.put(25, "B, H,");
qNumberAnswers.put(26, "B, H,");
qNumberAnswers.put(27, "B, H,");
qNumberAnswers.put(28, "B, H,");
qNumberAnswers.put(29, "B, H,");
qNumberAnswers.put(30, "B, H,");
qNumberAnswers.put(31, "B, H,");
qNumberAnswers.put(32, "B, H,");
qNumberAnswers.put(33, "B, H,");
qNumberAnswers.put(34, "B, H,");
qNumberAnswers.put(35, "B, H,");
qNumberAnswers.put(36, "B, H,");
qNumberAnswers.put(37, "B, H,");
qNumberAnswers.put(38, "B, H,");
qNumberAnswers.put(39, "B, H,");
qNumberAnswers.put(40, "B, H,");
qNumberAnswers.put(41, "B, H,");
qNumberAnswers.put(42, "B, H,");
qNumberAnswers.put(43, "B, H,");
qNumberAnswers.put(44, "B, H,");
qNumberAnswers.put(45, "B, H,");
qNumberAnswers.put(46, "B, H,");
qNumberAnswers.put(47, "B, H,");
qNumberAnswers.put(48, "B, H,");
qNumberAnswers.put(49, "B, H,");
qNumberAnswers.put(50, "B, H,");
qNumberAnswers.put(51, "B, H,");
qNumberAnswers.put(52, "B, H,");
qNumberAnswers.put(53, "B, H,");
qNumberAnswers.put(54, "B, H,");
qNumberAnswers.put(55, "B, H,");
qNumberAnswers.put(56, "B, H,");
qNumberAnswers.put(57, "B, H,");
qNumberAnswers.put(58, "B, H,");
qNumberAnswers.put(59, "B, H,");
qNumberAnswers.put(60, "B, H,");
qNumberAnswers.put(61, "B, H,");
qNumberAnswers.put(62, "B, H,");
qNumberAnswers.put(63, "B, H,");
qNumberAnswers.put(64, "B, H,");
qNumberAnswers.put(65, "B, H,");
qNumberAnswers.put(66, "B, H,");
qNumberAnswers.put(67, "B, H,");
qNumberAnswers.put(68, "B, H,");
qNumberAnswers.put(69, "B, H,");
qNumberAnswers.put(70, "B, H,");
qNumberAnswers.put(71, "B, H,");
qNumberAnswers.put(72, "B, H,");
qNumberAnswers.put(73, "B, H,");
qNumberAnswers.put(74, "B, H,");
qNumberAnswers.put(75, "B, H,");
qNumberAnswers.put(76, "B, H,");
qNumberAnswers.put(77, "B, H,");
qNumberAnswers.put(78, "B, H,");
qNumberAnswers.put(79, "B, H,");
qNumberAnswers.put(80, "B, H,");
qNumberAnswers.put(81, "B, H,");
qNumberAnswers.put(82, "B, H,");
qNumberAnswers.put(83, "B, H,");
qNumberAnswers.put(84, "B, H,");
qNumberAnswers.put(85, "B, H,");
qNumberAnswers.put(86, "B, H,");
qNumberAnswers.put(87, "B, H,");
qNumberAnswers.put(88, "B, H,");
qNumberAnswers.put(89, "B, H,");
qNumberAnswers.put(90, "B, H,");
qNumberAnswers.put(91, "B, H,");
qNumberAnswers.put(92, "B, H,");
qNumberAnswers.put(93, "B, H,");
qNumberAnswers.put(94, "B, H,");
qNumberAnswers.put(95, "B, H,");
qNumberAnswers.put(96, "B, H,");
qNumberAnswers.put(97, "B, H,");
qNumberAnswers.put(98, "B, H,");
qNumberAnswers.put(99, "B, H,");
qNumberAnswers.put(100, "B, H,");
qNumberAnswers.put(101, "B, H,");
qNumberAnswers.put(102, "B, H,");
qNumberAnswers.put(103, "B, H,");
qNumberAnswers.put(104, "B, H,");
qNumberAnswers.put(105, "B, H,");
qNumberAnswers.put(106, "B, H,");
qNumberAnswers.put(107, "B, H,");
qNumberAnswers.put(108, "B, H,");
qNumberAnswers.put(109, "B, H,");
qNumberAnswers.put(110, "B, H,");
qNumberAnswers.put(111, "B, H,");
qNumberAnswers.put(112, "B, H,");
qNumberAnswers.put(113, "B, H,");
qNumberAnswers.put(114, "B, H,");
qNumberAnswers.put(115, "B, H,");
qNumberAnswers.put(116, "B, H,");
qNumberAnswers.put(117, "B, H,");
qNumberAnswers.put(118, "B, H,");
qNumberAnswers.put(119, "B, H,");
qNumberAnswers.put(120, "B, H,");
qNumberAnswers.put(121, "B, H,");
qNumberAnswers.put(122, "B, H,");
qNumberAnswers.put(123, "B, H,");
qNumberAnswers.put(124, "B, H,");
qNumberAnswers.put(125, "B, H,");
qNumberAnswers.put(126, "B, H,");
qNumberAnswers.put(127, "B, H,");
qNumberAnswers.put(128, "B, H,");
qNumberAnswers.put(129, "B, H,");
qNumberAnswers.put(130, "B, H,");
qNumberAnswers.put(131, "B, H,");
qNumberAnswers.put(132, "B, H,");
qNumberAnswers.put(133, "B, H,");
qNumberAnswers.put(134, "B, H,");
qNumberAnswers.put(135, "B, H,");
qNumberAnswers.put(136, "B, H,");
qNumberAnswers.put(137, "B, H,");
qNumberAnswers.put(138, "B, H,");
qNumberAnswers.put(139, "B, H,");
qNumberAnswers.put(140, "B, H,");
qNumberAnswers.put(141, "B, H,");
qNumberAnswers.put(142, "B, H,");
qNumberAnswers.put(143, "B, H,");
qNumberAnswers.put(144, "B, H,");
qNumberAnswers.put(145, "B, H,");
qNumberAnswers.put(146, "B, H,");
qNumberAnswers.put(147, "B, H,");
qNumberAnswers.put(148, "B, H,");
qNumberAnswers.put(149, "B, H,");
qNumberAnswers.put(150, "B, H,");
qNumberAnswers.put(151, "B, H,");
qNumberAnswers.put(152, "B, H,");
qNumberAnswers.put(153, "B, H,");
qNumberAnswers.put(154, "B, H,");
qNumberAnswers.put(155, "B, H,");
qNumberAnswers.put(156, "B, H,");
qNumberAnswers.put(157, "B, H,");
qNumberAnswers.put(158, "B, H,");
qNumberAnswers.put(159, "B, H,");
qNumberAnswers.put(160, "B, H,");
qNumberAnswers.put(161, "B, H,");
qNumberAnswers.put(162, "B, H,");
qNumberAnswers.put(163, "B, H,");
qNumberAnswers.put(164, "B, H,");
qNumberAnswers.put(165, "B, H,");
qNumberAnswers.put(166, "B, H,");
qNumberAnswers.put(167, "B, H,");
qNumberAnswers.put(168, "B, H,");
qNumberAnswers.put(169, "B, H,");
qNumberAnswers.put(170, "B, H,");
qNumberAnswers.put(171, "B, H,");
qNumberAnswers.put(172, "B, H,");
qNumberAnswers.put(173, "B, H,");
qNumberAnswers.put(174, "B, H,");
qNumberAnswers.put(175, "B, H,");
qNumberAnswers.put(176, "B, H,");
qNumberAnswers.put(177, "B, H,");
qNumberAnswers.put(178, "B, H,");
qNumberAnswers.put(179, "B, H,");
qNumberAnswers.put(180, "B, H,");
qNumberAnswers.put(181, "B, H,");
qNumberAnswers.put(182, "B, H,");
qNumberAnswers.put(183, "B, H,");
qNumberAnswers.put(184, "B, H,");
qNumberAnswers.put(185, "B, H,");
qNumberAnswers.put(186, "B, H,");
qNumberAnswers.put(187, "B, H,");
qNumberAnswers.put(188, "B, H,");
qNumberAnswers.put(189, "B, H,");
qNumberAnswers.put(190, "B, H,");
qNumberAnswers.put(191, "B, H,");
qNumberAnswers.put(192, "B, H,");
qNumberAnswers.put(193, "B, H,");
qNumberAnswers.put(194, "B, H,");
qNumberAnswers.put(195, "B, H,");
qNumberAnswers.put(196, "B, H,");
qNumberAnswers.put(197, "B, H,");
qNumberAnswers.put(198, "B, H,");
qNumberAnswers.put(199, "B, H,");
qNumberAnswers.put(200, "B, H,");
}
public static void util() {
for(int i = 0; i < 200; i++) {
System.out.println("qNumberAnswers.put("+ (i + 1) +", \"B, H,\");");
}
}
public static void olNodeGenerator() {
/*
* <li><div id="check1"></div>
<a href="http://xyzcode.blogspot.com/2017/01/ocpjp-simulation-test-1.html" id="link1" target="_blank">Question 1</a></li>
*
* */
StringBuffer sb = new StringBuffer();
sb.append("<ol>\n");
for(int i = 0; i < 90; i++) {
sb.append("<li><div id=\"check" + (i + 1) + "\">");
sb.append("</div>\n");
sb.append("<a href=\"" + URLBASE);
sb.append(i+1);
sb.append(".html\" id=\"link");
sb.append(i+1);
sb.append("\" target=\"_blank\">Question ");
sb.append(i+1);
sb.append("</a></li>");
sb.append("\n");
}
sb.append("</ol>\n");
System.out.println(sb.toString());
}
/*
var questions = ["1", "5", "2", "4", "3"];
var answers = ["B,H,", "A,E,", "C,", "B,F,", "C,"];
*/
public static void answerArrayGeneratorRandom() {
int max = 160;
int min = 1;
int maxTotal = 90;
Random rn = new Random();
final Set<Integer> set = new HashSet<>();
IntStream.iterate(1, i->1).limit(maxTotal).forEach(i -> set.add(rn.nextInt(max - min + 1) + min));
System.out.println(set.size());
System.out.println("don't forget to remove the last , in the array");
final StringBuffer sb = new StringBuffer();
set.stream().forEach(i -> sb.append("\"" + i + "\","));
System.out.println("var questions = [" + sb.substring(0,sb.length()-1) + "];");
sb.setLength(0);
set.stream().forEach(i -> sb.append("\"" + qNumberAnswers.get(i) + "\","));
System.out.println("var answers = [" + sb.substring(0,sb.length()-1) + "];");
}
/*
var questions = ["1", "5", "2", "4", "3"];
var answers = ["B,H,", "A,E,", "C,", "B,F,", "C,"];
*/
public static void answerArrayGeneratorControl() {
System.out.println(PRE_SET_SEQUENCE.length);
System.out.println("don't forget to remove the last , in the array");
final StringBuffer sb = new StringBuffer();
Arrays.stream(PRE_SET_SEQUENCE).forEach(i -> sb.append("\"" + i + "\","));
System.out.println("var questions = [" + sb.substring(0,sb.length()-1) + "];");
sb.setLength(0);
Arrays.stream(PRE_SET_SEQUENCE).forEach(i -> sb.append("\"" + qNumberAnswers.get(i) + "\","));
System.out.println("var answers = [" + sb.substring(0,sb.length()-1) + "];");
}
/*
var questions = ["1", "5", "2", "4", "3"];
var answers = ["B,H,", "A,E,", "C,", "B,F,", "C,"];
*/
public static void answerArrayGeneratorSemiRandom() {
Random rn = new Random();
List<Integer> mixerList = new ArrayList<>();
Arrays.stream(MIXER).forEach(i -> {
mixerList.addAll(
rn.ints(0, i.length).distinct().limit(weight.get(i))
.mapToObj(k -> i[k]).collect(Collectors.toSet()));
});
System.out.println(mixerList.size());
Collections.shuffle(mixerList);
final StringBuffer sb = new StringBuffer();
mixerList.forEach(i -> sb.append("\"" + i + "\","));
System.out.println("var questions = [" + sb.substring(0,sb.length()-1) + "];");
sb.setLength(0);
mixerList.forEach(i -> sb.append("\"" + qNumberAnswers.get(i) + "\","));
System.out.println("var answers = [" + sb.substring(0,sb.length()-1) + "];");
}
public static void main(String...args) {
//olNodeGenerator();
//util();
//answerArrayGeneratorRandom();
//answerArrayGeneratorControl();
answerArrayGeneratorSemiRandom();
}
}