-
Notifications
You must be signed in to change notification settings - Fork 9
add disabled field to services and service links #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,23 @@ public class Service { | |
private String linkIdRegex; | ||
private String name; | ||
private Set<Role> roles; | ||
private boolean disabled; | ||
|
||
public Service(int serviceId, int siteId, String name, Set<Role> roles) { | ||
this(serviceId, siteId, name, roles, null); | ||
this(serviceId, siteId, name, roles, null, false); | ||
} | ||
|
||
public Service(int serviceId, int siteId, String name, Set<Role> roles, String linkIdRegex) { | ||
this(serviceId, siteId, name, roles, linkIdRegex, false); | ||
} | ||
|
||
public Service(int serviceId, int siteId, String name, Set<Role> roles, String linkIdRegex, boolean disabled) { | ||
this.serviceId = serviceId; | ||
this.siteId = siteId; | ||
this.name = name; | ||
this.roles = Objects.requireNonNullElseGet(roles, HashSet::new); | ||
this.linkIdRegex = linkIdRegex; | ||
this.disabled = disabled; | ||
} | ||
|
||
public int getServiceId() { | ||
|
@@ -65,6 +71,14 @@ public void setRoles(Set<Role> roles) { | |
this.roles = Objects.requireNonNullElseGet(roles, HashSet::new); | ||
} | ||
|
||
public boolean isDisabled() { | ||
return disabled; | ||
} | ||
|
||
public void setDisabled(boolean disabled) { | ||
this.disabled = disabled; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Service{" + | ||
|
@@ -73,6 +87,7 @@ public String toString() { | |
", name='" + name + '\'' + | ||
", roles=" + roles + | ||
", linkIdRegex=" + linkIdRegex + | ||
", disabled=" + disabled + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't we decide to use lombok at some point? |
||
'}'; | ||
} | ||
|
||
|
@@ -84,13 +99,14 @@ public boolean equals(Object o) { | |
|
||
return serviceId == other.serviceId | ||
&& siteId == other.siteId | ||
&& disabled == other.disabled | ||
&& Objects.equals(name, other.name) | ||
&& Objects.equals(roles, other.roles) | ||
&& Objects.equals(linkIdRegex, other.linkIdRegex); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(serviceId, siteId, name, roles.hashCode(), linkIdRegex); | ||
return Objects.hash(serviceId, siteId, name, roles.hashCode(), linkIdRegex, disabled); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,13 +41,32 @@ private JsonObject makeMetadata(String location) { | |
return metadata; | ||
} | ||
|
||
private ServiceLink addServiceLink(JsonArray content, String linkId, int serviceId, int siteId, String name, Set<Role> roles) { | ||
ServiceLink link = new ServiceLink(linkId, serviceId, siteId, name, roles); | ||
private ServiceLink addServiceLink(JsonArray content, String linkId, int serviceId, int siteId, String name, Set<Role> roles, boolean disabled) { | ||
ServiceLink link = new ServiceLink(linkId, serviceId, siteId, name, roles, disabled); | ||
JsonObject jo = JsonObject.mapFrom(link); | ||
content.add(jo); | ||
return link; | ||
} | ||
|
||
@Test | ||
public void allConstructors(){ | ||
ServiceLink link = new ServiceLink("abc123", 1, 123, "Test Service 1", Set.of()); | ||
assertEquals("abc123", link.getLinkId()); | ||
assertEquals(1, link.getServiceId()); | ||
assertEquals(123, link.getSiteId()); | ||
assertEquals("Test Service 1", link.getName()); | ||
assertEquals(Set.of(), link.getRoles()); | ||
assertEquals(false, link.isDisabled()); | ||
|
||
link = new ServiceLink("abc123", 1, 123, "Test Service 1", Set.of(), true); | ||
assertEquals("abc123", link.getLinkId()); | ||
assertEquals(1, link.getServiceId()); | ||
assertEquals(123, link.getSiteId()); | ||
assertEquals("Test Service 1", link.getName()); | ||
assertEquals(Set.of(), link.getRoles()); | ||
assertEquals(true, link.isDisabled()); | ||
} | ||
|
||
@Test | ||
public void loadContent_emptyArray_loadsZeroServiceLinks() throws Exception { | ||
JsonArray content = new JsonArray(); | ||
|
@@ -62,10 +81,10 @@ public void loadContent_emptyArray_loadsZeroServiceLinks() throws Exception { | |
@Test | ||
public void loadContent_multipleServiceLinksStored_loadsAllServiceLinks() throws Exception { | ||
JsonArray content = new JsonArray(); | ||
ServiceLink l1 = addServiceLink(content, "abc123", 1, 123, "Test Service 1", Set.of()); | ||
ServiceLink l2 = addServiceLink(content, "abc123", 2, 123, "test1", Set.of(Role.MAPPER)); | ||
ServiceLink l3 = addServiceLink(content, "ghi789", 1, 123, "Test Service 1", Set.of(Role.MAPPER, Role.SHARER)); | ||
ServiceLink l4 = addServiceLink(content, "jkl1011", 3, 124, "test2", null); | ||
ServiceLink l1 = addServiceLink(content, "abc123", 1, 123, "Test Service 1", Set.of(), false); | ||
ServiceLink l2 = addServiceLink(content, "abc123", 2, 123, "test1", Set.of(Role.MAPPER), true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are introducing a mix of enabled/disabled in the test but what tests or assertions are we doing with these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. containsAll will use .equals() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, will there be tests be that assert that disabling a service link or service actually does disable it? Where would these go? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Operator, as this is where we will check if it's disabled |
||
ServiceLink l3 = addServiceLink(content, "ghi789", 1, 123, "Test Service 1", Set.of(Role.MAPPER, Role.SHARER), false); | ||
ServiceLink l4 = addServiceLink(content, "jkl1011", 3, 124, "test2", null, true); | ||
when(cloudStorage.download("locationPath")).thenReturn(makeInputStream(content)); | ||
|
||
final long count = serviceLinkStore.loadContent(makeMetadata("locationPath")); | ||
|
@@ -77,9 +96,9 @@ public void loadContent_multipleServiceLinksStored_loadsAllServiceLinks() throws | |
@Test | ||
public void getServiceLink_multipleServiceLinksStored_findsCorrectServiceLink() throws Exception { | ||
JsonArray content = new JsonArray(); | ||
ServiceLink l1 = addServiceLink(content, "abc123", 1, 123, "Test Service 1", Set.of()); | ||
ServiceLink l2 = addServiceLink(content, "abc123", 2, 123, "test1", Set.of(Role.MAPPER)); | ||
ServiceLink l3 = addServiceLink(content, "ghi789", 1, 123, "Test Service 1", Set.of(Role.MAPPER, Role.SHARER)); | ||
ServiceLink l1 = addServiceLink(content, "abc123", 1, 123, "Test Service 1", Set.of(), false); | ||
ServiceLink l2 = addServiceLink(content, "abc123", 2, 123, "test1", Set.of(Role.MAPPER), true); | ||
ServiceLink l3 = addServiceLink(content, "ghi789", 1, 123, "Test Service 1", Set.of(Role.MAPPER, Role.SHARER), false); | ||
|
||
when(cloudStorage.download("locationPath")).thenReturn(makeInputStream(content)); | ||
|
||
|
@@ -98,7 +117,7 @@ public void getServiceLink_multipleServiceLinksStored_findsCorrectServiceLink() | |
@Test | ||
public void createService_nullRole_createsServiceLinkWithEmptySetOfRoles() throws Exception { | ||
JsonArray content = new JsonArray(); | ||
ServiceLink sl = addServiceLink(content, "jkl1011", 3, 124, "Test Service", null); | ||
ServiceLink sl = addServiceLink(content, "jkl1011", 3, 124, "Test Service", null, false); | ||
|
||
when(cloudStorage.download("locationPath")).thenReturn(makeInputStream(content)); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.