public class

ScriptWithArgsSimpleAtomRemoteMessage

extends java.lang.Object

implements EspressoRemoteMessage.To<WebModelAtoms.ScriptWithArgsSimpleAtomProto>

 java.lang.Object

↳androidx.test.espresso.web.model.ScriptWithArgsSimpleAtomRemoteMessage

Gradle dependencies

compile group: 'androidx.test.espresso', name: 'espresso-remote', version: '3.6.1'

  • groupId: androidx.test.espresso
  • artifactId: espresso-remote
  • version: 3.6.1

Artifact androidx.test.espresso:espresso-remote:3.6.1 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.test.espresso:espresso-remote com.android.support.test.espresso:espresso-remote

Androidx class mapping:

androidx.test.espresso.web.model.ScriptWithArgsSimpleAtomRemoteMessage android.support.test.espresso.web.model.ScriptWithArgsSimpleAtomRemoteMessage

Overview

and implementation of androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom.

Summary

Fields
public static final EspressoRemoteMessage.From<androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom, MessageLite>FROM

This field is used to create an instance of this view action from its unwrapped proto message.

Constructors
publicScriptWithArgsSimpleAtomRemoteMessage(androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom scriptWithArgsSimpleAtom)

Methods
public WebModelAtoms.ScriptWithArgsSimpleAtomPrototoProto()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final EspressoRemoteMessage.From<androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom, MessageLite> FROM

This field is used to create an instance of this view action from its unwrapped proto message.

Constructors

public ScriptWithArgsSimpleAtomRemoteMessage(androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom scriptWithArgsSimpleAtom)

Methods

Source

/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package androidx.test.espresso.web.model;


import androidx.test.espresso.remote.EspressoRemoteMessage;
import androidx.test.espresso.remote.TypeProtoConverters;
import androidx.test.espresso.web.model.Atoms.ScriptWithArgsSimpleAtom;
import androidx.test.espresso.web.proto.model.WebModelAtoms.ScriptWithArgsSimpleAtomProto;
import androidx.test.espresso.web.proto.model.WebModelAtoms.ScriptWithArgsSimpleAtomProto.Builder;
import com.google.protobuf.ByteString;
import com.google.protobuf.MessageLite;
import java.util.ArrayList;
import java.util.List;

/**
 * {@link EspressoRemoteMessage.To} and {@link EspressoRemoteMessage.From} implementation of {@link
 * ScriptWithArgsSimpleAtom}.
 */
public class ScriptWithArgsSimpleAtomRemoteMessage
    implements EspressoRemoteMessage.To<ScriptWithArgsSimpleAtomProto> {

  /**
   * This field is used to create an instance of this view action from its unwrapped proto message.
   */
  public static final EspressoRemoteMessage.From<ScriptWithArgsSimpleAtom, MessageLite> FROM =
      new EspressoRemoteMessage.From<ScriptWithArgsSimpleAtom, MessageLite>() {
        @Override
        public ScriptWithArgsSimpleAtom fromProto(MessageLite message) {
          ScriptWithArgsSimpleAtomProto scriptWithArgsSimpleAtomProto =
              (ScriptWithArgsSimpleAtomProto) message;

          String script = scriptWithArgsSimpleAtomProto.getScript();
          List<Object> nonContextualArguments = new ArrayList<>();
          List<ByteString> argsList = scriptWithArgsSimpleAtomProto.getArgsList();
          for (ByteString arg : argsList) {
            nonContextualArguments.add(TypeProtoConverters.byteStringToType(arg));
          }
          return new ScriptWithArgsSimpleAtom(script, nonContextualArguments);
        }
      };

  private final ScriptWithArgsSimpleAtom scriptWithArgsSimpleAtom;

  public ScriptWithArgsSimpleAtomRemoteMessage(ScriptWithArgsSimpleAtom scriptWithArgsSimpleAtom) {
    this.scriptWithArgsSimpleAtom = scriptWithArgsSimpleAtom;
  }

  @Override
  public ScriptWithArgsSimpleAtomProto toProto() {
    Builder builder =
        ScriptWithArgsSimpleAtomProto.newBuilder().setScript(scriptWithArgsSimpleAtom.getScript());

    List<Object> nonContextualArguments = scriptWithArgsSimpleAtom.getNonContextualArguments();
    if (!nonContextualArguments.isEmpty()) {
      List<ByteString> argsList = new ArrayList<>(nonContextualArguments.size());
      for (Object object : nonContextualArguments) {
        argsList.add(TypeProtoConverters.typeToByteString(object));
      }
      builder.addAllArgs(argsList);
    }
    return builder.build();
  }
}