KafkaConnectS2ICluster extends KafkaConnectCluster { public BuildConfig generateBuildConfig() { BuildTriggerPolicy triggerConfigChange = new BuildTriggerPolicy(); triggerConfigChange.setType("ConfigChange"); BuildTriggerPolicy triggerImageChange = new BuildTriggerPolicy(); triggerImageChange.setType("ImageChange"); triggerImageChange.setImageChange(new ImageChangeTrigger()); BuildConfig build = new BuildConfigBuilder() .withNewMetadata() .withName(KafkaConnectS2IResources.buildConfigName(cluster)) .withLabels(getLabelsWithStrimziName(name, null).toMap()) .withNamespace(namespace) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withFailedBuildsHistoryLimit(5) .withNewOutput() .withNewTo() .withKind("ImageStreamTag") .withName(image) .endTo() .endOutput() .withRunPolicy("Serial") .withNewSource() .withType("Binary") .withBinary(new BinaryBuildSource()) .endSource() .withNewStrategy() .withType("Source") .withNewSourceStrategy() .withScripts("image: .withNewFrom() .withKind("ImageStreamTag") .withName(KafkaConnectS2IResources.sourceImageStreamName(cluster) + ":" + sourceImageTag) .endFrom() .endSourceStrategy() .endStrategy() .withTriggers(triggerConfigChange, triggerImageChange) .withSuccessfulBuildsHistoryLimit(5) .withFailedBuildsHistoryLimit(5) .withResources(buildRequirements) .endSpec() .build(); return build; } private  KafkaConnectS2ICluster(HasMetadata resource); static KafkaConnectS2ICluster fromCrd(KafkaConnectS2I kafkaConnectS2I, KafkaVersion.Lookup versions); DeploymentConfig generateDeploymentConfig(Map<String, String> annotations, boolean isOpenShift, ImagePullPolicy imagePullPolicy,
                                                     List<LocalObjectReference> imagePullSecrets); ImageStream generateSourceImageStream(); ImageStream generateTargetImageStream(); BuildConfig generateBuildConfig(); boolean isInsecureSourceRepository(); void setInsecureSourceRepository(boolean insecureSourceRepository); void setBuildResourceRequirements(ResourceRequirements buildRequirements);  }
@Test public void testGenerateBuildConfig() { BuildConfig bc = kc.generateBuildConfig(); assertThat(bc.getMetadata().getName(), is(KafkaConnectS2IResources.buildConfigName(cluster))); assertThat(bc.getMetadata().getNamespace(), is(namespace)); assertThat(bc.getMetadata().getLabels(), is(expectedLabels(KafkaConnectS2IResources.buildConfigName(cluster)))); assertThat(bc.getSpec().getOutput().getTo().getKind(), is("ImageStreamTag")); assertThat(bc.getSpec().getOutput().getTo().getName(), is(kc.image)); assertThat(bc.getSpec().getRunPolicy(), is("Serial")); assertThat(bc.getSpec().getSource().getType(), is("Binary")); assertThat(bc.getSpec().getSource().getBinary(), is(new BinaryBuildSource())); assertThat(bc.getSpec().getStrategy().getType(), is("Source")); assertThat(bc.getSpec().getStrategy().getSourceStrategy().getFrom().getKind(), is("ImageStreamTag")); assertThat(bc.getSpec().getStrategy().getSourceStrategy().getFrom().getName(), is(KafkaConnectS2IResources.sourceImageStreamName(cluster) + ":" + kc.sourceImageTag)); assertThat(bc.getSpec().getTriggers().size(), is(2)); assertThat(bc.getSpec().getTriggers().get(0).getType(), is("ConfigChange")); assertThat(bc.getSpec().getTriggers().get(1).getType(), is("ImageChange")); assertThat(bc.getSpec().getTriggers().get(1).getImageChange(), is(new ImageChangeTrigger())); assertThat(bc.getSpec().getSuccessfulBuildsHistoryLimit(), is(Integer.valueOf(5))); assertThat(bc.getSpec().getFailedBuildsHistoryLimit(), is(Integer.valueOf(5))); assertThat(bc.getSpec().getResources().getLimits().get("cpu").getAmount(), is("42")); assertThat(bc.getSpec().getResources().getRequests().get("mem"), is(new Quantity("4", "Gi"))); checkOwnerReference(kc.createOwnerReference(), bc); }