@Test public void testAllMinionsAcceptedWithMatchingFingerprint() throws CloudbreakOrchestratorFailedException { MinionKeysOnMasterResponse keysOnMasterResponse = mock(MinionKeysOnMasterResponse.class); MinionFingersOnMasterResponse fingersOnMasterResponse = mock(MinionFingersOnMasterResponse.class); FingerprintFromSbCollector fingerprintCollector = mock(FingerprintFromSbCollector.class); FingerprintsResponse fingerprintsResponse = mock(FingerprintsResponse.class); Minion m1 = new Minion(); m1.setHostName("m1"); m1.setDomain("d"); m1.setAddress("1.1.1.1"); Minion m2 = new Minion(); m2.setHostName("m2"); m2.setDomain("d"); m2.setAddress("1.1.1.2"); Minion m3 = new Minion(); m3.setHostName("m3"); m3.setDomain("d"); m3.setAddress("1.1.1.3"); Minion m4 = new Minion(); m4.setHostName("m4"); m4.setDomain("d"); m4.setAddress("1.1.1.4"); Fingerprint fp1 = new Fingerprint(); fp1.setFingerprint("finger1"); fp1.setAddress("1.1.1.1"); Fingerprint fp2 = new Fingerprint(); fp2.setFingerprint("finger2"); fp2.setAddress("1.1.1.2"); Fingerprint fp3 = new Fingerprint(); fp3.setFingerprint("badFinger"); fp3.setAddress("1.1.1.3"); when(keysOnMasterResponse.getAllMinions()).thenReturn(List.of("m2.d", "m1.d", "m3.d", "m4.d")); when(keysOnMasterResponse.getUnacceptedMinions()).thenReturn(List.of("m2.d", "m1.d", "m3.d")); when(fingersOnMasterResponse.getUnacceptedMinions()).thenReturn(Map.of("m1.d", "finger1", "m2.d", "finger2", "m3.d", "finger3")); when(sc.wheel(eq("key.list_all"), isNull(), eq(MinionKeysOnMasterResponse.class))).thenReturn(keysOnMasterResponse); when(sc.wheel(eq("key.finger"), anyCollection(), eq(MinionFingersOnMasterResponse.class))).thenReturn(fingersOnMasterResponse); when(fingerprintCollector.collectFingerprintFromMinions(eq(sc), argThat(arg -> arg.containsAll(List.of(m1, m2, m3))))).thenReturn(fingerprintsResponse); when(fingerprintsResponse.getFingerprints()).thenReturn(List.of(fp2, fp1, fp3)); MinionAcceptor underTest = spy(new MinionAcceptor(sc, List.of(m1, m2, m3, m4), new EqualMinionFpMatcher(), fingerprintCollector)); underTest.acceptMinions(); verify(sc).wheel(eq("key.accept"), argThat(arg -> arg.containsAll(List.of("m2.d", "m1.d"))), eq(Object.class)); }
public void acceptMinions() throws CloudbreakOrchestratorFailedException { List<String> unacceptedMinions = fetchUnacceptedMinionsFromMaster(minions); if (!unacceptedMinions.isEmpty()) { proceedWithAcceptingMinions(unacceptedMinions); } else { LOGGER.info("No unaccepted minions found on master"); } }
MinionAcceptor { public void acceptMinions() throws CloudbreakOrchestratorFailedException { List<String> unacceptedMinions = fetchUnacceptedMinionsFromMaster(minions); if (!unacceptedMinions.isEmpty()) { proceedWithAcceptingMinions(unacceptedMinions); } else { LOGGER.info("No unaccepted minions found on master"); } } }
MinionAcceptor { public void acceptMinions() throws CloudbreakOrchestratorFailedException { List<String> unacceptedMinions = fetchUnacceptedMinionsFromMaster(minions); if (!unacceptedMinions.isEmpty()) { proceedWithAcceptingMinions(unacceptedMinions); } else { LOGGER.info("No unaccepted minions found on master"); } } MinionAcceptor(SaltConnector sc, List<Minion> minions, MinionFingerprintMatcher fingerprintMatcher, FingerprintCollector fingerprintCollector); }
MinionAcceptor { public void acceptMinions() throws CloudbreakOrchestratorFailedException { List<String> unacceptedMinions = fetchUnacceptedMinionsFromMaster(minions); if (!unacceptedMinions.isEmpty()) { proceedWithAcceptingMinions(unacceptedMinions); } else { LOGGER.info("No unaccepted minions found on master"); } } MinionAcceptor(SaltConnector sc, List<Minion> minions, MinionFingerprintMatcher fingerprintMatcher, FingerprintCollector fingerprintCollector); void acceptMinions(); }
MinionAcceptor { public void acceptMinions() throws CloudbreakOrchestratorFailedException { List<String> unacceptedMinions = fetchUnacceptedMinionsFromMaster(minions); if (!unacceptedMinions.isEmpty()) { proceedWithAcceptingMinions(unacceptedMinions); } else { LOGGER.info("No unaccepted minions found on master"); } } MinionAcceptor(SaltConnector sc, List<Minion> minions, MinionFingerprintMatcher fingerprintMatcher, FingerprintCollector fingerprintCollector); void acceptMinions();  }