|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + */ |
| 8 | + |
| 9 | +/* |
| 10 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 11 | + * license agreements. See the NOTICE file distributed with |
| 12 | + * this work for additional information regarding copyright |
| 13 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 14 | + * the Apache License, Version 2.0 (the "License"); you may |
| 15 | + * not use this file except in compliance with the License. |
| 16 | + * You may obtain a copy of the License at |
| 17 | + * |
| 18 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | + * |
| 20 | + * Unless required by applicable law or agreed to in writing, |
| 21 | + * software distributed under the License is distributed on an |
| 22 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 23 | + * KIND, either express or implied. See the License for the |
| 24 | + * specific language governing permissions and limitations |
| 25 | + * under the License. |
| 26 | + */ |
| 27 | + |
| 28 | +/* |
| 29 | + * Modifications Copyright OpenSearch Contributors. See |
| 30 | + * GitHub history for details. |
| 31 | + */ |
| 32 | + |
| 33 | +package org.opensearch.client.opensearch.model; |
| 34 | + |
| 35 | +import static java.util.Collections.emptyList; |
| 36 | + |
| 37 | +import java.util.HashMap; |
| 38 | +import org.junit.Assert; |
| 39 | +import org.junit.Test; |
| 40 | +import org.opensearch.client.opensearch._types.CompletionStats; |
| 41 | +import org.opensearch.client.opensearch._types.DocStats; |
| 42 | +import org.opensearch.client.opensearch._types.FielddataStats; |
| 43 | +import org.opensearch.client.opensearch._types.FlushStats; |
| 44 | +import org.opensearch.client.opensearch._types.GetStats; |
| 45 | +import org.opensearch.client.opensearch._types.IndexingStats; |
| 46 | +import org.opensearch.client.opensearch._types.MergesStats; |
| 47 | +import org.opensearch.client.opensearch._types.RecoveryStats; |
| 48 | +import org.opensearch.client.opensearch._types.RefreshStats; |
| 49 | +import org.opensearch.client.opensearch._types.RequestCacheStats; |
| 50 | +import org.opensearch.client.opensearch._types.SearchStats; |
| 51 | +import org.opensearch.client.opensearch._types.SegmentsStats; |
| 52 | +import org.opensearch.client.opensearch._types.StoreStats; |
| 53 | +import org.opensearch.client.opensearch._types.TranslogStats; |
| 54 | +import org.opensearch.client.opensearch._types.WarmerStats; |
| 55 | +import org.opensearch.client.opensearch.indices.stats.ShardCommit; |
| 56 | +import org.opensearch.client.opensearch.indices.stats.ShardPath; |
| 57 | +import org.opensearch.client.opensearch.indices.stats.ShardQueryCache; |
| 58 | +import org.opensearch.client.opensearch.indices.stats.ShardRetentionLeases; |
| 59 | +import org.opensearch.client.opensearch.indices.stats.ShardRouting; |
| 60 | +import org.opensearch.client.opensearch.indices.stats.ShardRoutingState; |
| 61 | +import org.opensearch.client.opensearch.indices.stats.ShardSequenceNumber; |
| 62 | +import org.opensearch.client.opensearch.indices.stats.ShardStats; |
| 63 | +import org.opensearch.client.util.MissingRequiredPropertyException; |
| 64 | + |
| 65 | +public class ShardStatsTest extends Assert { |
| 66 | + |
| 67 | + @Test |
| 68 | + public void testShardStatsBulkAndShardsPropertiesNotRequired() { |
| 69 | + |
| 70 | + ShardStats.Builder builder = createShardsStatsBuilderWithRequiredFields(); |
| 71 | + |
| 72 | + try { |
| 73 | + builder.build(); |
| 74 | + } catch (MissingRequiredPropertyException e) { |
| 75 | + fail(e.getClass().getSimpleName() + " was thrown: " + e.getMessage()); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + private ShardStats.Builder createShardsStatsBuilderWithRequiredFields() { |
| 80 | + ShardCommit commit = new ShardCommit.Builder().id("").generation(0).numDocs(0).userData(new HashMap<>()).build(); |
| 81 | + CompletionStats completion = new CompletionStats.Builder().sizeInBytes(0).build(); |
| 82 | + DocStats docs = new DocStats.Builder().count(0).deleted(0).build(); |
| 83 | + FielddataStats fielddata = new FielddataStats.Builder().memorySizeInBytes(0).build(); |
| 84 | + FlushStats flush = new FlushStats.Builder().periodic(0).total(0).totalTimeInMillis(0).build(); |
| 85 | + GetStats get = new GetStats.Builder().current(0) |
| 86 | + .existsTimeInMillis(0) |
| 87 | + .existsTotal(0) |
| 88 | + .missingTimeInMillis(0) |
| 89 | + .missingTotal(0) |
| 90 | + .timeInMillis(0) |
| 91 | + .total(0) |
| 92 | + .build(); |
| 93 | + IndexingStats indexing = new IndexingStats.Builder().indexCurrent(0) |
| 94 | + .deleteCurrent(0) |
| 95 | + .deleteTimeInMillis(0) |
| 96 | + .deleteTotal(0) |
| 97 | + .isThrottled(false) |
| 98 | + .noopUpdateTotal(0) |
| 99 | + .throttleTimeInMillis(0) |
| 100 | + .indexTimeInMillis(0) |
| 101 | + .indexTotal(0) |
| 102 | + .indexFailed(0) |
| 103 | + .types(new HashMap<>()) |
| 104 | + .build(); |
| 105 | + MergesStats merges = new MergesStats.Builder().current(0) |
| 106 | + .currentDocs(0) |
| 107 | + .currentSizeInBytes(0) |
| 108 | + .total(0) |
| 109 | + .totalAutoThrottleInBytes(0) |
| 110 | + .totalDocs(0) |
| 111 | + .totalSizeInBytes(0) |
| 112 | + .totalStoppedTimeInMillis(0) |
| 113 | + .totalThrottledTimeInMillis(0) |
| 114 | + .totalTimeInMillis(0) |
| 115 | + .build(); |
| 116 | + ShardPath shardPath = new ShardPath.Builder().dataPath("").isCustomDataPath(false).statePath("").build(); |
| 117 | + ShardQueryCache queryCache = new ShardQueryCache.Builder().cacheCount(0) |
| 118 | + .cacheSize(0) |
| 119 | + .evictions(0) |
| 120 | + .hitCount(0) |
| 121 | + .memorySizeInBytes(0) |
| 122 | + .missCount(0) |
| 123 | + .totalCount(0) |
| 124 | + .build(); |
| 125 | + RecoveryStats recovery = new RecoveryStats.Builder().currentAsSource(0).currentAsTarget(0).throttleTimeInMillis(0).build(); |
| 126 | + RefreshStats refresh = new RefreshStats.Builder().externalTotal(0) |
| 127 | + .externalTotalTimeInMillis(0) |
| 128 | + .listeners(0) |
| 129 | + .total(0) |
| 130 | + .totalTimeInMillis(0) |
| 131 | + .build(); |
| 132 | + RequestCacheStats requestCache = new RequestCacheStats.Builder().evictions(0).hitCount(0).memorySizeInBytes(0).missCount(0).build(); |
| 133 | + ShardRetentionLeases retentionLeases = new ShardRetentionLeases.Builder().primaryTerm(0).version(0).leases(emptyList()).build(); |
| 134 | + ShardRouting routing = new ShardRouting.Builder().node("").primary(false).state(ShardRoutingState.Unassigned).build(); |
| 135 | + SearchStats search = new SearchStats.Builder().fetchCurrent(0) |
| 136 | + .fetchTimeInMillis(0) |
| 137 | + .fetchTotal(0) |
| 138 | + .queryCurrent(0) |
| 139 | + .queryTimeInMillis(0) |
| 140 | + .queryTotal(0) |
| 141 | + .scrollCurrent(0) |
| 142 | + .scrollTimeInMillis(0) |
| 143 | + .scrollTotal(0) |
| 144 | + .suggestCurrent(0) |
| 145 | + .suggestTimeInMillis(0) |
| 146 | + .suggestTotal(0) |
| 147 | + .build(); |
| 148 | + SegmentsStats segments = new SegmentsStats.Builder().count(0) |
| 149 | + .docValuesMemoryInBytes(0) |
| 150 | + .fileSizes(new HashMap<>()) |
| 151 | + .fixedBitSetMemoryInBytes(0) |
| 152 | + .indexWriterMemoryInBytes(0) |
| 153 | + .maxUnsafeAutoIdTimestamp(0) |
| 154 | + .memoryInBytes(0) |
| 155 | + .normsMemoryInBytes(0) |
| 156 | + .pointsMemoryInBytes(0) |
| 157 | + .storedFieldsMemoryInBytes(0) |
| 158 | + .termsMemoryInBytes(0) |
| 159 | + .termVectorsMemoryInBytes(0) |
| 160 | + .versionMapMemoryInBytes(0) |
| 161 | + .build(); |
| 162 | + ShardSequenceNumber seqNo = new ShardSequenceNumber.Builder().globalCheckpoint(0).localCheckpoint(0).maxSeqNo(0).build(); |
| 163 | + StoreStats store = new StoreStats.Builder().sizeInBytes(0).reservedInBytes(0).build(); |
| 164 | + TranslogStats translog = new TranslogStats.Builder().earliestLastModifiedAge(0) |
| 165 | + .operations(0) |
| 166 | + .sizeInBytes(0) |
| 167 | + .uncommittedOperations(0) |
| 168 | + .uncommittedSizeInBytes(0) |
| 169 | + .build(); |
| 170 | + WarmerStats warmer = new WarmerStats.Builder().current(0).total(0).totalTimeInMillis(0).build(); |
| 171 | + |
| 172 | + ShardStats.Builder builder = new ShardStats.Builder(); |
| 173 | + |
| 174 | + builder.commit(commit) |
| 175 | + .completion(completion) |
| 176 | + .docs(docs) |
| 177 | + .fielddata(fielddata) |
| 178 | + .flush(flush) |
| 179 | + .get(get) |
| 180 | + .indexing(indexing) |
| 181 | + .merges(merges) |
| 182 | + .shardPath(shardPath) |
| 183 | + .queryCache(queryCache) |
| 184 | + .recovery(recovery) |
| 185 | + .refresh(refresh) |
| 186 | + .requestCache(requestCache) |
| 187 | + .retentionLeases(retentionLeases) |
| 188 | + .routing(routing) |
| 189 | + .search(search) |
| 190 | + .segments(segments) |
| 191 | + .seqNo(seqNo) |
| 192 | + .store(store) |
| 193 | + .translog(translog) |
| 194 | + .warmer(warmer); |
| 195 | + |
| 196 | + return builder; |
| 197 | + } |
| 198 | +} |
0 commit comments