/** * * * <pre> * Required. * The job to add. The user can optionally specify a name for the * job in [name][google.cloud.scheduler.v1beta1.Job.name]. [name][google.cloud.scheduler.v1beta1.Job.name] cannot be the same as an * existing job. If a name is not specified then the system will * generate a random unique name that will be returned * ([name][google.cloud.scheduler.v1beta1.Job.name]) in the response. * </pre> * * <code>.google.cloud.scheduler.v1beta1.Job job = 2;</code> */ public com.google.cloud.scheduler.v1beta1.JobOrBuilder getJobOrBuilder() { return getJob(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getParentBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); } if (job_ != null) { output.writeMessage(2, getJob()); } unknownFields.writeTo(output); }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (!getParentBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); } if (job_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getJob()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PARENT_FIELD_NUMBER; hash = (53 * hash) + getParent().hashCode(); if (hasJob()) { hash = (37 * hash) + JOB_FIELD_NUMBER; hash = (53 * hash) + getJob().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.scheduler.v1beta1.CreateJobRequest)) { return super.equals(obj); } com.google.cloud.scheduler.v1beta1.CreateJobRequest other = (com.google.cloud.scheduler.v1beta1.CreateJobRequest) obj; boolean result = true; result = result && getParent().equals(other.getParent()); result = result && (hasJob() == other.hasJob()); if (hasJob()) { result = result && getJob().equals(other.getJob()); } result = result && unknownFields.equals(other.unknownFields); return result; }
public Builder mergeFrom(com.google.cloud.scheduler.v1beta1.CreateJobRequest other) { if (other == com.google.cloud.scheduler.v1beta1.CreateJobRequest.getDefaultInstance()) return this; if (!other.getParent().isEmpty()) { parent_ = other.parent_; onChanged(); } if (other.hasJob()) { mergeJob(other.getJob()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Test @SuppressWarnings("all") public void createJobTest() { JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); String description = "description-1724546052"; String schedule = "schedule-697920873"; String timeZone = "timeZone36848094"; Job expectedResponse = Job.newBuilder() .setName(name.toString()) .setDescription(description) .setSchedule(schedule) .setTimeZone(timeZone) .build(); mockCloudScheduler.addResponse(expectedResponse); LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); Job job = Job.newBuilder().build(); Job actualResponse = client.createJob(parent, job); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockCloudScheduler.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateJobRequest actualRequest = (CreateJobRequest) actualRequests.get(0); Assert.assertEquals(parent, LocationName.parse(actualRequest.getParent())); Assert.assertEquals(job, actualRequest.getJob()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }