You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by of...@apache.org on 2020/09/15 10:22:49 UTC
[incubator-dlab] branch develop updated: Created test for
TagServiceImpl
This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push:
new 04b14a0 Created test for TagServiceImpl
04b14a0 is described below
commit 04b14a0746d99812391ef833c11f8bfdbc245db8
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Tue Sep 15 13:21:43 2020 +0300
Created test for TagServiceImpl
---
.../dlab/backendapi/service/TagServiceImpl.java | 3 +-
.../backendapi/service/TagServiceImplTest.java | 70 ++++++++++++++++++++++
2 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/TagServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/TagServiceImpl.java
index 3b281fd..5238a2f 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/TagServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/TagServiceImpl.java
@@ -30,8 +30,7 @@ import java.util.Optional;
public class TagServiceImpl implements TagService {
@Override
- public Map<String, String> getResourceTags(UserInfo userInfo, String endpoint, String project,
- String customTag) {
+ public Map<String, String> getResourceTags(UserInfo userInfo, String endpoint, String project, String customTag) {
Map<String, String> tags = new HashMap<>();
tags.put("user_tag", userInfo.getName());
tags.put("endpoint_tag", endpoint);
diff --git a/services/self-service/src/test/java/com/epam/dlab/backendapi/service/TagServiceImplTest.java b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/TagServiceImplTest.java
new file mode 100644
index 0000000..ea6739c
--- /dev/null
+++ b/services/self-service/src/test/java/com/epam/dlab/backendapi/service/TagServiceImplTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 com.epam.dlab.backendapi.service;
+
+import com.epam.dlab.backendapi.resources.TestBase;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public class TagServiceImplTest extends TestBase {
+
+ private static final String PROJECT = "project";
+ private static final String ENDPOINT = "endpoint";
+ private static final String CUSTOM_TAG = "customTag";
+
+ TagService tagService = new TagServiceImpl();
+
+ @Test
+ public void getResourceTags() {
+ Map<String, String> actualResourceTags = tagService.getResourceTags(getUserInfo(), ENDPOINT, PROJECT, CUSTOM_TAG);
+
+ assertEquals("maps of tags are not equals", getExpectedResourceTags(), actualResourceTags);
+ }
+
+ @Test
+ public void getResourceTagsWithNullCustomTag() {
+ Map<String, String> actualResourceTags = tagService.getResourceTags(getUserInfo(), ENDPOINT, PROJECT, null);
+
+ assertEquals("maps of tags are not equals", getExpectedResourceTagsWithNullCustomTag(), actualResourceTags);
+ }
+
+ private Map<String, String> getExpectedResourceTags() {
+ Map<String, String> resourceTags = new HashMap<>();
+ resourceTags.put("user_tag", USER.toLowerCase());
+ resourceTags.put("endpoint_tag", ENDPOINT);
+ resourceTags.put("project_tag", PROJECT);
+ resourceTags.put("custom_tag", CUSTOM_TAG);
+
+ return resourceTags;
+ }
+
+ private Map<String, String> getExpectedResourceTagsWithNullCustomTag() {
+ Map<String, String> resourceTags = new HashMap<>();
+ resourceTags.put("user_tag", USER.toLowerCase());
+ resourceTags.put("endpoint_tag", ENDPOINT);
+ resourceTags.put("project_tag", PROJECT);
+
+ return resourceTags;
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org