Skip to content

Commit

Permalink
LPS-194616 Rename and SF
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiojimcos authored and brianchandotcom committed Sep 22, 2023
1 parent 5f56674 commit e7e1cd1
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 220 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ private void _validateSingleElementPath(
"x-must-start-with-the-x-character");
}

Matcher individualMatcher = _individualPathPattern.matcher(pathString);
Matcher singleElementPathMatcher = _singleElementPathPattern.matcher(
pathString);

if (!individualMatcher.matches()) {
if (!singleElementPathMatcher.matches()) {
throw new ObjectEntryValuesException.InvalidObjectField(
Arrays.asList(objectField.getLabel(user.getLocale())),
"%s can have a maximum of 255 alphanumeric characters",
Expand All @@ -285,10 +286,10 @@ private void _validateSingleElementPath(

private static final Pattern _curlyBracePattern = Pattern.compile(
"^\\{[a-zA-Z0-9]+\\}$");
private static final Pattern _individualPathPattern = Pattern.compile(
"/[a-zA-Z0-9][a-zA-Z0-9-/-{\\-}]{1,253}");
private static final Pattern _pathPattern = Pattern.compile(
"/[a-zA-Z0-9][a-zA-Z0-9-/]{1,253}");
private static final Pattern _singleElementPathPattern = Pattern.compile(
"/[a-zA-Z0-9][a-zA-Z0-9-/-{\\-}]{1,253}");

@Reference(
target = "(filter.factory.key=" + ObjectDefinitionConstants.STORAGE_TYPE_DEFAULT + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,46 @@ public void testGetOperationIdWithCollection() {
}

@Test
public void testGetOperationIdWithSingleElementByExternalReferenceCode() {
public void testGetOperationIdWithScopedSingleElementByExternalReferenceCode() {
Assert.assertEquals(
"getSchemaByExternalReferenceCodeSchemaERC",
"getScopeScopeKeyByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/schemas/by-external-reference-code/{schemaERC}",
"/scopes/{scopeKey}/by-external-reference-code/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeyByExternalReferenceCodeSchemaExternal" +
"ReferenceCode",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/by-external-reference-code " +
"/{schemaExternalReferenceCode}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeyPathNameByExternalReferenceCodePathNameERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/path-names/by-external-reference-code" +
"/{pathNameERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeySchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/schemas/by-external-reference-code" +
"/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, null));
Assert.assertEquals(
"getScopeScopeKeySchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/schemas/by-external-reference-code" +
"/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
}

@Test
public void testGetOperationIdWithSingleElementByExternalReferenceCode() {
Assert.assertEquals(
"getByExternalReferenceCode",
OpenAPIUtil.getOperationId(
Expand All @@ -95,6 +128,12 @@ public void testGetOperationIdWithSingleElementByExternalReferenceCode() {
OpenAPIUtil.getOperationId(
Http.Method.GET, "/path-names/{pathNameERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getSchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/schemas/by-external-reference-code/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getSchemaWhateverWhateverERC",
OpenAPIUtil.getOperationId(
Expand All @@ -108,7 +147,7 @@ public void testGetOperationIdWithSingleElementByExternalReferenceCode() {
}

@Test
public void testGetOperationIdWithIndividualById() {
public void testGetOperationIdWithSingleElementById() {
Assert.assertEquals(
"getCamelSchema",
OpenAPIUtil.getOperationId(
Expand Down Expand Up @@ -143,55 +182,4 @@ public void testGetOperationIdWithIndividualById() {
"CamelSchema"));
}

@Test
public void testGetOperationIdWithScopedSingleElementByExternalReferenceCode() {
Assert.assertEquals(
"getScopeScopeKeyByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/by-external-reference-code/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeySchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/schemas/by-external-reference-code" +
"/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeySchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/schemas/by-external-reference-code" +
"/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeySchemaByExternalReferenceCodeSchemaERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/schemas/by-external-reference-code" +
"/{schemaERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, null));
Assert.assertEquals(
"getScopeScopeKeyPathNameByExternalReferenceCodePathNameERC",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/path-names/by-external-reference-code" +
"/{pathNameERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getSchemaWhateverWhateverERC",
OpenAPIUtil.getOperationId(
Http.Method.GET, "/schema/whatever/{whateverERC}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
Assert.assertEquals(
"getScopeScopeKeyByExternalReferenceCodeSchemaExternal" +
"ReferenceCode",
OpenAPIUtil.getOperationId(
Http.Method.GET,
"/scopes/{scopeKey}/by-external-reference-code " +
"/{schemaExternalReferenceCode}",
APIApplication.Endpoint.RetrieveType.SINGLE_ELEMENT, "Schema"));
}

}
Loading

0 comments on commit e7e1cd1

Please sign in to comment.