PageRenderTime 3019ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/CreateDriveRequestToMapTest.java

http://github.com/jclouds/jclouds
Java | 62 lines | 35 code | 10 blank | 17 comment | 0 complexity | fa6d30310b9c9bbcebbee49b396415ec MD5 | raw file
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.jclouds.elasticstack.functions;
  18. import static org.testng.Assert.assertEquals;
  19. import java.io.IOException;
  20. import org.jclouds.elasticstack.domain.ClaimType;
  21. import org.jclouds.elasticstack.domain.CreateDriveRequest;
  22. import org.testng.annotations.Test;
  23. import com.google.common.collect.ImmutableMap;
  24. import com.google.common.collect.ImmutableSet;
  25. import com.google.inject.Guice;
  26. @Test(groups = { "unit" })
  27. public class CreateDriveRequestToMapTest {
  28. private static final CreateDriveRequestToMap BASEDRIVE_TO_MAP = Guice.createInjector().getInstance(
  29. CreateDriveRequestToMap.class);
  30. public void testBasics() {
  31. assertEquals(BASEDRIVE_TO_MAP.apply(new CreateDriveRequest.Builder().name("foo").size(100L).build()),
  32. ImmutableMap.of("name", "foo", "size", "100"));
  33. }
  34. public void testComplete() throws IOException {
  35. CreateDriveRequest one = new CreateDriveRequest.Builder()
  36. .name("Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System")
  37. //
  38. .size(8589934592L)//
  39. .claimType(ClaimType.SHARED)//
  40. .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))//
  41. .tags(ImmutableSet.of("tag1", "tag2")).userMetadata(ImmutableMap.of("foo", "bar", "baz", "raz"))//
  42. .encryptionCipher("aes-xts-plain").avoid(ImmutableSet.of("avoid1")).build();
  43. assertEquals(
  44. BASEDRIVE_TO_MAP.apply(one),
  45. ImmutableMap.builder().put("name", "Ubuntu 10.10 Server Edition Linux 64bit Preinstalled System")
  46. .put("size", "8589934592").put("claim:type", "shared")
  47. .put("readers", "ffffffff-ffff-ffff-ffff-ffffffffffff").put("tags", "tag1 tag2")
  48. .put("user:foo", "bar").put("user:baz", "raz").put("encryption:cipher", "aes-xts-plain")
  49. .put("avoid", "avoid1").build()
  50. );
  51. }
  52. }