ConfigMapLock implements Lock { @Override public <C extends Namespaceable<C> & KubernetesClient> void create( C client, LeaderElectionRecord leaderElectionRecord) throws LockException { try { client.inNamespace(configMapNamespace).configMaps().withName(configMapName).createNew() .editOrNewMetadata().withNamespace(configMapNamespace).withName(configMapName) .addToAnnotations(LEADER_ELECTION_RECORD_ANNOTATION_KEY, objectMapper.writeValueAsString(leaderElectionRecord)) .endMetadata() .done(); } catch (Exception e) { throw new LockException("Unable to create ConfigMapLock", e); } } ConfigMapLock(String configMapNamespace, String configMapName, String identity); @Override LeaderElectionRecord get(C client); @Override void create(
    C client, LeaderElectionRecord leaderElectionRecord); @Override void update(
    C client, LeaderElectionRecord leaderElectionRecord); @Override String identity(); @Override String describe();  }
@Test void createWithValidLeaderElectionRecordShouldSendPostRequest() throws Exception { when(metadata .withNamespace("namespace") .withName("name") .addToAnnotations(eq("control-plane.alpha.kubernetes.io/leader"), anyString()).endMetadata() ).thenReturn(doneableConfigMap); final LeaderElectionRecord record = new LeaderElectionRecord( "1", Duration.ofSeconds(1), ZonedDateTime.now(), ZonedDateTime.now(), 0); final ConfigMapLock lock = new ConfigMapLock("namespace", "name", "1337"); lock.create(kc, record); verify(doneableConfigMap, times(1)).done(); }