Skip to content

Commit

Permalink
fix #4067 running spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Jun 3, 2022
1 parent 064bd2e commit d487d69
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author <a href="[email protected]">Christophe Laprun</a>
*/
public abstract class Base<Spec extends BaseSpec, Status extends BaseStatus>
extends CustomResource<Spec, Status>
implements Namespaced {
extends CustomResource<Spec, Status>
implements Namespaced {

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
@Group("acme.com")
public class Child extends Base<ChildSpec, ChildStatus> implements Namespaced {


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package io.fabric8.crd.generator.inherited;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.utils.Serialization;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ChildCRDTest {

@Test
void testCrd() {
CustomResourceDefinition d = Serialization.unmarshal(getClass().getClassLoader()
.getResourceAsStream("META-INF/fabric8/children.acme.com-v1.yml"),
CustomResourceDefinition.class);
CustomResourceDefinition.class);
assertNotNull(d);
assertEquals("Child", d.getSpec().getNames().getKind());
assertEquals("children", d.getSpec().getNames().getPlural());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,57 @@
@Version("v1alpha1")
@JsonInclude(Include.NON_NULL)
public class Joke extends CustomResource<Void, Void> implements Namespaced {
private String joke;
private String category;
private boolean safe;
private String lang;
private int id;
private String joke;
private String category;
private boolean safe;
private String lang;
private int id;

public Joke() {
}
public Joke() {
}

public Joke(int id, String joke, String category, boolean safe, String lang) {
this.id = id;
getMetadata().setName("" + id);
this.joke = joke;
this.category = category;
this.safe = safe;
this.lang = lang;
}
public Joke(int id, String joke, String category, boolean safe, String lang) {
this.id = id;
getMetadata().setName("" + id);
this.joke = joke;
this.category = category;
this.safe = safe;
this.lang = lang;
}

public int getId() {
return id;
}
public int getId() {
return id;
}

public String getJoke() {
return joke;
}
public String getJoke() {
return joke;
}

public void setJoke(String joke) {
this.joke = joke;
}
public void setJoke(String joke) {
this.joke = joke;
}

public String getCategory() {
return category;
}
public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}
public void setCategory(String category) {
this.category = category;
}

public boolean isSafe() {
return safe;
}
public boolean isSafe() {
return safe;
}

public void setSafe(boolean safe) {
this.safe = safe;
}
public void setSafe(boolean safe) {
this.safe = safe;
}

public String getLang() {
return lang;
}
public String getLang() {
return lang;
}

public void setLang(String lang) {
this.lang = lang;
}
public void setLang(String lang) {
this.lang = lang;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@
package io.fabric8.crd.generator.joke;

public class JokeRequestSpec {
public enum Category {
Any,
Misc,
Programming,
Dark,
Pun,
Spooky,
Christmas
}
public enum Category {
Any,
Misc,
Programming,
Dark,
Pun,
Spooky,
Christmas
}

public enum ExcludedTopic {
nsfw,
religious,
political,
racist,
sexist,
explicit
}
public enum ExcludedTopic {
nsfw,
religious,
political,
racist,
sexist,
explicit
}

private Category category = Category.Any;
private ExcludedTopic[] excluded = new ExcludedTopic[] { ExcludedTopic.nsfw, ExcludedTopic.racist, ExcludedTopic.sexist };
private boolean safe;
private Category category = Category.Any;
private ExcludedTopic[] excluded = new ExcludedTopic[] { ExcludedTopic.nsfw, ExcludedTopic.racist, ExcludedTopic.sexist };
private boolean safe;

public Category getCategory() {
return category;
}
public Category getCategory() {
return category;
}

public void setCategory(Category category) {
this.category = category;
}
public void setCategory(Category category) {
this.category = category;
}

public ExcludedTopic[] getExcluded() {
return excluded;
}
public ExcludedTopic[] getExcluded() {
return excluded;
}

public void setExcluded(ExcludedTopic[] excluded) {
this.excluded = excluded;
}
public void setExcluded(ExcludedTopic[] excluded) {
this.excluded = excluded;
}

public boolean isSafe() {
return safe;
}
public boolean isSafe() {
return safe;
}

public void setSafe(boolean safe) {
this.safe = safe;
}
public void setSafe(boolean safe) {
this.safe = safe;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@
package io.fabric8.crd.generator.joke;

public class JokeRequestStatus {
public enum State {
CREATED,
ALREADY_PRESENT,
PROCESSING,
ERROR,
UNKNOWN
}

private State state = State.UNKNOWN;
private boolean error;
private String message;
public State getState() {
return state;
}

public void setState(State state) {
this.state = state;
}

public boolean isError() {
return error;
}

public void setError(boolean error) {
this.error = error;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
public enum State {
CREATED,
ALREADY_PRESENT,
PROCESSING,
ERROR,
UNKNOWN
}

private State state = State.UNKNOWN;
private boolean error;
private String message;

public State getState() {
return state;
}

public void setState(State state) {
this.state = state;
}

public boolean isError() {
return error;
}

public void setError(boolean error) {
this.error = error;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package io.fabric8.crd.generator.zookeeper;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionVersion;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaProps;
Expand All @@ -28,11 +24,17 @@
import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ZookeeperCustomResourceTest {

@Test
void testCrd() {
CustomResourceDefinition d = Serialization.unmarshal(getClass().getClassLoader().getResourceAsStream("META-INF/fabric8/zookeepers.io.zookeeper-v1beta1.yml"), CustomResourceDefinition.class);
CustomResourceDefinition d = Serialization.unmarshal(
getClass().getClassLoader().getResourceAsStream("META-INF/fabric8/zookeepers.io.zookeeper-v1beta1.yml"),
CustomResourceDefinition.class);
assertNotNull(d);
assertEquals("Zookeeper", d.getSpec().getNames().getKind());
assertEquals("zookeepers", d.getSpec().getNames().getPlural());
Expand All @@ -44,28 +46,29 @@ void testCrd() {
assertEquals(".spec.size", d.getSpec().getSubresources().getScale().getSpecReplicasPath());
assertNotNull(d.getSpec().getSubresources().getStatus());

Optional<CustomResourceDefinitionVersion> v1 = d.getSpec().getVersions().stream().filter(v -> v.getName().equals("v1")).findFirst();
Optional<CustomResourceDefinitionVersion> v1 = d.getSpec().getVersions().stream().filter(v -> v.getName().equals("v1"))
.findFirst();
assertTrue(v1.isPresent());
v1.ifPresent(v -> {
//Let's check that version is marked as required
Object spec = v.getSchema().getOpenAPIV3Schema().getProperties().get("spec");
assertNotNull(spec);
JSONSchemaProps props = (JSONSchemaProps) spec;
List<String> required = props.getRequired();
assertTrue(required.contains("version"));
});
//Let's check that version is marked as required
Object spec = v.getSchema().getOpenAPIV3Schema().getProperties().get("spec");
assertNotNull(spec);
JSONSchemaProps props = (JSONSchemaProps) spec;
List<String> required = props.getRequired();
assertTrue(required.contains("version"));
});

Optional<CustomResourceDefinitionVersion> v1alpha1 = d.getSpec().getVersions().stream().filter(v -> v.getName().equals("v1alpha1")).findFirst();
Optional<CustomResourceDefinitionVersion> v1alpha1 = d.getSpec().getVersions().stream()
.filter(v -> v.getName().equals("v1alpha1")).findFirst();
assertTrue(v1alpha1.isPresent());
v1.ifPresent(v -> {
//Let's check that version is marked as required
Object spec = v.getSchema().getOpenAPIV3Schema().getProperties().get("spec");
assertNotNull(spec);
JSONSchemaProps props = (JSONSchemaProps) spec;
List<String> required = props.getRequired();
assertTrue(required.contains("version"));
});
//Let's check that version is marked as required
Object spec = v.getSchema().getOpenAPIV3Schema().getProperties().get("spec");
assertNotNull(spec);
JSONSchemaProps props = (JSONSchemaProps) spec;
List<String> required = props.getRequired();
assertTrue(required.contains("version"));
});

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@
public class Zookeeper extends CustomResource<ZookeeperSpec, ZookeeperStatus> implements Namespaced {

}

Loading

0 comments on commit d487d69

Please sign in to comment.