new-integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonPatchTestUtils.java
public static String patchDomainResourceWithNewAdminSecret(
      String domainResourceName,
      String namespace,
      String secretName
  ) {
    LoggingFacade logger = getLogger();
    String patch = String.format(
        "[\n  {\"op\": \"replace\", \"path\": \"/spec/%s\", \"value\": \"%s\"}\n]\n",
        "webLogicCredentialsSecret/name", secretName);
    logger.info("Patch the domain resource {0} in namespace {1} with: {2}\n",
        domainResourceName, namespace, patch);

    assertTrue(patchDomainCustomResource(
        domainResourceName,
        namespace,
        new V1Patch(patch),
        V1Patch.PATCH_FORMAT_JSON_PATCH),
        String.format("Failed to patch the domain resource %s in namespace %s with %s: %s",
            domainResourceName, namespace, "/spec/webLogicCredentialsSecret/name", secretName));

    String oldVersion = assertDoesNotThrow(
        () -> getDomainCustomResource(domainResourceName, namespace).getSpec().getRestartVersion(),
        String.format("Failed to get the restartVersion of %s in namespace %s", domainResourceName, namespace));
    int newVersion = oldVersion == null ? 1 : Integer.valueOf(oldVersion) + 1;
    logger.info("Update domain resource {0} in namespace {1} restartVersion from {2} to {3}",
        domainResourceName, namespace, oldVersion, newVersion);
    patch =
        String.format("[\n  {\"op\": \"replace\", \"path\": \"/spec/restartVersion\", \"value\": \"%s\"}\n]\n",
            newVersion);

    logger.info("Patch the domain resource {0} in namespace {1} with: {2}\n",
        domainResourceName, namespace, patch);

    assertTrue(patchDomainCustomResource(
        domainResourceName,
        namespace,
        new V1Patch(patch),
        V1Patch.PATCH_FORMAT_JSON_PATCH),
        String.format("Failed to patch the domain resource %s in namespace %s with startVersion: %s",
            domainResourceName, namespace, newVersion));

    String updatedVersion = assertDoesNotThrow(
        () -> getDomainCustomResource(domainResourceName, namespace).getSpec().getRestartVersion(),
        String.format("Failed to get the restartVersion of %s in namespace %s", domainResourceName, namespace));
    logger.info("Current restartVersion is {0}", updatedVersion);
    assertTrue(updatedVersion.equals(String.valueOf(newVersion)),
        String.format("Failed to update the restartVersion of domain %s from %s to %s",
            domainResourceName,
            oldVersion,
            newVersion));
    return String.valueOf(newVersion);
  }
/**
   * Patch the domain resource with a new WebLogic admin credentials secret.
   *
   * @param domainResourceName name of the domain resource
   * @param namespace Kubernetes namespace that the domain is hosted
   * @param secretName name of the new WebLogic admin credentials secret
   * @return restartVersion new restartVersion of the domain resource
   */
Patch the domain resource with a new WebLogic admin credentials secret.
@param domainResourceName name of the domain resource
@param namespace Kubernetes namespace that the domain is hosted
@param secretName name of the new WebLogic admin credentials secret
@return restartVersion new restartVersion of the domain resource
Patch the domain resource with a new WebLogic admin credentials secret . @param domainResourceName name of the domain resource @param namespace Kubernetes namespace that the domain is hosted @param secretName name of the new WebLogic admin credentials secret @return restartVersion new restartVersion of the domain resource
public static String patchDomainResourceWithNewAdminSecret(
      String domainResourceName,
      String namespace,
      String secretName
  ) {
    LoggingFacade logger = getLogger();
    String patch = String.format(
        "[\n  {\"op\": \"replace\", \"path\": \"/spec/%s\", \"value\": \"%s\"}\n]\n",
        "webLogicCredentialsSecret/name", secretName);
    logger.info("Patch the domain resource {0} in namespace {1} with: {2}\n",
        domainResourceName, namespace, patch);
    assertTrue(patchDomainCustomResource(
        domainResourceName,
        namespace,
        new V1Patch(patch),
        V1Patch.PATCH_FORMAT_JSON_PATCH),
        String.format("Failed to patch the domain resource %s in namespace %s with %s: %s",
            domainResourceName, namespace, "/spec/webLogicCredentialsSecret/name", secretName));
    String oldVersion = assertDoesNotThrow(
        () -> getDomainCustomResource(domainResourceName, namespace).getSpec().getRestartVersion(),
        String.format("Failed to get the restartVersion of %s in namespace %s", domainResourceName, namespace));
    int newVersion = oldVersion == null ? 1 : Integer.valueOf(oldVersion) + 1;
    logger.info("Update domain resource {0} in namespace {1} restartVersion from {2} to {3}",
        domainResourceName, namespace, oldVersion, newVersion);
    patch =
        String.format("[\n  {\"op\": \"replace\", \"path\": \"/spec/restartVersion\", \"value\": \"%s\"}\n]\n",
            newVersion);
    logger.info("Patch the domain resource {0} in namespace {1} with: {2}\n",
        domainResourceName, namespace, patch);
    assertTrue(patchDomainCustomResource(
        domainResourceName,
        namespace,
        new V1Patch(patch),
        V1Patch.PATCH_FORMAT_JSON_PATCH),
        String.format("Failed to patch the domain resource %s in namespace %s with startVersion: %s",
            domainResourceName, namespace, newVersion));
    String updatedVersion = assertDoesNotThrow(
        () -> getDomainCustomResource(domainResourceName, namespace).getSpec().getRestartVersion(),
        String.format("Failed to get the restartVersion of %s in namespace %s", domainResourceName, namespace));
    logger.info("Current restartVersion is {0}", updatedVersion);
    assertTrue(updatedVersion.equals(String.valueOf(newVersion)),
        String.format("Failed to update the restartVersion of domain %s from %s to %s",
            domainResourceName,
            oldVersion,
            newVersion));
    return String.valueOf(newVersion);
  }
public static String patchDomainResourceWithNewAdminSecret ( String domainResourceName , String namespace , String secretName ) { LoggingFacade logger = getLogger ( ) ; String patch = String . format ( "[\n  {\"op\": \"replace\", \"path\": \"/spec/%s\", \"value\": \"%s\"}\n]\n" , "webLogicCredentialsSecret/name" , secretName ) ; logger . info ( "Patch the domain resource {0} in namespace {1} with: {2}\n" , domainResourceName , namespace , patch ) ; assertTrue ( patchDomainCustomResource ( domainResourceName , namespace , new V1Patch ( patch ) , V1Patch . PATCH_FORMAT_JSON_PATCH ) , String . format ( "Failed to patch the domain resource %s in namespace %s with %s: %s" , domainResourceName , namespace , "/spec/webLogicCredentialsSecret/name" , secretName ) ) ; String oldVersion = assertDoesNotThrow ( ( ) -> getDomainCustomResource ( domainResourceName , namespace ) . getSpec ( ) . getRestartVersion ( ) , String . format ( "Failed to get the restartVersion of %s in namespace %s" , domainResourceName , namespace ) ) ; int newVersion = oldVersion == null ? 1 : Integer . valueOf ( oldVersion ) + 1 ; logger . info ( "Update domain resource {0} in namespace {1} restartVersion from {2} to {3}" , domainResourceName , namespace , oldVersion , newVersion ) ; patch = String . format ( "[\n  {\"op\": \"replace\", \"path\": \"/spec/restartVersion\", \"value\": \"%s\"}\n]\n" , newVersion ) ; logger . info ( "Patch the domain resource {0} in namespace {1} with: {2}\n" , domainResourceName , namespace , patch ) ; assertTrue ( patchDomainCustomResource ( domainResourceName , namespace , new V1Patch ( patch ) , V1Patch . PATCH_FORMAT_JSON_PATCH ) , String . format ( "Failed to patch the domain resource %s in namespace %s with startVersion: %s" , domainResourceName , namespace , newVersion ) ) ; String updatedVersion = assertDoesNotThrow ( ( ) -> getDomainCustomResource ( domainResourceName , namespace ) . getSpec ( ) . getRestartVersion ( ) , String . format ( "Failed to get the restartVersion of %s in namespace %s" , domainResourceName , namespace ) ) ; logger . info ( "Current restartVersion is {0}" , updatedVersion ) ; assertTrue ( updatedVersion . equals ( String . valueOf ( newVersion ) ) , String . format ( "Failed to update the restartVersion of domain %s from %s to %s" , domainResourceName , oldVersion , newVersion ) ) ; return String . valueOf ( newVersion ) ; }
Patch the domain resource with a new WebLogic admin credentials secret.
Patch the domain resource with a new WebLogic admin credentials secret .