Search in sources :

Example 21 with GroupCapacity

use of com.alibaba.nacos.config.server.model.capacity.GroupCapacity in project nacos by alibaba.

the class GroupCapacityPersistServiceTest method testGetClusterCapacity.

@Test
public void testGetClusterCapacity() {
    List<GroupCapacity> list = new ArrayList<>();
    GroupCapacity groupCapacity = new GroupCapacity();
    groupCapacity.setId(1L);
    list.add(groupCapacity);
    String groupId = GroupCapacityPersistService.CLUSTER;
    when(jdbcTemplate.query(anyString(), eq(new Object[] { groupId }), any(RowMapper.class))).thenReturn(list);
    Capacity ret = service.getClusterCapacity();
    Assert.assertEquals(groupCapacity.getId(), ret.getId());
}
Also used : GroupCapacity(com.alibaba.nacos.config.server.model.capacity.GroupCapacity) Capacity(com.alibaba.nacos.config.server.model.capacity.Capacity) GroupCapacity(com.alibaba.nacos.config.server.model.capacity.GroupCapacity) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.Test)

Example 22 with GroupCapacity

use of com.alibaba.nacos.config.server.model.capacity.GroupCapacity in project nacos by alibaba.

the class GroupCapacityPersistServiceTest method testIncrementUsage.

@Test
public void testIncrementUsage() {
    GroupCapacity groupCapacity = new GroupCapacity();
    Timestamp timestamp = new Timestamp(System.currentTimeMillis());
    groupCapacity.setGmtModified(timestamp);
    groupCapacity.setGroup("test3");
    when(jdbcTemplate.update(anyString(), eq(timestamp), eq("test3"))).thenReturn(1);
    Assert.assertTrue(service.incrementUsage(groupCapacity));
}
Also used : GroupCapacity(com.alibaba.nacos.config.server.model.capacity.GroupCapacity) Timestamp(java.sql.Timestamp) Test(org.junit.Test)

Aggregations

GroupCapacity (com.alibaba.nacos.config.server.model.capacity.GroupCapacity)22 Test (org.junit.Test)18 Timestamp (java.sql.Timestamp)7 ArrayList (java.util.ArrayList)7 TenantCapacity (com.alibaba.nacos.config.server.model.capacity.TenantCapacity)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 RowMapper (org.springframework.jdbc.core.RowMapper)5 Capacity (com.alibaba.nacos.config.server.model.capacity.Capacity)4 PreparedStatementCreator (org.springframework.jdbc.core.PreparedStatementCreator)2 CollectionUtils (com.alibaba.nacos.common.utils.CollectionUtils)1 DataSourceService (com.alibaba.nacos.config.server.service.datasource.DataSourceService)1 DynamicDataSource (com.alibaba.nacos.config.server.service.datasource.DynamicDataSource)1 FATAL_LOG (com.alibaba.nacos.config.server.utils.LogUtil.FATAL_LOG)1 PropertyUtil (com.alibaba.nacos.config.server.utils.PropertyUtil)1 TimeUtils (com.alibaba.nacos.config.server.utils.TimeUtils)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1